Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
from_file.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 2025 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
33
34/* JSON_FROM_FILE */
36#ifdef FUN_WITH_JSON
37 Value vpath = pop_value(vm);
40 if (!path) {
41 push_value(vm, make_nil());
42 break;
43 }
44 json_object *root = json_object_from_file(path);
45 free(path);
46 if (!root) {
47 push_value(vm, make_nil());
48 break;
49 }
50 Value v = json_to_fun(root);
51 push_value(vm, v);
52 json_object_put(root);
53#else
54 Value vpath = pop_value(vm);
57#endif
58 break;
59}
@ OP_JSON_FROM_FILE
Definition bytecode.h:169
Value v
Definition cast.c:22
free_value(vpath)
push_value(vm, make_nil())
free(vals)
Tagged union representing a Fun value.
Definition value.h:68
void vpath
Definition stubs.c:23
Value make_nil(void)
Construct a nil Value.
Definition value.c:126
char * value_to_string_alloc(const Value *v)
Allocate a printable C string for a Value.
Definition value.c:641
Value path
Definition write_file.c:33