Fun
0.41.5
The programming language that makes You have fun
Main Page
Data Structures
Files
File List
Globals
Loading...
Searching...
No Matches
src
vm
os
env.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
21
22
case
OP_ENV
: {
23
Value
key = pop_value(vm);
24
if
(key.
type
!=
VAL_STRING
) {
25
fprintf
(stderr,
"Runtime type error: ENV expects string name\n"
);
26
free_value
(key);
27
exit
(1);
28
}
29
const
char
*
name
= key.
s
? key.
s
:
""
;
30
const
char
*
val
= getenv(
name
);
31
/* Return empty string if not set (consistent with read_file fallback style) */
32
push_value
(vm,
make_string
(
val
?
val
:
""
));
33
free_value
(key);
34
break
;
35
}
OP_ENV
@ OP_ENV
Definition
bytecode.h:140
free_value
free_value(key)
push_value
push_value(vm, make_string(val ? val :""))
name
const char * name
Definition
env.c:29
val
Value val
Definition
load_local.c:36
Value
Tagged union representing a Fun value.
Definition
value.h:68
Value::type
ValueType type
Definition
value.h:69
Value::s
char * s
Definition
value.h:73
make_string
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
Definition
value.c:95
VAL_STRING
@ VAL_STRING
Definition
value.h:53
fprintf
#define fprintf
Definition
vm.c:200
exit
#define exit(code)
Definition
vm.c:230
Generated on
for Fun by
1.16.1