added the bool type

This commit is contained in:
cozis
2021-10-31 17:17:14 +00:00
parent 9eaa82297f
commit 91765b2ca0
9 changed files with 175 additions and 23 deletions
+46 -4
View File
@@ -363,7 +363,7 @@ static _Bool step(Runtime *runtime, Error *error)
break;
}
case OPCODE_PUSHI:
case OPCODE_PUSHINT:
{
assert(opc == 1);
assert(ops[0].type == OPTP_INT);
@@ -378,7 +378,7 @@ static _Bool step(Runtime *runtime, Error *error)
return 1;
}
case OPCODE_PUSHF:
case OPCODE_PUSHFLT:
{
assert(opc == 1);
assert(ops[0].type == OPTP_FLOAT);
@@ -393,7 +393,7 @@ static _Bool step(Runtime *runtime, Error *error)
return 1;
}
case OPCODE_PUSHS:
case OPCODE_PUSHSTR:
{
assert(opc == 1);
assert(ops[0].type == OPTP_STRING);
@@ -408,7 +408,7 @@ static _Bool step(Runtime *runtime, Error *error)
return 1;
}
case OPCODE_PUSHV:
case OPCODE_PUSHVAR:
{
assert(opc == 1);
assert(ops[0].type == OPTP_STRING);
@@ -430,6 +430,48 @@ static _Bool step(Runtime *runtime, Error *error)
return 1;
}
case OPCODE_PUSHNNE:
{
assert(opc == 0);
Object *obj = Object_NewNone(runtime->heap, error);
if(obj == NULL)
return 0;
if(!Runtime_Push(runtime, error, obj))
return 0;
return 1;
}
case OPCODE_PUSHTRU:
{
assert(opc == 0);
Object *obj = Object_FromBool(1, runtime->heap, error);
if(obj == NULL)
return 0;
if(!Runtime_Push(runtime, error, obj))
return 0;
return 1;
}
case OPCODE_PUSHFLS:
{
assert(opc == 0);
Object *obj = Object_FromBool(0, runtime->heap, error);
if(obj == NULL)
return 0;
if(!Runtime_Push(runtime, error, obj))
return 0;
return 1;
}
case OPCODE_RETURN:
return 0;