[m-dev.] Diff: Extra args added to enter_pred bytecode.
Bert THOMPSON
aet at cs.mu.oz.au
Thu Jun 5 17:08:47 AEST 1997
Zoltan,
Please review this diff.
The bytecode was not distinguishing at all between predicates
and functions of the same name and arity, and some crunching
was needed to determine the arity of preds/funx.
--------------------------------------------------
Estimated hours taken: 0.2
The `enter_pred' bytecode needed two extra arguments in order to
fully disambiguate some cases. The augmentations are:
- its arity
- whether it is a function or a predicate
compiler/bytecode.m:
compiler/bytecode_gen.m:
Two extra arguments added to the `enter_pred' functor, which
comes from the `byte_code' type.
CVS: ----------------------------------------------------------------------
CVS: Enter Log. Lines beginning with `CVS: ' are removed automatically
CVS:
CVS: Modified Files:
CVS: bytecode.m bytecode_gen.m
CVS: ----------------------------------------------------------------------
Index: bytecode.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode.m,v
retrieving revision 1.26
diff -u -r1.26 bytecode.m
--- 1.26 1997/05/21 02:13:09
+++ bytecode.m 1997/06/05 05:05:24
@@ -19,7 +19,8 @@
:- type byte_tree == tree(list(byte_code)).
-:- type byte_code ---> enter_pred(byte_pred_id, int)
+:- type byte_code ---> enter_pred(byte_pred_id, int,
+ byte_pred_or_func, int)
; endof_pred
; enter_proc(byte_proc_id, determinism,
int, int, list(byte_var_info))
@@ -109,6 +110,7 @@
:- type byte_label_id == int.
:- type byte_var == int.
:- type byte_temp == int.
+:- type byte_pred_or_func == int.
:- pred output_bytecode_file(string::in, list(byte_code)::in,
io__state::di, io__state::uo) is det.
@@ -191,8 +193,10 @@
:- pred output_args(byte_code, io__state, io__state).
:- mode output_args(in, di, uo) is det.
-output_args(enter_pred(PredId, ProcCount)) -->
+output_args(enter_pred(PredId, PredArity, IsFunc, ProcCount)) -->
output_pred_id(PredId),
+ output_length(PredArity),
+ output_byte(IsFunc),
output_length(ProcCount).
output_args(endof_pred) --> [].
output_args(enter_proc(ProcId, Detism, LabelCount, TempCount, Vars)) -->
@@ -310,8 +314,15 @@
:- pred debug_args(byte_code, io__state, io__state).
:- mode debug_args(in, di, uo) is det.
-debug_args(enter_pred(PredId, ProcsCount)) -->
+debug_args(enter_pred(PredId, PredArity, IsFunc, ProcsCount)) -->
debug_pred_id(PredId),
+ debug_length(PredArity),
+ (
+ { IsFunc = 0 } ->
+ debug_string("pred")
+ ;
+ debug_string("func")
+ ),
debug_length(ProcsCount).
debug_args(endof_pred) --> [].
debug_args(enter_proc(ProcId, Detism, LabelCount, TempCount, Vars)) -->
@@ -835,7 +846,7 @@
:- pred byte_code(byte_code, int).
:- mode byte_code(in, out) is det.
-byte_code(enter_pred(_, _), 0).
+byte_code(enter_pred(_, _, _, _), 0).
byte_code(endof_pred, 1).
byte_code(enter_proc(_, _, _, _, _), 2).
byte_code(endof_proc, 3).
@@ -879,7 +890,7 @@
:- pred byte_debug(byte_code, string).
:- mode byte_debug(in, out) is det.
-byte_debug(enter_pred(_, _), "enter_pred").
+byte_debug(enter_pred(_, _, _, _), "enter_pred").
byte_debug(endof_pred, "endof_pred").
byte_debug(enter_proc(_, _, _, _, _), "enter_proc").
byte_debug(endof_proc, "endof_proc").
Index: bytecode_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.27
diff -u -r1.27 bytecode_gen.m
--- 1.27 1997/05/20 01:51:36
+++ bytecode_gen.m 1997/06/05 05:06:00
@@ -52,7 +52,17 @@
ProcsCode),
{ predicate_name(ModuleInfo, PredId, PredName) },
{ list__length(ProcIds, ProcsCount) },
- { EnterCode = node([enter_pred(PredName, ProcsCount)]) },
+ { pred_info_arity(PredInfo, Arity) },
+ { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ {
+ (PredOrFunc = predicate ->
+ IsFunc = 0
+ ;
+ IsFunc = 1
+ )
+ },
+ { EnterCode = node([enter_pred(PredName, Arity, IsFunc,
+ ProcsCount)]) },
{ EndofCode = node([endof_pred]) },
{ PredCode = tree(EnterCode, tree(ProcsCode, EndofCode)) }
),
More information about the developers
mailing list