[Intial version of XSL style sheets Neil Mitchell **20051207130711] { hunk ./src/compiler98/ByteCode/data/bytecode.xml 37 - + hunk ./src/compiler98/ByteCode/data/bytecode.xml 47 -
- - 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 - + hunk ./src/compiler98/ByteCode/data/bytecode.xml 125 - - - + + PUSH_INT n allocates a heap node for the Int n and pushes a pointer to + the heap node on the top of the stack. + + + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 136 + + PUSH_CHAR n allocates a heap node for the Char n and pushes a pointer to + the heap node on the top of the stack. + hunk ./src/compiler98/ByteCode/data/bytecode.xml 144 - - - - - - - - - + + PUSH_CONST n pushes the nth item of the current application node's + constant table onto the top of the stack. This constant item must be a + C_NODE rather than a C_INFO (See Yhc/RTS/Heap). + + + + + + + + + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 162 - - - - - - - - - - - - - - - - - + + MK_AP n looks up the nth item of the constant table (which must be a + FInfo). It then makes a fully saturated application to this function by + taking m arguments off the stack (where m is the arity of the + function). It then builds an application in the heap to the given + function with those arguments. It then pushes a pointer to the new + application onto the top of the stack. + +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. + + + + + + + + + + + + + + + + + + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 199 - + + MK_PAP n m is a more generalised version of MK_AP that can also build + partial applications. As with MK_AP here n refers to the nth constant + table item, but unlike MK_AP the arity of the application is specified + explicitly in m. + +MK_PAP n m s_1 .. s_m : ss ==> + a : ss + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 210 - + hunk ./src/compiler98/ByteCode/data/bytecode.xml 217 - - + + APPLY n takes an application on the top of the stack an application to + additional n arguments from the stack to create a new application. + +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. +
+ The function '_apply' is defined in src/runtime/BCKernel/primitive.c as: + +_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. +
+ + hunk ./src/compiler98/ByteCode/data/bytecode.xml 250 - - - - - + + MK_CON n looks up the nth item of the constant table (which must be a + CInfo). It then builds a fully saturated application to the constructor + using the correct number of arguments from the stack. + +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 + + + + + + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 270 + + UNPACK takes from the top of the stack an application to a constructor. + It then pushes on the stack all the arguments of that constructor with + the first argument on top. + +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 + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 286 - - - + + SLIDE n takes the top item off the stack, pops n items from the stack + and then pushes the first item removed back on to the top of the stack + +SLIDE n s : s_1 .. s_n : ss ==> + s : ss + + + + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 301 - + + POP n removes n items from the top of the stack. + +POP n s_1 .. s_n : ss ==> + ss + + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 313 - + + ALLOC n creates n 'blackhole' applications in the heap and + pushes the pointers to the applications on to the top of the stack. + +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. +
+ ALLOC n is used in conjunction with UPDATE n to create + circular heap nodes. For example + +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 + +
+ hunk ./src/compiler98/ByteCode/data/bytecode.xml 349 - + + UPDATE n removes the top item from stack and uses it to 'update' the + application pointed to by the nth item of the stack. To 'update' the + application it is overwritten with an application the value from the + top of the stack. + +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. + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 365 - + hunk ./src/compiler98/ByteCode/data/bytecode.xml 367 - - - + + SELECT n is an abbreviation for + UNPACK ; PUSH_ZAP n ; RETURN_EVAL +It is used to implement dictionaries and selectors. + + + + hunk ./src/compiler98/ByteCode/data/bytecode.xml 378 + + RETURN returns the value on the top of the stack as the result of the + current function call. It then pops the top item off the frame stack to + continue the function below it (see Yhc/RTS/Machine). + hunk ./src/compiler98/ByteCode/data/bytecode.xml 386 + + EVAL takes the value on the top of the stack and evaluates it to weak + head normal form (WHNF). If the value on the top of the stack is a + constructor or partial application EVAL does nothing. If it is a + saturated application then EVAL 'calls' the function specified in the + application. It does this by pushing a new frame onto the stack + (See Yhc/RTS/Machine). + hunk ./src/compiler98/ByteCode/data/bytecode.xml 397 + + RETURN_EVAL is equivilent to + EVAL ; RETURN + except that it doesn't use any stack space. + RETURN_EVAL is thus used to implement tail call optimisation. + hunk ./src/compiler98/ByteCode/data/bytecode.xml 406 + Number of alternatives + + Jump to + + + TABLE_SWITCH examines the tag of the item on the top of the stack and + then jumps forward by the number of bytes specified by jump-table[tag]. + hunk ./src/compiler98/ByteCode/data/bytecode.xml 417 + Number of alternatives + Default label + + Tag + Jump to + + + LOOKUP_SWITCH is similar to TABLE_SWITCH but here lookup-table is an + array of tag-offset pairs. When a matching tag is found the program + jumps forward by 'offset' number of bytes. If no match is found the + program just forward by 'def' number of bytes. + hunk ./src/compiler98/ByteCode/data/bytecode.xml 435 - Tag + Value hunk ./src/compiler98/ByteCode/data/bytecode.xml 438 + + INT_SWITCH is similar to LOOKUP_SWITCH but selects on the integer value + of an int node rather than on the constructor tag number. + hunk ./src/compiler98/ByteCode/data/bytecode.xml 445 + Label + + JUMP_FALSE j removes the value from the top of the stack and if it is + the node Prelude.False then the program jumps forward by j bytes. If it + is not Prelude.False then JUMP_FALSE is a no-op. + + + + + Label + + JUMP j unconditionally jumps forward by j bytes. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + STRING removes from the top of the stack a pointer to an + application to a StringNode. It then 'unpacks' the string + into the equivilent list of characters. + +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 + + + + + + + FROM_ENUM takes a pointer to an application to a constructor from the + top of the stack and pushes onto the top of the stack a pointer to an + heap allocated Int containing the tag number of the constructor. +
+ FROM_ENUM is used (perhaps rather unsurprisingly) to implement fromEnum +
+
+ + + + PRIMITIVE takes the first constant table item, which must be an XInfo + and calls the external function using the current application node. It + pushes on the top of the stack the value returned by the external + function. +
+ PRIMITIVE is used to implement primitive functions and the FFI. +
+
+ + + + SELECTOR_EVAL is an abbreviation for + PUSH_ARG_0 ; EVAL + hunk ./src/compiler98/ByteCode/data/bytecode.xml 550 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + addfile ./src/compiler98/ByteCode/data/clist.xsl hunk ./src/compiler98/ByteCode/data/clist.xsl 1 + + + + + + + + + + + + + + + + + _ + + + + + P1 + + + _P2 + + + + + + opT + opL + opJ + op + + op + + + _ + + + + + () + + + + 1 + 2 + 1S + 2S + + + + addfile ./src/compiler98/ByteCode/data/documentation.xsl hunk ./src/compiler98/ByteCode/data/documentation.xsl 1 - + + + + + + + + + + Yhc - Bytecode Documentation + + + +

Yhc - Bytecode Documentation

+ + + +

Index

+ + +

Bytecodes

+ + + +

Primitives

+ + + + , + + + +
+ + + +

+ +

+ + + No arguments or variants + + + [ + + + , + + ] + + + + 1 variant + variants + + + +

+ + +
+ + + + + () + + + + + { | + + + , + + } + + + +
+
+ + +

+
+ + + + + +
addfile ./src/compiler98/ByteCode/data/haskell.xsl hunk ./src/compiler98/ByteCode/data/haskell.xsl 1 + + + + + + +module ByteCode.Raw(readRaw, writeRaw, RawCodes(..) where + + + + + + + + + + + + +data RawCode = + + + + + + | + + + + + + + + + + + + + + Int + + + + + [ + + + Int + + + ( + + Int + , + + ) + + + ] + + + + +readRawIns :: Int -> BinaryRead RawCode +readRawIns x = case x of + + + + + + + + -> do { + + return + ( + + + ) + } + + + + + + + + + r + <- + + rUByte + rSByte + rUShort + rSShort + error "unknown type" + + ; + + + + r + <- sequence (replicate r + (do { + + return ( + + r + , + + )})); + + + + + r + + + + + + + + + + + +writeRawIns :: RawCode -> BinaryWrite +writeRawIns x = case x of + + + + + + + + + + + + + + + -> do {wUByte + + } + + + + + + | + + isUByte + isSByte + error "doh" + + r1 + + + + r + + + + + + + + + + + + + ; + + wUByte + wSByte + wUShort + wSShort + error "doh" + + r + + + ; wUShort (length r + + ) + + + + + + ; mapM_ (\( + + ) -> do { + + }) r + + + + + + wUByte + wSByte + wUShort + wSShort + error "doh" + + s + + ; + + + + s + , + + addfile ./src/compiler98/ByteCode/data/python.xsl hunk ./src/compiler98/ByteCode/data/python.xsl 1 - + + + + + + + bytecodes = { + + + + + } + + + + + + + + : ([ + + + , + + ], ), + + + + + + ('', [ + + + , + + ]) + + + + ('', None) + + + + (None, "" + + + + }