ufff
This commit is contained in:
parent
c8b8dd820e
commit
0e7fffcfe0
67 changed files with 154 additions and 65 deletions
13
src/vm_case_index_of.c
Normal file
13
src/vm_case_index_of.c
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
case OP_INDEX_OF: {
|
||||
Value needle = pop_value(vm);
|
||||
Value arr = pop_value(vm);
|
||||
if (arr.type != VAL_ARRAY) {
|
||||
fprintf(stderr, "Runtime type error: INDEX_OF expects (array, value)\n");
|
||||
exit(1);
|
||||
}
|
||||
int idx = array_index_of(&arr, &needle);
|
||||
free_value(arr);
|
||||
free_value(needle);
|
||||
push_value(vm, make_int(idx));
|
||||
break;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue