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

Implements the OP_HAS_KEY opcode for map key checking in the VM. More...

Go to the source code of this file.

Functions

 if (m.type !=VAL_MAP||key.type !=VAL_STRING)
 free_value (m)
 free_value (key)
 push_value (vm, make_int(ok ? 1 :0))

Variables

case OP_HAS_KEY
Value m = pop_value(vm)
int ok = map_has(&m, key.s ? key.s : "")
 break

Detailed Description

Implements the OP_HAS_KEY opcode for map key checking in the VM.

This file handles the OP_HAS_KEY instruction, which checks if a map contains a specific key.

Behavior:

  • Pops key and map from stack
  • Pushes 1 if key exists, 0 otherwise

Error Handling:

  • Exits if arguments wrong types

Definition in file has_key.c.

Function Documentation

◆ free_value() [1/2]

free_value(key)

◆ free_value() [2/2]

free_value(m)

◆ if()

if(m.type ! = VAL_MAP || key.type != VAL_STRING)

Definition at line 28 of file has_key.c.

◆ push_value()

push_value(vm,
make_int(ok ? 1 :0) )

Variable Documentation

◆ break

break

Definition at line 36 of file has_key.c.

◆ m

void map_set & m = pop_value(vm)

Definition at line 27 of file has_key.c.

◆ ok

int ok = map_has(&m, key.s ? key.s : "")

Definition at line 32 of file has_key.c.

◆ OP_HAS_KEY

case OP_HAS_KEY

Definition at line 25 of file has_key.c.