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...

This graph shows which files directly or indirectly include this file:

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: []

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 31 of file print.c.

Variable Documentation

◆ break

break

Definition at line 41 of file print.c.

◆ else

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

Definition at line 36 of file print.c.

◆ OP_PRINT

case OP_PRINT

Definition at line 27 of file print.c.

◆ snap

Definition at line 29 of file print.c.