progress
This commit is contained in:
@@ -20,6 +20,10 @@ typedef struct GroundInstruction GroundInstruction;
|
||||
typedef struct GroundProgram GroundProgram;
|
||||
typedef struct GroundState GroundState;
|
||||
|
||||
typedef struct GroundBytecodeProgram GroundBytecodeProgram;
|
||||
typedef struct GroundBytecodeInstruction GroundBytecodeInstruction;
|
||||
typedef struct GroundBytecodeHeap GroundBytecodeHeap;
|
||||
|
||||
// --- Literal types ---
|
||||
|
||||
typedef int64_t GroundInt;
|
||||
@@ -48,23 +52,25 @@ typedef struct GroundVariable GroundVariable;
|
||||
typedef struct GroundLabel GroundLabel;
|
||||
typedef struct GroundCatch GroundCatch;
|
||||
|
||||
typedef uint64_t GroundSize;
|
||||
|
||||
// --- Complex types definitions ---
|
||||
|
||||
struct GroundString {
|
||||
char* cstr;
|
||||
size_t len;
|
||||
GroundSize len;
|
||||
};
|
||||
|
||||
struct GroundList {
|
||||
size_t capacity;
|
||||
size_t count;
|
||||
GroundSize capacity;
|
||||
GroundSize count;
|
||||
GroundValue* at;
|
||||
};
|
||||
|
||||
struct GroundFunction {
|
||||
struct {
|
||||
size_t capacity;
|
||||
size_t count;
|
||||
GroundSize capacity;
|
||||
GroundSize count;
|
||||
GroundFunctionArg* at;
|
||||
} args;
|
||||
|
||||
@@ -77,7 +83,7 @@ struct GroundFunction {
|
||||
|
||||
GroundState* closure;
|
||||
|
||||
size_t _requiredSize;
|
||||
GroundSize _requiredSize;
|
||||
};
|
||||
|
||||
struct GroundStruct {
|
||||
@@ -149,7 +155,7 @@ struct GroundArg {
|
||||
GroundValue value;
|
||||
} as;
|
||||
|
||||
size_t _offset;
|
||||
GroundSize _offset;
|
||||
};
|
||||
|
||||
enum GroundInstructionType {
|
||||
@@ -209,15 +215,15 @@ enum GroundInstructionType {
|
||||
struct GroundInstruction {
|
||||
enum GroundInstructionType type;
|
||||
struct {
|
||||
size_t len;
|
||||
size_t capacity;
|
||||
GroundSize len;
|
||||
GroundSize capacity;
|
||||
GroundArg* at;
|
||||
} args;
|
||||
};
|
||||
|
||||
struct GroundProgram {
|
||||
size_t len;
|
||||
size_t capacity;
|
||||
GroundSize len;
|
||||
GroundSize capacity;
|
||||
GroundInstruction* at;
|
||||
};
|
||||
|
||||
@@ -226,12 +232,12 @@ struct GroundVariable {
|
||||
GroundValue value;
|
||||
UT_hash_handle hh;
|
||||
|
||||
size_t _offset;
|
||||
GroundSize _offset;
|
||||
};
|
||||
|
||||
struct GroundLabel {
|
||||
char name[2048];
|
||||
size_t lineNum;
|
||||
GroundSize lineNum;
|
||||
UT_hash_handle hh;
|
||||
};
|
||||
|
||||
@@ -246,14 +252,36 @@ struct GroundState {
|
||||
GroundLabel* labels;
|
||||
GroundCatch* catches;
|
||||
|
||||
size_t _size;
|
||||
GroundSize _size;
|
||||
};
|
||||
|
||||
struct GroundIdentifier {
|
||||
char* string;
|
||||
size_t referenceCount;
|
||||
GroundSize referenceCount;
|
||||
};
|
||||
|
||||
struct GroundBytecodeProgram {
|
||||
GroundBytecodeInstruction* at;
|
||||
GroundSize capacity;
|
||||
GroundSize len;
|
||||
};
|
||||
|
||||
struct GroundBytecodeInstruction {
|
||||
GroundInstruction instruction;
|
||||
struct {
|
||||
GroundSize* at;
|
||||
GroundSize capacity;
|
||||
GroundSize len;
|
||||
} args;
|
||||
};
|
||||
|
||||
struct GroundBytecodeHeap {
|
||||
GroundValue* heap;
|
||||
GroundSize capacity;
|
||||
GroundSize count;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// INTERFACE
|
||||
//
|
||||
@@ -299,7 +327,7 @@ struct _Ground {
|
||||
GroundObject (*Object) (GroundStruct* in);
|
||||
GroundError (*Error) (GroundValue* in);
|
||||
|
||||
GroundFunction (*NativeFunction) (void* function, size_t argc, ...);
|
||||
GroundFunction (*NativeFunction) (void* function, GroundSize argc, ...);
|
||||
|
||||
GroundInstruction (*Instruction) (enum GroundInstructionType type);
|
||||
GroundProgram (*Program) ();
|
||||
@@ -368,7 +396,7 @@ struct _Ground {
|
||||
|
||||
struct {
|
||||
GroundValue* (*findVariable) (GroundState* state, const char* id);
|
||||
size_t* (*findLabel) (GroundState* state, const char* id);
|
||||
GroundSize* (*findLabel) (GroundState* state, const char* id);
|
||||
GroundCatch* (*findCatch) (GroundState* state, const char* id);
|
||||
} State;
|
||||
|
||||
@@ -384,10 +412,19 @@ struct _Ground {
|
||||
void (*printErrors)();
|
||||
|
||||
char* errors[4096];
|
||||
size_t errorCount;
|
||||
GroundSize errorCount;
|
||||
char* warnings[4096];
|
||||
size_t warningCount;
|
||||
GroundSize warningCount;
|
||||
} Log;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
void (*execute) (GroundBytecodeProgram* program, GroundBytecodeHeap* heap);
|
||||
void (*optimise) (GroundBytecodeProgram* program);
|
||||
} Program;
|
||||
struct {} Instruction;
|
||||
struct {} Heap;
|
||||
} Bytecode;
|
||||
};
|
||||
|
||||
extern struct _Ground Ground;
|
||||
|
||||
Reference in New Issue
Block a user