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

Implements the OP_RUST_HELLO_ARGS opcode (conditional build). More...

Go to the source code of this file.

Functions

 free_value (vmsg)
 vm_raise_error (vm, "RUST_HELLO_ARGS requires FUN_WITH_RUST=ON at build time")
 push_value (vm, make_nil())

Variables

case OP_RUST_HELLO_ARGS
 break

Detailed Description

Implements the OP_RUST_HELLO_ARGS opcode (conditional build).

Demonstrates passing a VM value to Rust. Converts the top stack value to a string, calls into Rust to print/log it, and pushes Nil. When Rust support is disabled, the argument is still popped and freed to keep the stack sane, then Nil is pushed after raising an error message.

Definition in file hello_args.c.

Function Documentation

◆ free_value()

free_value(vmsg)

◆ push_value()

push_value(vm,
make_nil() )

◆ vm_raise_error()

vm_raise_error(vm)

Variable Documentation

◆ break

break

Definition at line 53 of file hello_args.c.

◆ OP_RUST_HELLO_ARGS

case OP_RUST_HELLO_ARGS

OP_RUST_HELLO_ARGS: (msg:any) -> Nil

Behavior (FUN_WITH_RUST=ON):

  • Pops one value from the stack and converts it to a newly allocated C string via value_to_string_alloc().
  • Calls fun_rust_print_string(msg) and then frees the allocated buffer.
  • Pushes Nil.

Behavior (FUN_WITH_RUST=OFF):

  • Pops and frees one value to preserve stack discipline.
  • Raises a runtime error indicating missing Rust support.
  • Pushes Nil.

Definition at line 34 of file hello_args.c.