![]() | Fun 0.41.5 The programming language that makes You have fun |
Implements the OP_LEN opcode for getting the length of arrays or strings in the VM. More...
Go to the source code of this file.
Functions | |
| if (a.type==VAL_STRING) | |
| free_value (a) | |
| push_value (vm, make_int(len)) | |
Variables | |
| case | OP_LEN |
| int | len = 0 |
| else | |
| break | |
Implements the OP_LEN opcode for getting the length of arrays or strings in the VM.
This file handles the OP_LEN instruction, which retrieves the length of an array or string. The array or string is popped from the stack, and the length is pushed back.
Behavior:
Error Handling:
Example: // Bytecode: OP_LEN // Stack before: ["hello"] // Stack after: [5]
Definition in file len.c.
| free_value | ( | a | ) |
| if | ( | a. | type = = VAL_STRING | ) |
| else |