- PUSH n s_1 .. s_n : ss ==>
- s_n : s_1 .. s_n : ss
-
+
+PUSH n s_1 .. s_n : ss ==>
+ s_n : s_1 .. s_n : ss
+
hunk ./src/compiler98/ByteCode/data/bytecode.xml 72
-
+MK_AP n s_1 .. s_m : ss ==>
+ a : ss
+ where
+ a is the new application of the given function to the arguments s_1 .. s_m
+ m is the arity of the function described by constant table item n.
+
+
+MK_PAP n m s_1 .. s_m : ss ==>
+ a : ss
+
+
+APPLY n a : s_1 .. s_n : ss ==>
+ b : ss
+
+ If applying an extra n arguments to the application a would
+ super-saturate it (i.e. apply it to more arguments that the functions
+ arity) then APPLY satures the application fully and then builds further
+ applications to the built in function '_apply' to apply the rest of the
+ argument.
+
+_apply(app,arg):
+ NEED_HEAP_32
+ PUSH_ZAP arg
+ PUSH_ZAP app
+ EVAL
+ APPLY 1
+ RETURN_EVAL
+
+ which is to say it evaluates the fully-staturated application which
+ then returns another application, and this application is then applied
+ to the additional argument.
+
+MK_CON n s_1 .. s_m : ss ==>
+ a : ss
+ where
+ a is the application to the constructor given by constant table item n
+ m is the arity of the constructor
+
+
+UNPACK a : ss ==>
+ c_1 .. c_m : ss
+ where
+ c_1 .. c_m are the arguments of the constructor application a
+ m is the arity of the application a
+
+
+SLIDE n s : s_1 .. s_n : ss ==>
+ s : ss
+
+
+POP n s_1 .. s_n : ss ==>
+ ss
+
+
+ALLOC n ss ==>
+ a_1 .. a_n : ss
+ where
+ a_1 .. a_n are 'blackhole' applications.
+
+ The applications are to the function 'Prelude._black_hole'
+ which will terminate the program if evaluated.
+
+repeat x = xs
+ where
+ xs = x : xs
+
+ would be compiled as
+
+repeat(x): []
+ ALLOC 1 [ hole ]
+ PUSH 0 [ hole, hole ]
+ PUSH_ZAP_ARG x [ x, hole, hole ]
+ MK_CON (:) [ x : hole, hole ]
+ UPDATE 0 [ x:x:x:... ]
+ PUSH_ZAP 0 [ x:x:x:..., ZAP ]
+ RETURN
+
+
+UPDATE n a : s_1 .. s_n : ss ==>
+ s_1 .. s_n : ss
+ where
+ the application at s_n is overwritten with an indirection to a
+
+ UPDATE is used in conjunction with ALLOC to create cyclic memory structures.
+ UNPACK ; PUSH_ZAP n ; RETURN_EVAL
+It is used to implement dictionaries and selectors.
+ EVAL ; RETURN
+ except that it doesn't use any stack space.
+ RETURN_EVAL is thus used to implement tail call optimisation.
+
+STRING s : ss ==>
+ (c:_primCString s') : ss
+
+ where
+ c is the first character of s
+ s' is the StringNode of the rest of the characters in s
+
+ _primCString is a function to unpack more or the string
+ and is defined in src/runtime/BCKernel/primitive.c as
+
+_primCString(s):
+ NEED_HEAP_32
+ PUSH_ZAP_ARG s
+ STRING
+ RETURN
+
+ PUSH_ARG_0 ; EVAL
+
+
+