2 Commits

Author SHA1 Message Date
6a7ea3dab9 Fix subtraction bug 2026-04-27 11:05:26 +10:00
830963c890 Small changes 2026-04-10 20:22:54 +10:00
4 changed files with 16 additions and 4 deletions

View File

@@ -16,7 +16,7 @@
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, STOI, STOD, ITOC, CTOI, TOSTRING, FUN, RETURN, ENDFUN, PUSHARG, CALL, STRUCT, ENDSTRUCT, INIT, GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, 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, STRUCT, ENDSTRUCT, INIT, GETFIELD, SETFIELD, USE, EXTERN, CREATELABEL, PAUSE, DROP, LICENSE, ERRORCMD
} GroundInstType; } GroundInstType;
typedef enum GroundValueType { typedef enum GroundValueType {

View File

@@ -1332,9 +1332,9 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
} }
if (right->type == INT) { if (right->type == INT) {
result += right->data.intVal; result -= right->data.intVal;
} else if (right->type == DOUBLE) { } else if (right->type == DOUBLE) {
result += right->data.doubleVal; result -= right->data.doubleVal;
} }
addVariable(scope->variables, in->args.args[2].value.refName, createDoubleGroundValue(result)); addVariable(scope->variables, in->args.args[2].value.refName, createDoubleGroundValue(result));
@@ -2106,7 +2106,7 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
runtimeError(TOO_MANY_ARGS, "Expecting 3 args", in, currentInstruction); runtimeError(TOO_MANY_ARGS, "Expecting 3 args", in, currentInstruction);
} }
if (in->args.args[0].type != VALUE) { if (in->args.args[0].type != VALUE) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting an Object for arg 1", in, currentInstruction); runtimeError(ARG_TYPE_MISMATCH, "Expecting a Value for arg 1", in, currentInstruction);
} }
if (in->args.args[0].value.value.type != CUSTOM) { if (in->args.args[0].value.value.type != CUSTOM) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting an Object for arg 1", in, currentInstruction); runtimeError(ARG_TYPE_MISMATCH, "Expecting an Object for arg 1", in, currentInstruction);

View File

@@ -540,6 +540,12 @@ void printGroundInstruction(GroundInstruction* gi) {
case INIT: case INIT:
printf("init"); printf("init");
break; break;
case SETFIELD:
printf("setfield");
break;
case GETFIELD:
printf("getfield");
break;
case USE: case USE:
printf("use"); printf("use");
break; break;

6
tests/log.txt Normal file
View File

@@ -0,0 +1,6 @@
Lists are deprecated, please migrate to using the "collections" library soon.
Ground runtime error:
ErrorType: Hello
ErrorContext: [1, 2, 3, Hi!]
ErrorInstruction: error "Hello" [1, 2, 3, Hi!] 1
ErrorLine: 2