mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-22 07:20:05 +00:00
minor refactoring
This commit is contained in:
parent
08c640cd58
commit
0f138abedd
10
src/cvm.c
10
src/cvm.c
@ -465,7 +465,7 @@ bool cosmoV_execute(CState *state) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OP_NOT: {
|
case OP_NOT: {
|
||||||
cosmoV_pushValue(state, cosmoV_newBoolean(isFalsey(cosmoV_pop(state))));
|
cosmoV_pushBoolean(state, isFalsey(cosmoV_pop(state)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OP_NEGATE: { // pop 1 value off the stack & try to negate
|
case OP_NEGATE: { // pop 1 value off the stack & try to negate
|
||||||
@ -473,7 +473,7 @@ bool cosmoV_execute(CState *state) {
|
|||||||
|
|
||||||
if (val->type == COSMO_TNUMBER) {
|
if (val->type == COSMO_TNUMBER) {
|
||||||
cosmoV_pop(state);
|
cosmoV_pop(state);
|
||||||
cosmoV_pushValue(state, cosmoV_newNumber(-(val->val.num)));
|
cosmoV_pushNumber(state, -(val->val.num));
|
||||||
} else {
|
} else {
|
||||||
cosmoV_error(state, "Expected number, got %s!", cosmoV_typeStr(*val));
|
cosmoV_error(state, "Expected number, got %s!", cosmoV_typeStr(*val));
|
||||||
}
|
}
|
||||||
@ -591,7 +591,7 @@ bool cosmoV_execute(CState *state) {
|
|||||||
StkPtr valA = cosmoV_pop(state);
|
StkPtr valA = cosmoV_pop(state);
|
||||||
|
|
||||||
// compare & push
|
// compare & push
|
||||||
cosmoV_pushValue(state, cosmoV_newBoolean(cosmoV_equal(*valA, *valB)));
|
cosmoV_pushBoolean(state, cosmoV_equal(*valA, *valB));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OP_GREATER: {
|
case OP_GREATER: {
|
||||||
@ -610,8 +610,8 @@ bool cosmoV_execute(CState *state) {
|
|||||||
BINARYOP(cosmoV_newBoolean, <=)
|
BINARYOP(cosmoV_newBoolean, <=)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OP_TRUE: cosmoV_pushValue(state, cosmoV_newBoolean(true)); break;
|
case OP_TRUE: cosmoV_pushBoolean(state, true); break;
|
||||||
case OP_FALSE: cosmoV_pushValue(state, cosmoV_newBoolean(false)); break;
|
case OP_FALSE: cosmoV_pushBoolean(state, false); break;
|
||||||
case OP_NIL: cosmoV_pushValue(state, cosmoV_newNil()); break;
|
case OP_NIL: cosmoV_pushValue(state, cosmoV_newNil()); break;
|
||||||
case OP_RETURN: {
|
case OP_RETURN: {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user