Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
values.c File Reference

Implements the OP_VALUES opcode for retrieving map values in the VM. More...

Go to the source code of this file.

Functions

 if (m.type !=VAL_MAP)
 free_value (m)
 push_value (vm, arr)

Variables

case OP_VALUES
Value arr = map_values_array(&m)
 break

Detailed Description

Implements the OP_VALUES opcode for retrieving map values in the VM.

This file handles the OP_VALUES instruction, which retrieves the values of a map and pushes them as an array onto the stack.

Behavior:

  • Pops the map from the stack.
  • Retrieves the values of the map.
  • Pushes the values as an array onto the stack.

Error Handling:

  • Exits with an error if the map is of the wrong type.

Example: // Bytecode: OP_VALUES // Stack before: [{"a": 1, "b": 2}] // Stack after: [[1, 2]]

Definition in file values.c.

Function Documentation

◆ free_value()

free_value(m)

◆ if()

if(m.type ! = VAL_MAP)

Definition at line 33 of file values.c.

◆ push_value()

push_value(vm,
arr )

Variable Documentation

◆ arr

Definition at line 37 of file values.c.

◆ break

break

Definition at line 40 of file values.c.

◆ OP_VALUES

case OP_VALUES

Definition at line 31 of file values.c.