![]() | Fun 0.41.5 The programming language that makes You have fun |
Implements the OP_CONTAINS opcode for checking array membership in the VM. More...

Go to the source code of this file.
Functions | |
| if (arr.type !=VAL_ARRAY) | |
| free_value (arr) | |
| free_value (needle) | |
| push_value (vm, make_int(ok ? 1 :0)) | |
Variables | |
| case | OP_CONTAINS |
| Value | arr = pop_value(vm) |
| int | ok = array_contains(&arr, &needle) |
| break | |
Implements the OP_CONTAINS opcode for checking array membership in the VM.
This file handles the OP_CONTAINS instruction, which checks if a value is present in an array. The value and array are popped from the stack, and a boolean result (1/0) is pushed back.
Behavior:
Error Handling:
Example: // Bytecode: OP_CONTAINS // Stack before: [20, [10, 20, 30]] // Stack after: [1]
Definition in file contains.c.
| free_value | ( | arr | ) |
| free_value | ( | needle | ) |
| if | ( | arr.type ! | = VAL_ARRAY | ) |
Definition at line 34 of file contains.c.
| Value arr = pop_value(vm) |
Definition at line 33 of file contains.c.
| break |
Definition at line 42 of file contains.c.
| int ok = array_contains(&arr, &needle) |
Definition at line 38 of file contains.c.
| case OP_CONTAINS |
Definition at line 31 of file contains.c.