Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
echo.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
23
24/* Implements OP_ECHO: print top-of-stack value without trailing newline. */
25
26case OP_ECHO: {
27 Value v = pop_value(vm);
30 if (vm->output_count < OUTPUT_SIZE) {
31 int idx = vm->output_count;
32 vm->output[idx] = snap;
33 vm->output_is_partial[idx] = 1; // ECHO does not end the line
34 vm->output_count++;
35 } else {
37 fprintf(stderr, "Runtime error: output buffer overflow\n");
38 exit(1);
39 }
40 break;
41}
@ OP_ECHO
Definition bytecode.h:64
Value v
Definition cast.c:22
Value snap
Definition echo.c:28
free_value(v)
int idx
Definition index_of.c:38
Tagged union representing a Fun value.
Definition value.h:68
Value deep_copy_value(const Value *v)
Deep copy a Value, recursively copying arrays and maps.
Definition value.c:463
#define fprintf
Definition vm.c:200
#define exit(code)
Definition vm.c:230
#define OUTPUT_SIZE
Definition vm.h:38