3 * - By John Hodge (thePowersGang)
6 * - Bytecode Generation header
8 #ifndef _BYTECODE_GEN_H_
9 #define _BYTECODE_GEN_H_
15 typedef struct sStringList tStringList;
16 typedef struct sString tString;
34 extern int Bytecode_ConvertScript(tSpiderScript *Script, const char *DestFile);
35 extern tBC_Function *Bytecode_ConvertFunction(tScript_Function *Fcn);
36 extern tBC_Function *Bytecode_NewBlankFunction(void);
37 extern void Bytecode_DeleteFunction(tBC_Function *Fcn);
39 extern char *Bytecode_SerialiseFunction(const tBC_Function *Function, int *Length, tStringList *Strings);
40 extern int StringList_GetString(tStringList *List, const char *String, int Length);
41 extern tBC_Function *Bytecode_CreateFunction(tScript_Function *Fcn);
43 extern int Bytecode_AllocateLabel(tBC_Function *Handle);
44 extern void Bytecode_SetLabel(tBC_Function *Handle, int Label);
47 extern void Bytecode_AppendJump(tBC_Function *Handle, int Label);
48 extern void Bytecode_AppendCondJump(tBC_Function *Handle, int Label);
49 extern void Bytecode_AppendCondJumpNot(tBC_Function *Handle, int Label);
50 extern void Bytecode_AppendReturn(tBC_Function *Handle);
53 extern void Bytecode_AppendLoadVar(tBC_Function *Handle, const char *Name);
54 extern void Bytecode_AppendSaveVar(tBC_Function *Handle, const char *Name); // (Obj->)?var =
55 extern void Bytecode_AppendConstInt(tBC_Function *Handle, uint64_t Value);
56 extern void Bytecode_AppendConstReal(tBC_Function *Handle, double Value);
57 extern void Bytecode_AppendConstString(tBC_Function *Handle, const void *Data, size_t Length);
58 extern void Bytecode_AppendConstNull(tBC_Function *Handle);
60 extern void Bytecode_AppendElement(tBC_Function *Handle, const char *Name); // Obj->SubObj
61 extern void Bytecode_AppendSetElement(tBC_Function *Handle, const char *Name); // Set an object member
62 extern void Bytecode_AppendIndex(tBC_Function *Handle); // Index into an array
63 extern void Bytecode_AppendSetIndex(tBC_Function *Handle); // Write an array element
65 extern void Bytecode_AppendCreateObj(tBC_Function *Handle, const char *Name, int ArgumentCount);
66 extern void Bytecode_AppendMethodCall(tBC_Function *Handle, const char *Name, int ArgumentCount);
67 extern void Bytecode_AppendFunctionCall(tBC_Function *Handle, const char *Name, int ArgumentCount);
69 extern void Bytecode_AppendBinOp(tBC_Function *Handle, int Operation);
70 extern void Bytecode_AppendUniOp(tBC_Function *Handle, int Operation);
71 extern void Bytecode_AppendCast(tBC_Function *Handlde, int Type);
72 extern void Bytecode_AppendDuplicate(tBC_Function *Handlde);
73 extern void Bytecode_AppendDelete(tBC_Function *Handle);
75 // TODO: Are contexts needed? Should variables be allocated like labels?
76 extern void Bytecode_AppendEnterContext(tBC_Function *Handle);
77 extern void Bytecode_AppendLeaveContext(tBC_Function *Handle);
78 //extern void Bytecode_AppendImportNamespace(tBC_Function *Handle, const char *Name);
79 extern void Bytecode_AppendDefineVar(tBC_Function *Handle, const char *Name, int Type);