![]() | Fun 0.41.5 The programming language that makes You have fun |
Implements the OP_PUSH opcode for appending elements to arrays in the VM. More...

Go to the source code of this file.
Functions | |
| if (arr.type !=VAL_ARRAY) | |
| if (n< 0) | |
| free_value (arr) | |
| push_value (vm, make_int(n)) | |
Variables | |
| case | OP_PUSH |
| Value | arr = pop_value(vm) |
| int | n = array_push(&arr, v) |
| break | |
Implements the OP_PUSH opcode for appending elements to arrays in the VM.
Handles the OP_PUSH instruction, which appends a value to the end of an array. The array and value are popped from the stack; the opcode pushes the new array length (integer) as a result.
Behavior:
Error Handling:
Example: // Bytecode: OP_PUSH // Stack before: [42, [10, 20, 30]] // Stack after: [4]
Definition in file push.c.
| free_value | ( | arr | ) |
| int n = array_push(&arr, v) |