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
print.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
29
30
case
OP_PRINT
: {
31
Value
v
= pop_value(vm);
32
Value
snap
=
deep_copy_value
(&
v
);
33
free_value
(
v
);
34
if
(vm->output_count <
OUTPUT_SIZE
) {
35
int
idx
= vm->output_count;
36
vm->output[
idx
] =
snap
;
37
vm->output_is_partial[
idx
] = 0;
// PRINT terminates the line
38
vm->output_count++;
39
}
else
{
40
free_value
(
snap
);
41
fprintf
(stderr,
"Runtime error: output buffer overflow\n"
);
42
exit
(1);
43
}
44
break
;
45
}
OP_PRINT
@ OP_PRINT
Definition
bytecode.h:63
v
Value v
Definition
cast.c:22
snap
Value snap
Definition
echo.c:28
idx
int idx
Definition
index_of.c:38
free_value
free_value(v)
Value
Tagged union representing a Fun value.
Definition
value.h:68
deep_copy_value
Value deep_copy_value(const Value *v)
Deep copy a Value, recursively copying arrays and maps.
Definition
value.c:463
fprintf
#define fprintf
Definition
vm.c:200
exit
#define exit(code)
Definition
vm.c:230
OUTPUT_SIZE
#define OUTPUT_SIZE
Definition
vm.h:38
Generated on
for Fun by
1.16.1