![]() | Fun 0.41.5 The programming language that makes You have fun |
Implements the OP_FIND opcode for finding substrings in the VM. More...
Go to the source code of this file.
Functions | |
| if (hay.type !=VAL_STRING||needle.type !=VAL_STRING) | |
| free_value (hay) | |
| free_value (needle) | |
| push_value (vm, make_int(idx)) | |
Variables | |
| case | OP_FIND |
| Value | hay = pop_value(vm) |
| int | idx = bi_find(&hay, &needle) |
| break | |
Implements the OP_FIND opcode for finding substrings in the VM.
This file handles the OP_FIND instruction, which finds the index of a substring within a string. The substring and string are popped from the stack, and the index (or -1) is pushed back.
Behavior:
Error Handling:
Example: // Bytecode: OP_FIND // Stack before: ["world", "hello world"] // Stack after: [6]
Definition in file find.c.
| free_value | ( | hay | ) |
| free_value | ( | needle | ) |
| if | ( | hay.type ! | = VAL_STRING || needle.type != VAL_STRING | ) |