[m-dev.] for review: refactor generation of builtins
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Mar 15 16:08:15 AEDT 2000
On 15-Mar-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> +:- pred translate_builtin_2(string, string, int, list(T), simple_code(T)).
> +:- mode translate_builtin_2(in, in, in, in, out) is semidet.
I think you can find a better name than this for this predicate.
> (
> - { MaybeTest = yes(Test) }
> + { SimpleCode = test(TestExpr) }
> ->
> - ( { Test = binop(BinOp, X0, Y0) } ->
> - call_gen__generate_builtin_arg(X0, X, CodeX),
> - call_gen__generate_builtin_arg(Y0, Y, CodeY),
> + (
> + { TestExpr = binary(BinOp, X0, Y0) },
> + { X1 = convert_simple_expr(X0) },
> + { Y1 = convert_simple_expr(Y0) },
> + call_gen__generate_builtin_arg(X1, X, CodeX),
> + call_gen__generate_builtin_arg(Y1, Y, CodeY),
> { Rval = binop(BinOp, X, Y) },
> { ArgCode = tree(CodeX, CodeY) }
> - ; { Test = unop(UnOp, X0) } ->
> - call_gen__generate_builtin_arg(X0, X, ArgCode),
> - { Rval = unop(UnOp, X) }
> ;
> - { error("Malformed semi builtin predicate") }
> + { TestExpr = unary(UnOp, X0) },
> + { X1 = convert_simple_expr(X0) },
> + call_gen__generate_builtin_arg(X1, X, ArgCode),
> + { Rval = unop(UnOp, X) }
The code for converting a test into LLDS should be in its own predicate or
function, just as the code for converting an assignment into LLDS is, and
as both kinds of conversions to MLDS are.
Apart from that, the diff is fine.
Zoltan.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list