Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
hello_args_return.c
Go to the documentation of this file.
1/*
2 * This file is part of the Fun programming language.
3 * https://fun-lang.xyz/
4 *
5 * Copyright 2026 Johannes Findeisen <you@hanez.org>
6 * Licensed under the terms of the Apache-2.0 license.
7 * https://opensource.org/license/apache-2-0
8 */
9
19
37#ifdef FUN_WITH_RUST
38 Value vmsg = pop_value(vm);
39 char *msg = value_to_string_alloc(&vmsg);
40 free_value(vmsg);
41 if (msg) {
42 char *ret = fun_rust_echo_string(msg);
43 free(msg);
44 if (ret) {
45 push_value(vm, make_string(ret));
47 } else {
48 push_value(vm, make_nil());
49 }
50 } else {
51 char *ret = fun_rust_echo_string("");
52 if (ret) {
53 push_value(vm, make_string(ret));
55 } else {
56 push_value(vm, make_nil());
57 }
58 }
59#else
60 /* Still pop and free the arg to keep stack sane */
61 Value vmsg = pop_value(vm);
62 free_value(vmsg);
63 vm_raise_error(vm, "RUST_HELLO_ARGS_RETURN requires FUN_WITH_RUST=ON at build time");
65#endif
66 break;
67}
@ OP_RUST_HELLO_ARGS_RETURN
Definition bytecode.h:280
vm_raise_error(vm, "RUST_HELLO_ARGS_RETURN requires FUN_WITH_RUST=ON at build time")
push_value(vm, make_nil())
free_value(vmsg)
free(vals)
Tagged union representing a Fun value.
Definition value.h:68
Value make_nil(void)
Construct a nil Value.
Definition value.c:126
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
Definition value.c:95
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
Definition value.c:641
void fun_rust_string_free(char *ptr)
char * fun_rust_echo_string(const char *input)