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);
59 extern void Bytecode_AppendElement(tBC_Function *Handle, const char *Name); // Obj->SubObj
60 extern void Bytecode_AppendIndex(tBC_Function *Handle); // Index into an array
62 extern void Bytecode_AppendCreateObj(tBC_Function *Handle, const char *Name, int ArgumentCount);
63 extern void Bytecode_AppendMethodCall(tBC_Function *Handle, const char *Name, int ArgumentCount);
64 extern void Bytecode_AppendFunctionCall(tBC_Function *Handle, const char *Name, int ArgumentCount);
66 extern void Bytecode_AppendBinOp(tBC_Function *Handle, int Operation);
67 extern void Bytecode_AppendUniOp(tBC_Function *Handle, int Operation);
68 extern void Bytecode_AppendCast(tBC_Function *Handlde, int Type);
69 extern void Bytecode_AppendDuplicate(tBC_Function *Handlde);
70 extern void Bytecode_AppendDelete(tBC_Function *Handle);
72 // TODO: Are contexts needed? Should variables be allocated like labels?
73 extern void Bytecode_AppendEnterContext(tBC_Function *Handle);
74 extern void Bytecode_AppendLeaveContext(tBC_Function *Handle);
75 //extern void Bytecode_AppendImportNamespace(tBC_Function *Handle, const char *Name);
76 extern void Bytecode_AppendDefineVar(tBC_Function *Handle, const char *Name, int Type);