3 * by John Hodge (thePowersGang)
6 * - Generate a bytecode file
9 #include "bytecode_ops.h"
11 typedef sBC_StackEnt tBC_StackEnt;
13 enum eBC_StackEntTypes
15 ET_NULL, // Start of the stack
16 ET_FUNCTION_START, // Start of the function
17 ET_INTEGER, // Integer / Boolean
18 ET_REAL, // Real number
20 ET_REFERENCE // Reference to a tSpiderValue
30 tSpiderValue *Reference;
31 tSpiderObject *Object;
39 tBC_StackEnt Entries[];
43 int Bytecode_int_StackPop(tBC_Stack *Stack, tBC_StackEnt *Dest)
45 if( Stack->EntryCount == 0 ) return 1;
47 *Dest = Stack->Entries[Stack->EntryCount];
51 int Bytecode_int_StackPush(tBC_Stack *Stack, tBC_StackEnt *Src)
53 if( Stack->EntryCount == Stack->EntrySpace ) return 1;
54 Stack->Entries[Stack->EntryCount] = *Src;
59 #define GET_STACKVAL(dst) if((ret = Bytecode_int_StackPop(Stack, &dst))) return ret;
61 int Bytecode_ExecuteFunction(tBC_Function *Fcn, tBC_Stack *Stack, int ArgCount);
64 tBC_StackEnt val1, val2;
65 tBC_StackEnt local_vars[Fcn->MaxVariableCount+Fcn->ArgumentCount];
75 tBC_Op *nextop = op->Next;
79 nextop = Fcn->Labels[op->StringInt.Integer];
83 if( Bytecode_int_IsStackEntTrue(&val1) )
84 nextop = Fcn->Labels[op->StringInt.Integer];
88 if( !Bytecode_int_IsStackEntTrue(&val1) )
89 nextop = Fcn->Labels[op->StringInt.Integer];