forked from ground/ground
Start work on throw and catch
This commit is contained in:
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef enum GroundInstType {
|
typedef enum GroundInstType {
|
||||||
IF, JUMP, END, INPUT, PRINT, PRINTLN, SET, GETTYPE, EXISTS, SETLIST, SETLISTAT, GETLISTAT, GETLISTSIZE, LISTAPPEND, GETSTRSIZE, GETSTRCHARAT, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, NOT, GREATER, LESSER, AND, OR, XOR, NEG, SHIFT, STOI, STOD, ITOC, CTOI, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, CALLMETHOD, STRUCT, ENDSTRUCT, INIT, GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, LICENSE, ERRORCMD
|
IF, JUMP, END, INPUT, PRINT, PRINTLN, SET, GETTYPE, EXISTS, SETLIST, SETLISTAT, GETLISTAT, GETLISTSIZE, LISTAPPEND,
|
||||||
|
GETSTRSIZE, GETSTRCHARAT, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, NOT, GREATER, LESSER, AND, OR, XOR, NEG,
|
||||||
|
SHIFT, STOI, STOD, ITOC, CTOI, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, CALLMETHOD, STRUCT, ENDSTRUCT, INIT,
|
||||||
|
GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, LICENSE, ERRORCMD, THROW, CATCH
|
||||||
} GroundInstType;
|
} GroundInstType;
|
||||||
|
|
||||||
typedef enum GroundValueType {
|
typedef enum GroundValueType {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -204,6 +204,8 @@ static GroundInstType getInstructionType(const char* inst) {
|
|||||||
if (strcmp(inst, "extern") == 0) return EXTERN;
|
if (strcmp(inst, "extern") == 0) return EXTERN;
|
||||||
if (strcmp(inst, "drop") == 0) return DROP;
|
if (strcmp(inst, "drop") == 0) return DROP;
|
||||||
if (strcmp(inst, "license") == 0) return LICENSE;
|
if (strcmp(inst, "license") == 0) return LICENSE;
|
||||||
|
if (strcmp(inst, "throw") == 0) return THROW;
|
||||||
|
if (strcmp(inst, "catch") == 0) return CATCH;
|
||||||
if (strcmp(inst, "PAUSE") == 0) return PAUSE;
|
if (strcmp(inst, "PAUSE") == 0) return PAUSE;
|
||||||
|
|
||||||
fprintf(stderr, "Error: Unknown instruction: %s\n", inst);
|
fprintf(stderr, "Error: Unknown instruction: %s\n", inst);
|
||||||
|
|||||||
@@ -794,10 +794,12 @@ GroundScope copyGroundScope(GroundScope* scope) {
|
|||||||
GroundScope newScope = {
|
GroundScope newScope = {
|
||||||
.labels = malloc(sizeof(GroundLabel*)),
|
.labels = malloc(sizeof(GroundLabel*)),
|
||||||
.variables = malloc(sizeof(GroundVariable*)),
|
.variables = malloc(sizeof(GroundVariable*)),
|
||||||
|
.catches = malloc(sizeof(GroundCatch*)),
|
||||||
.isMainScope = false
|
.isMainScope = false
|
||||||
};
|
};
|
||||||
*newScope.variables = NULL;
|
*newScope.variables = NULL;
|
||||||
*newScope.labels = NULL;
|
*newScope.labels = NULL;
|
||||||
|
*newScope.catches = NULL;
|
||||||
|
|
||||||
if (scope == NULL) {
|
if (scope == NULL) {
|
||||||
printf("oh no scope is null\n");
|
printf("oh no scope is null\n");
|
||||||
|
|||||||
12
src/types.h
12
src/types.h
@@ -29,7 +29,10 @@ void wasm_print(const char* str);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum GroundInstType {
|
typedef enum GroundInstType {
|
||||||
IF, JUMP, END, INPUT, PRINT, PRINTLN, SET, GETTYPE, EXISTS, SETLIST, SETLISTAT, GETLISTAT, GETLISTSIZE, LISTAPPEND, GETSTRSIZE, GETSTRCHARAT, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, NOT, GREATER, LESSER, AND, OR, XOR, NEG, SHIFT, STOI, STOD, ITOC, CTOI, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, CALLMETHOD, STRUCT, ENDSTRUCT, INIT, GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, LICENSE, ERRORCMD
|
IF, JUMP, END, INPUT, PRINT, PRINTLN, SET, GETTYPE, EXISTS, SETLIST, SETLISTAT, GETLISTAT, GETLISTSIZE, LISTAPPEND,
|
||||||
|
GETSTRSIZE, GETSTRCHARAT, ADD, SUBTRACT, MULTIPLY, DIVIDE, EQUAL, INEQUAL, NOT, GREATER, LESSER, AND, OR, XOR, NEG,
|
||||||
|
SHIFT, STOI, STOD, ITOC, CTOI, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, CALLMETHOD, STRUCT, ENDSTRUCT, INIT,
|
||||||
|
GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, LICENSE, ERRORCMD, THROW, CATCH
|
||||||
} GroundInstType;
|
} GroundInstType;
|
||||||
|
|
||||||
typedef enum GroundValueType {
|
typedef enum GroundValueType {
|
||||||
@@ -110,9 +113,16 @@ typedef struct GroundVariable {
|
|||||||
bool freed;
|
bool freed;
|
||||||
} GroundVariable;
|
} GroundVariable;
|
||||||
|
|
||||||
|
typedef struct GroundCatch {
|
||||||
|
char id[MAX_ID_LEN];
|
||||||
|
GroundLabel* label;
|
||||||
|
UT_hash_handle hh;
|
||||||
|
} GroundCatch;
|
||||||
|
|
||||||
typedef struct GroundScope {
|
typedef struct GroundScope {
|
||||||
GroundLabel** labels;
|
GroundLabel** labels;
|
||||||
GroundVariable** variables;
|
GroundVariable** variables;
|
||||||
|
GroundCatch** catches;
|
||||||
bool isMainScope;
|
bool isMainScope;
|
||||||
} GroundScope;
|
} GroundScope;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user