[m-rev.] for review: support foreign code in Erlang backend
Julien Fischer
juliensf at csse.unimelb.edu.au
Fri May 18 15:43:38 AEST 2007
On Fri, 18 May 2007, Peter Wang wrote:
> Estimated hours taken: 8
> Branches: main
>
> Add support for Erlang foreign_code, foreign_procs (det and semidet) and
> foreign_exports.
> compiler/elds.m:
> Extend the ELDS to hold foreign code bodies and foreign_export function
> definitions.
>
> Allow pieces of foreign code to be embedded verbatim in ELDS
> expressions.
>
> Add fixed name variables to the ELDS. These are necessary to
> communicate with foreign code which expects variables with fixed names.
>
> Move `elds_clause_arity' here from elds_to_erlang.m.
>
> compiler/erl_call_gen.m:
> Generate code for calls to foreign code.
>
> Make erl_gen_simple_expr work for unary operators that are supported.
>
> compiler/erl_code_gen.m:
> Get Erlang foreign code bodies from the HLDS and hold them in the ELDS.
>
> Generate code for calls to foreign code.
>
> Generate forwarding functions for foreign_exported procedures.
>
> compiler/elds_to_erlang.m:
> Write out foreign code bodies and foreign export functions.
>
> Conform to ELDS changes.
>
> compiler/erl_code_util.m:
> Conform to ELDS changes.
>
...
> Index: compiler/erl_code_gen.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/erl_code_gen.m,v
> retrieving revision 1.2
> diff -u -r1.2 erl_code_gen.m
> --- compiler/erl_code_gen.m 17 May 2007 03:28:12 -0000 1.2
> +++ compiler/erl_code_gen.m 18 May 2007 02:39:02 -0000
> @@ -25,7 +25,8 @@
> % - RTTI
> % - type classes
> % - many scope types not yet supported
> -% - foreign code
> +% - nondet foreign code
Don't bother implementing nondet foreign procs. We're going to drop
support for them entirely
>
> :- pred erl_gen_preds(module_info::in, list(elds_defn)::out, io::di, io::uo)
> is det.
> @@ -399,13 +426,20 @@
> erl_gen_goal_expr(scope(ScopeReason, Goal), CodeModel, InstMap, Context,
> MaybeSuccessExpr, Statement, !Info) :-
> (
> - ( ScopeReason = exist_quant(_)
> - ; ScopeReason = promise_solutions(_, _)
> - ; ScopeReason = promise_purity(_, _)
> - ; ScopeReason = barrier(_)
> - ; ScopeReason = trace_goal(_, _, _, _, _)
> - ),
> - sorry(this_file, "exotic scope type in erlang code generator")
> + ScopeReason = exist_quant(_),
> + sorry(this_file, "exist_quant scope in erlang code generator")
> + ;
> + ScopeReason = promise_solutions(_, _),
> + sorry(this_file, "promise_solutions scope in erlang code generator")
> + ;
> + ScopeReason = promise_purity(_, _),
> + sorry(this_file, "promise_purity scope in erlang code generator")
> + ;
> + ScopeReason = barrier(_),
> + sorry(this_file, "barrier scope in erlang code generator")
Handling promise_purity and barrier scopes should be trivial. Just
emit code for the goal. (You don't need to do it as part of this change
though.)
The diff looks fine.
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list