1
0
Fork 0
forked from fun/fun
This commit is contained in:
Johannes Findeisen 2025-09-15 08:39:41 +02:00
commit 0e7fffcfe0
67 changed files with 154 additions and 65 deletions

19
src/vm_case_neq.c Normal file
View file

@ -0,0 +1,19 @@
case OP_NEQ: {
Value b = pop_value(vm);
Value a = pop_value(vm);
int neq = 1;
if (a.type == b.type) {
switch (a.type) {
case VAL_INT: neq = (a.i != b.i); break;
case VAL_STRING: neq = (a.s && b.s) ? (strcmp(a.s, b.s) != 0) : (a.s != b.s); break;
case VAL_FUNCTION: neq = (a.fn != b.fn); break;
case VAL_NIL: neq = 0; break;
default: neq = 1; break;
}
} else {
neq = 1;
}
push_value(vm, make_int(neq ? 1 : 0));
free_value(a); free_value(b);
break;
}