Misc stuff, probably crashes
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#define HEAP_GET(heap, idx) (&(heap)->heap[(idx)])
|
||||
#define HEAP_SET(heap, idx, val) ((heap)->heap[(idx)] = (val))
|
||||
|
||||
static void printValue(GroundValue* val) {
|
||||
static void printValue(GroundBytecodeValue* val) {
|
||||
switch (val->type.type) {
|
||||
case GroundType_Int:
|
||||
printf("%" PRId64, val->as.Int);
|
||||
@@ -53,7 +53,7 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
goto *jumpTable[instruction->type];
|
||||
|
||||
IF: {
|
||||
GroundValue* cond = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* cond = HEAP_GET(heap, instruction->args.at[0]);
|
||||
if (cond->as.Bool) {
|
||||
return instruction->args.at[1];
|
||||
}
|
||||
@@ -67,7 +67,7 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
}
|
||||
INPUT: {
|
||||
char* input = linenoise("");
|
||||
HEAP_SET(heap, instruction->args.at[0], Ground.New.Value.String(Ground.New.String(input)));
|
||||
HEAP_SET(heap, instruction->args.at[0], Ground.New.BytecodeValue(Ground.New.Value.String(Ground.New.String(input))));
|
||||
free(input);
|
||||
return -1;
|
||||
}
|
||||
@@ -118,19 +118,19 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
return -1;
|
||||
}
|
||||
ADD: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
switch (left->type.type) {
|
||||
case GroundType_Int: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Int(left->as.Int + right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Int(left->as.Int + right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Double(left->as.Int + right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Int + right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -144,11 +144,11 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
case GroundType_Double: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Double(left->as.Double + right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Double + right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Double(left->as.Double + right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Double + right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -170,7 +170,7 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
break;
|
||||
}
|
||||
sprintf(buf, "%s%s", left->as.String.cstr, right->as.String.cstr);
|
||||
*final = Ground.New.Value.String(Ground.New.String(buf));
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.String(Ground.New.String(buf)));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -189,19 +189,19 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
return -1;
|
||||
}
|
||||
SUBTRACT: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
switch (left->type.type) {
|
||||
case GroundType_Int: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Int(left->as.Int - right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Int(left->as.Int - right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Double(left->as.Int - right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Int - right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -215,11 +215,11 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
case GroundType_Double: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Double(left->as.Double - right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Double - right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Double(left->as.Double - right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Double - right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -239,19 +239,19 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
return -1;
|
||||
}
|
||||
MULTIPLY: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
switch (left->type.type) {
|
||||
case GroundType_Int: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Int(left->as.Int * right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Int(left->as.Int * right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Double(left->as.Int * right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Int * right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -265,11 +265,11 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
case GroundType_Double: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Double(left->as.Double * right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Double * right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Double(left->as.Double * right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Double * right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -289,19 +289,19 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
return -1;
|
||||
}
|
||||
DIVIDE: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
switch (left->type.type) {
|
||||
case GroundType_Int: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Int(left->as.Int / right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Int(left->as.Int / right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Double(left->as.Int / right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Int / right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -315,11 +315,11 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
case GroundType_Double: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Double(left->as.Double / right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Double / right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Double(left->as.Double / right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(left->as.Double / right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -339,23 +339,23 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
return -1;
|
||||
}
|
||||
EQUAL: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
switch (left->type.type) {
|
||||
case GroundType_Int: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Bool(left->as.Int == right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Int == right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Bool(left->as.Int == right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Int == right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(false);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -364,15 +364,15 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
case GroundType_Double: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Bool(left->as.Double == right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Double == right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Bool(left->as.Double == right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Double == right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(false);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -380,53 +380,53 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
}
|
||||
case GroundType_Char: {
|
||||
if (right->type.type == GroundType_Char) {
|
||||
*final = Ground.New.Value.Bool(left->as.Char == right->as.Char);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Char == right->as.Char));
|
||||
} else {
|
||||
*final = Ground.New.Value.Bool(false);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GroundType_Bool: {
|
||||
if (right->type.type == GroundType_Bool) {
|
||||
*final = Ground.New.Value.Bool(left->as.Bool == right->as.Bool);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Bool == right->as.Bool));
|
||||
} else {
|
||||
*final = Ground.New.Value.Bool(false);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GroundType_String: {
|
||||
if (right->type.type == GroundType_String) {
|
||||
*final = Ground.New.Value.Bool(strcmp(left->as.String.cstr, right->as.String.cstr) == 0);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(strcmp(left->as.String.cstr, right->as.String.cstr) == 0));
|
||||
} else {
|
||||
*final = Ground.New.Value.Bool(false);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(false);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
INEQUAL: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
switch (left->type.type) {
|
||||
case GroundType_Int: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Bool(left->as.Int != right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Int != right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Bool(left->as.Int != right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Int != right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(true);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -435,15 +435,15 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
case GroundType_Double: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Bool(left->as.Double != right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Double != right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Bool(left->as.Double != right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Double != right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(true);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -451,57 +451,57 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
}
|
||||
case GroundType_Char: {
|
||||
if (right->type.type == GroundType_Char) {
|
||||
*final = Ground.New.Value.Bool(left->as.Char != right->as.Char);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Char != right->as.Char));
|
||||
} else {
|
||||
*final = Ground.New.Value.Bool(true);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GroundType_Bool: {
|
||||
if (right->type.type == GroundType_Bool) {
|
||||
*final = Ground.New.Value.Bool(left->as.Bool != right->as.Bool);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Bool != right->as.Bool));
|
||||
} else {
|
||||
*final = Ground.New.Value.Bool(true);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GroundType_String: {
|
||||
if (right->type.type == GroundType_String) {
|
||||
*final = Ground.New.Value.Bool(strcmp(left->as.String.cstr, right->as.String.cstr) != 0);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(strcmp(left->as.String.cstr, right->as.String.cstr) != 0));
|
||||
} else {
|
||||
*final = Ground.New.Value.Bool(true);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(false);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
NOT: {
|
||||
HEAP_SET(heap, instruction->args.at[1], Ground.New.Value.Bool(!HEAP_GET(heap, instruction->args.at[0])->as.Bool));
|
||||
HEAP_SET(heap, instruction->args.at[1], Ground.New.BytecodeValue(Ground.New.Value.Bool(!HEAP_GET(heap, instruction->args.at[0])->as.Bool)));
|
||||
return -1;
|
||||
}
|
||||
GREATER: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
switch (left->type.type) {
|
||||
case GroundType_Int: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Bool(left->as.Int > right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Int > right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Bool(left->as.Int > right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Int > right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(true);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -510,45 +510,45 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
case GroundType_Double: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Bool(left->as.Double > right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Double > right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Bool(left->as.Double > right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Double > right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(true);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(false);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
LESSER: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
switch (left->type.type) {
|
||||
case GroundType_Int: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Bool(left->as.Int < right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Int < right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Bool(left->as.Int < right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Int < right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(true);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -557,51 +557,51 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
case GroundType_Double: {
|
||||
switch (right->type.type) {
|
||||
case GroundType_Int: {
|
||||
*final = Ground.New.Value.Bool(left->as.Double < right->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Double < right->as.Int));
|
||||
break;
|
||||
}
|
||||
case GroundType_Double: {
|
||||
*final = Ground.New.Value.Bool(left->as.Double < right->as.Double);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Double < right->as.Double));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(true);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(true));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
*final = Ground.New.Value.Bool(false);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
AND: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
*final = Ground.New.Value.Bool(left->as.Bool && right->as.Bool);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Bool && right->as.Bool));
|
||||
|
||||
return -1;
|
||||
}
|
||||
OR: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
*final = Ground.New.Value.Bool(left->as.Bool || right->as.Bool);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Bool || right->as.Bool));
|
||||
|
||||
return -1;
|
||||
}
|
||||
XOR: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[2]);
|
||||
GroundBytecodeValue* left = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* right = HEAP_GET(heap, instruction->args.at[1]);
|
||||
|
||||
*final = Ground.New.Value.Bool(left->as.Bool != right->as.Bool);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Bool(left->as.Bool != right->as.Bool));
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -612,12 +612,12 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
return -1;
|
||||
}
|
||||
STOI: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
|
||||
char* status = NULL;
|
||||
|
||||
*final = Ground.New.Value.Int(strtoll(in->as.String.cstr, &status, 0));
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Int(strtoll(in->as.String.cstr, &status, 0)));
|
||||
|
||||
if (status != in->as.String.cstr) {
|
||||
Ground.Flags.error = true;
|
||||
@@ -627,12 +627,12 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
return -1;
|
||||
}
|
||||
STOD: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
|
||||
char* status = NULL;
|
||||
|
||||
*final = Ground.New.Value.Double(strtod(in->as.String.cstr, &status));
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Double(strtod(in->as.String.cstr, &status)));
|
||||
|
||||
if (status != in->as.String.cstr) {
|
||||
Ground.Flags.error = true;
|
||||
@@ -642,24 +642,24 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
return -1;
|
||||
}
|
||||
ITOC: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
|
||||
*final = Ground.New.Value.Char((char)in->as.Int);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Char((char)in->as.Int));
|
||||
|
||||
return -1;
|
||||
}
|
||||
CTOI: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
|
||||
*final = Ground.New.Value.Int((int64_t)in->as.Char);
|
||||
*final = Ground.New.BytecodeValue(Ground.New.Value.Int((int64_t)in->as.Char));
|
||||
|
||||
return -1;
|
||||
}
|
||||
TOSTRING: {
|
||||
GroundValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
GroundBytecodeValue* final = HEAP_GET(heap, instruction->args.at[1]);
|
||||
GroundBytecodeValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
|
||||
char buf[4096];
|
||||
|
||||
@@ -681,7 +681,7 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
break;
|
||||
}
|
||||
case GroundType_String: {
|
||||
*in = Ground.New.Value.String(final->as.String);
|
||||
*in = Ground.New.BytecodeValue(Ground.New.Value.String(final->as.String));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -692,7 +692,7 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
}
|
||||
}
|
||||
|
||||
*in = Ground.New.Value.String(Ground.New.String(buf));
|
||||
*in = Ground.New.BytecodeValue(Ground.New.Value.String(Ground.New.String(buf)));
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -744,9 +744,9 @@ int64_t _GroundBytecodeInstructionExecute(GroundBytecodeInstruction* instruction
|
||||
return -1;
|
||||
}
|
||||
DROP: {
|
||||
GroundValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
Ground.Free.Value(in);
|
||||
*in = Ground.New.Value.Int(0);
|
||||
GroundBytecodeValue* in = HEAP_GET(heap, instruction->args.at[0]);
|
||||
Ground.Free.BytecodeValue(in);
|
||||
*in = Ground.New.BytecodeValue(Ground.New.Value.Int(0));
|
||||
return -1;
|
||||
}
|
||||
LICENSE: {
|
||||
|
||||
Reference in New Issue
Block a user