[m-rev.] diff: fix problems building standard library with Erlang
Peter Wang
wangp at students.csse.unimelb.edu.au
Thu Jul 12 13:05:54 AEST 2007
Estimated hours taken: 1
Branches: main
Fix problems with building the standard library with Erlang that didn't show up
without intermodule optimisation or higher optimisation levels.
compiler/erl_code_gen.m:
When calculating the arity of :- external predicates take into account
that model_non predicates need an additional success continuation
argument.
library/table_builtin.m:
Add missing arguments for hand-written stubs of :- external predicates.
library/exception.m:
Remove the Erlang foreign_proc implementations which overrode two modes
of catch_impl. Use all modes of the Mercury implementation of
catch_impl and implement builtin_catch (which it calls) for the
previously missing modes.
Index: compiler/erl_code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/erl_code_gen.m,v
retrieving revision 1.20
diff -u -r1.20 erl_code_gen.m
--- compiler/erl_code_gen.m 12 Jul 2007 01:28:42 -0000 1.20
+++ compiler/erl_code_gen.m 12 Jul 2007 02:43:36 -0000
@@ -365,7 +365,17 @@
proc_info_get_argmodes(ProcInfo, ArgModes),
erl_gen_arg_list(ModuleInfo, opt_dummy_args,
HeadVars, ArgTypes, ArgModes, InputArgs, _OutputArgs),
- ProcBody = body_external(list.length(InputArgs))
+ (
+ ( CodeModel = model_det
+ ; CodeModel = model_semi
+ ),
+ Arity = list.length(InputArgs)
+ ;
+ CodeModel = model_non,
+ % Extra argument for success continuation.
+ Arity = list.length(InputArgs) + 1
+ ),
+ ProcBody = body_external(Arity)
;
erl_gen_proc_body(CodeModel, InstMap0, Goal, ProcClause,
!Info),
Index: library/exception.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.127
diff -u -r1.127 exception.m
--- library/exception.m 9 Jul 2007 04:48:44 -0000 1.127
+++ library/exception.m 12 Jul 2007 02:43:36 -0000
@@ -1397,40 +1397,24 @@
throw({'ML_exception', T})
").
-:- pragma foreign_proc("Erlang",
- catch_impl(Pred::pred(out) is det, Handler::in(handler), T::out),
- [will_not_call_mercury, promise_pure],
-"
- T = try
- Pred()
- catch
- throw: {'ML_exception', Excp} ->
- Handler(Excp)
- end
-").
+:- pragma foreign_code("Erlang", "
-:- pragma foreign_proc("Erlang",
- catch_impl(Pred::pred(out) is semidet, Handler::in(handler), T::out),
- [will_not_call_mercury, promise_pure],
-"
- case
- try
- Pred()
+ % det ==> model_det
+ builtin_catch_3_p_0(TypeInfo, WrappedGoal, Handler) ->
+ T = try
+ WrappedGoal()
catch
throw: {'ML_exception', Excp} ->
Handler(Excp)
- end
- of
- fail ->
- SUCCESS_INDICATOR = false,
- T = null;
- T ->
- SUCCESS_INDICATOR = true
- end
-").
+ end.
-:- pragma foreign_code("Erlang", "
+ % semidet ==> model_semi
+ builtin_catch_3_p_1(_TypeInfo, _WrappedGoal, _Handler) ->
+ % This function is not called anywhere in this module.
+ mercury__private_builtin:sorry_1_p_0(
+ ""builtin_catch_3_p_1 not implemented"").
+ % cc_multi ==> model_det
builtin_catch_3_p_2(TypeInfo, WrappedGoal, Handler) ->
try
WrappedGoal()
@@ -1439,6 +1423,13 @@
Handler(Excp)
end.
+ % cc_nondet ==> model_semi
+ builtin_catch_3_p_3(_TypeInfo, _Pred, _Handler) ->
+ % This function is not called anywhere in this module.
+ mercury__private_builtin:sorry_1_p_0(
+ ""builtin_catch_3_p_3 not implemented"").
+
+ % multi ==> model_non
builtin_catch_3_p_4(_TypeInfo_for_T, Pred, Handler, Succeed) ->
try
Pred(Succeed)
@@ -1448,6 +1439,7 @@
Succeed(Result)
end.
+ % multi ==> model_non
builtin_catch_3_p_5(_TypeInfo_for_T, Pred, Handler, Succeed) ->
try
Pred(Succeed)
Index: library/table_builtin.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/table_builtin.m,v
retrieving revision 1.60
diff -u -r1.60 table_builtin.m
--- library/table_builtin.m 31 May 2007 03:03:37 -0000 1.60
+++ library/table_builtin.m 12 Jul 2007 02:43:36 -0000
@@ -2016,21 +2016,21 @@
% These stubs are needed so that the Erlang compiler doesn't complain
% about missing definitions for exported functions.
- table_memo_return_all_answers_multi_2_p_0(_) ->
+ table_memo_return_all_answers_multi_2_p_0(_, _) ->
mercury__private_builtin:sorry_1_p_0(""tabling in Erlang backend"").
- table_memo_return_all_answers_nondet_2_p_0(_) ->
+ table_memo_return_all_answers_nondet_2_p_0(_, _) ->
mercury__private_builtin:sorry_1_p_0(""tabling in Erlang backend"").
table_mm_completion_1_p_0(_) ->
mercury__private_builtin:sorry_1_p_0(""tabling in Erlang backend"").
- table_mm_return_all_multi_2_p_0(_) ->
+ table_mm_return_all_multi_2_p_0(_, _) ->
mercury__private_builtin:sorry_1_p_0(""tabling in Erlang backend"").
- table_mm_return_all_nondet_2_p_0(_) ->
+ table_mm_return_all_nondet_2_p_0(_, _) ->
mercury__private_builtin:sorry_1_p_0(""tabling in Erlang backend"").
- table_mm_suspend_consumer_2_p_0(_) ->
+ table_mm_suspend_consumer_2_p_0(_, _) ->
mercury__private_builtin:sorry_1_p_0(""tabling in Erlang backend"").
- table_mmos_consume_next_answer_multi_2_p_0(_) ->
+ table_mmos_consume_next_answer_multi_2_p_0(_, _) ->
mercury__private_builtin:sorry_1_p_0(""tabling in Erlang backend"").
- table_mmos_consume_next_answer_nondet_2_p_0(_) ->
+ table_mmos_consume_next_answer_nondet_2_p_0(_, _) ->
mercury__private_builtin:sorry_1_p_0(""tabling in Erlang backend"").
").
--------------------------------------------------------------------------
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