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

VM opcode snippet for parsing a JSON string into a Fun Value. More...

Go to the source code of this file.

Functions

 free_value (drop)
 push_value (vm, make_nil())

Variables

case OP_JSON_PARSE
 break

Detailed Description

VM opcode snippet for parsing a JSON string into a Fun Value.

Implements the OP_JSON_PARSE instruction. Expects a string (or any value convertible to string) on the stack, parses it with json-c, converts the resulting json_object to a Fun Value and pushes it.

Build gating: compiled only when FUN_WITH_JSON is enabled. Otherwise the opcode consumes its argument and pushes Nil.

Stack effect (with FUN_WITH_JSON):

  • Pops: text (any; converted to string)
  • Pushes: Value converted from JSON, or Nil on error

Errors and edge cases:

  • If allocation fails, tokenization fails, or the text is not valid JSON, the opcode pushes Nil.
  • The temporary json-c objects are released after conversion; ownership of the pushed Fun Value follows normal VM semantics.

Definition in file parse.c.

Function Documentation

◆ free_value()

free_value(drop)

◆ push_value()

push_value(vm,
make_nil() )

Variable Documentation

◆ break

break

Definition at line 60 of file parse.c.

◆ OP_JSON_PARSE

case OP_JSON_PARSE

Definition at line 33 of file parse.c.