#ifndef _BYTECODE_H_
#define _BYTECODE_H_
-struct sBytecodeHeader
+#include "bytecode_ops.h"
+
+#define BC_NS_SEPARATOR '@'
+
+typedef struct sBC_Op tBC_Op;
+typedef struct sBC_Function tBC_Function;
+
+struct sBC_Op
{
- uint32_t Magic; //!< Magic Value (identifier) "\x8FSS\r"
- uint32_t NFunctions; //!< Number of functions
- struct {
- uint32_t NameOffset; //!< Offset to the name
- uint32_t CodeOffset; //!< Offset to the code
- } Functions[];
+ tBC_Op *Next;
+ int Operation;
+ char bUseInteger; // Used for serialisation
+ char bUseString; // Used for serialisation
+ union {
+ struct {
+ int Integer;
+ char String[];
+ } StringInt;
+
+ uint64_t Integer;
+ double Real;
+ } Content;
};
-enum eBytecodeOperations
+struct sBC_Function
{
- BCOP_UNDEF,
- BCOP_NOP,
+ int LabelCount;
+ int LabelSpace;
+ tBC_Op **Labels;
- BCOP_DEFVAR,
- BCOP_RETURN,
-
- NUM_BCOP
-}
+ int MaxVariableCount;
+ // NOTE: These fields are invalid after compilation
+ int VariableCount;
+ int VariableSpace;
+ const char **VariableNames;
+ int CurContextDepth; // Used to get the real var count
+
+ int OperationCount;
+ tBC_Op *Operations;
+ tBC_Op *OperationsEnd;
+};
#endif