Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
print.c File Reference

Implements the OP_PRINT opcode for printing values in the VM. More...

Go to the source code of this file.

Functions

 free_value (v)
 if (vm->output_count< OUTPUT_SIZE)
 fprintf (stderr, "Runtime error: output buffer overflow\n")
 exit (1)

Variables

case OP_PRINT
Value snap = deep_copy_value(&v)
 else
 break

Detailed Description

Implements the OP_PRINT opcode for printing values in the VM.

This file handles the OP_PRINT instruction, which prints the top value on the stack to the output buffer. The value is popped from the stack.

Behavior:

  • Pops the value from the stack.
  • Prints the value to the output buffer.

Example: // Bytecode: OP_PRINT // Stack before: [42] // Stack after: []

Author
Johannes Findeisen
Date
2025-09-16

Definition in file print.c.

Function Documentation

◆ exit()

exit(1)

◆ fprintf()

fprintf(stderr,
"Runtime error: output buffer overflow\n" )

◆ free_value()

free_value(v)

◆ if()

if()

Definition at line 34 of file print.c.

Variable Documentation

◆ break

break

Definition at line 44 of file print.c.

◆ else

else
Initial value:
{
Value snap
Definition echo.c:28
void free_value(Value v)
Free dynamic storage owned by a Value.
Definition value.c:517

Definition at line 39 of file print.c.

◆ OP_PRINT

case OP_PRINT

Definition at line 30 of file print.c.

◆ snap

Definition at line 32 of file print.c.