![]() | Fun 0.41.5 The programming language that makes You have fun |
Implements the OP_SUBSTR opcode for extracting substrings in the VM. More...
Go to the source code of this file.
Functions | |
| if (str.type !=VAL_STRING||startv.type !=VAL_INT||lenv.type !=VAL_INT) | |
| free_value (str) | |
| free_value (startv) | |
| free_value (lenv) | |
| push_value (vm, out) | |
Variables | |
| case | OP_SUBSTR |
| Value | startv = pop_value(vm) |
| Value | str = pop_value(vm) |
| Value | out = bi_substr(&str, (int)startv.i, (int)lenv.i) |
| break | |
Implements the OP_SUBSTR opcode for extracting substrings in the VM.
This file handles the OP_SUBSTR instruction, which extracts a substring from a string using a start index and length. The length, start index, and string are popped from the stack, and the resulting substring is pushed back.
Behavior:
Error Handling:
Example: // Bytecode: OP_SUBSTR // Stack before: [5, 6, "hello world"] // Stack after: ["world"]
Definition in file substr.c.
| free_value | ( | lenv | ) |
| free_value | ( | startv | ) |
| free_value | ( | str | ) |
| if | ( | str.type ! | = VAL_STRING || startv.type != VAL_INT || lenv.type != VAL_INT | ) |
| push_value | ( | vm | , |
| out | ) |