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...

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

Go to the source code of this file.

Functions

 free_value (vmsg)
 if (msg)
 push_value (vm, make_nil())

Variables

case OP_RUST_HELLO_ARGS
char * msg = value_to_string_alloc(&vmsg)
 else
 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. 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 in file hello_args.c.

Function Documentation

◆ free_value()

free_value ( vmsg )

◆ if()

if ( msg )

Definition at line 37 of file hello_args.c.

◆ push_value()

push_value ( vm ,
make_nil()  )

Variable Documentation

◆ break

break

Definition at line 51 of file hello_args.c.

◆ else

else
Initial value:
{
int fun_rust_print_string(const char *msg)

Definition at line 40 of file hello_args.c.

◆ msg

char* msg = value_to_string_alloc(&vmsg)

Definition at line 35 of file hello_args.c.

◆ OP_RUST_HELLO_ARGS

case OP_RUST_HELLO_ARGS

Definition at line 32 of file hello_args.c.