🐛 fix line numbers.
parent
076fd79ff1
commit
bd84f3bb3d
10
lib/mod.c
10
lib/mod.c
|
@ -98,16 +98,6 @@ size_t mod_push_new_value(mod_t* mod, value_t* value)
|
|||
assert(mod);
|
||||
assert(value);
|
||||
|
||||
for (size_t i=0; i<mod->values.size; i++)
|
||||
{
|
||||
if (value_eq(value, mod->values.data[i]))
|
||||
{
|
||||
value_free(value);
|
||||
free(value);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
if (mod->values.size == 0)
|
||||
{
|
||||
mod->values.cap = 2;
|
||||
|
|
26
lib/vm.c
26
lib/vm.c
|
@ -142,31 +142,7 @@ int vm_exec_instr(vm_t* vm, mod_t* mod, Opcode op, param_t param)
|
|||
value_t* lhs = mod->values.data[r];
|
||||
|
||||
int same_type = lhs->type->kind == rhs->type->kind;
|
||||
int type = lhs->type->kind;
|
||||
|
||||
int eq = 0;
|
||||
|
||||
if (same_type)
|
||||
{
|
||||
if (type == TYPE_NUM)
|
||||
{
|
||||
eq = lhs->value.num == rhs->value.num;
|
||||
}
|
||||
else if (type == TYPE_BOOL)
|
||||
{
|
||||
eq = lhs->value.bool == rhs->value.bool;
|
||||
}
|
||||
else if (type == TYPE_STR)
|
||||
{
|
||||
eq = strcmp(lhs->value.str, rhs->value.str) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Cannot test equality on unknown type '%s'.\n",
|
||||
TypeKindStr[type]);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
int eq = value_eq(lhs, rhs);
|
||||
|
||||
value_t* res = tysy_new_bool(vm->tysy,
|
||||
(op == OP_EQ
|
||||
|
|
Loading…
Reference in New Issue