Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
keys.c File Reference

Implements the OP_KEYS opcode for retrieving map keys in the VM. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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

Variables

case OP_KEYS
Value arr = map_keys_array(&m)
 break

Detailed Description

Implements the OP_KEYS opcode for retrieving map keys in the VM.

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

Behavior:

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

Error Handling:

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

Example:

  • Bytecode: OP_KEYS
  • Stack before: [{"a": 1, "b": 2}]
  • Stack after: [["a", "b"]]

Definition in file keys.c.

Function Documentation

◆ free_value()

free_value ( m )

◆ if()

if ( m.type ! = VAL_MAP)

Definition at line 33 of file keys.c.

◆ push_value()

push_value ( vm ,
arr  )

Variable Documentation

◆ arr

Definition at line 37 of file keys.c.

◆ break

break

Definition at line 40 of file keys.c.

◆ OP_KEYS

case OP_KEYS

Definition at line 31 of file keys.c.