[m-dev.] for review: bytecode generator enter_else

Levi Cameron l.cameron2 at ugrad.unimelb.edu.au
Tue Dec 19 16:30:31 AEDT 2000


Estimate hours taken: 0.25

Added an enter_else bytecode & commented out error

compiler/bytecode.m
       Added enter_else bytecode. This is needed so that the temp
       frame generated by enter_if can be removed
compiler/bytecode_gen.m
       More support for enter_else.
       Also removed error for unsupported code which prevents
       compilation to bytecode. (Does this need a warning?)

Index: bytecode.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode.m,v
retrieving revision 1.41
diff -u -r1.41 bytecode.m
--- bytecode.m  2000/10/06 10:18:10     1.41
+++ bytecode.m  2000/12/19 00:08:53
@@ -38,6 +38,7 @@
                                        byte_temp)
                        ;       enter_then(byte_temp)
                        ;       endof_then(byte_label_id)
+                       ;       enter_else(byte_temp)
                        ;       endof_if
                        ;       enter_negation(byte_label_id)
                        ;       endof_negation
@@ -241,6 +242,8 @@
        output_temp(FramePtrTemp).
 output_args(endof_then(FollowLabelId)) -->
        output_label_id(FollowLabelId).
+output_args(enter_else(FramePtrTemp)) -->
+       output_temp(FramePtrTemp).
 output_args(endof_if) --> [].
 output_args(enter_negation(LabelId)) -->
        output_label_id(LabelId).
@@ -367,6 +370,8 @@
        debug_temp(FramePtrTemp).
 debug_args(endof_then(FollowLabelId)) -->
        debug_label_id(FollowLabelId).
+debug_args(enter_else(FramePtrTemp)) -->
+       debug_temp(FramePtrTemp).
 debug_args(endof_if) --> [].
 debug_args(enter_negation(LabelId)) -->
        debug_label_id(LabelId).
@@ -902,6 +907,7 @@
 byte_code(fail,                                        37).
 byte_code(context(_),                          38).
 byte_code(not_supported,                       39).
+byte_code(enter_else(_),                       40).

 :- pred byte_debug(byte_code, string).
 :- mode byte_debug(in, out) is det.
@@ -922,6 +928,7 @@
 byte_debug(enter_if(_, _, _),                  "enter_if").
 byte_debug(enter_then(_),                      "enter_then").
 byte_debug(endof_then(_),                      "endof_then").
+byte_debug(enter_else(_),                      "enter_else").
 byte_debug(endof_if,                           "endof_if").
 byte_debug(enter_negation(_),                  "enter_negation").
 byte_debug(endof_negation,                     "endof_negation").
Index: bytecode_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.53
diff -u -r1.53 bytecode_gen.m
--- bytecode_gen.m      2000/11/23 04:32:26     1.53
+++ bytecode_gen.m      2000/12/18 05:32:04
@@ -183,11 +183,13 @@
                        ByteInfo = ByteInfo0
                ;
                        % XXX
-                       functor(GenericCallType, GenericCallFunctor, _),
-                       string__append_list([
+                       functor(GenericCallType, _GenericCallFunctor, _),
+                       /*string__append_list([
                                "sorry: bytecode not yet implemented for ",
                                GenericCallFunctor, " calls"], Msg),
-                       error(Msg)
+                       error(Msg)*/
+                       Code = node([not_supported]),
+                       ByteInfo = ByteInfo0
                )
        ;
                GoalExpr = call(PredId, ProcId, ArgVars, BuiltinState, _, _),
@@ -257,7 +259,8 @@
                bytecode_gen__goal(Else, ByteInfo5, ByteInfo, ElseCode),
                EnterIfCode = node([enter_if(ElseLabel, EndLabel, FrameTemp)]),

                EnterThenCode = node([enter_then(FrameTemp)]),
-               EndofThenCode = node([endof_then(EndLabel), label(ElseLabel)]),

+               EndofThenCode = node([endof_then(EndLabel), label(ElseLabel),
+                       enter_else(FrameTemp)]),
                EndofIfCode = node([endof_if, label(EndLabel)]),
                Code =
                        tree(EnterIfCode,


Levi Cameron
l.cameron2 at ugrad.unimelb.edu.au

--------------------------------------------------------------------------
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