Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
return.c File Reference

Implements the OP_RETURN opcode for returning from a function in the VM. More...

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

Go to the source code of this file.

Functions

 if (vm->sp >=0) retv
 vm_pop_frame (vm)
 push_value (vm, retv)

Variables

case OP_RETURN
else retv = make_nil()
 break

Detailed Description

Implements the OP_RETURN opcode for returning from a function in the VM.

This file handles the OP_RETURN instruction, which returns from the current function and optionally pushes a return value onto the stack.

Behavior:

  • Pops the optional return value from the stack.
  • Returns to the caller frame.
  • Pushes the return value onto the stack (if any).

Error Handling:

  • Exits with an error if the frame stack is empty.

Example:

  • Bytecode: OP_RETURN
  • Stack before: [42]
  • Stack after: [42]

Definition in file return.c.

Function Documentation

◆ if()

if ( vm->sp >= 0)

Definition at line 22 of file exit.c.

◆ push_value()

push_value ( vm ,
retv  )

◆ vm_pop_frame()

vm_pop_frame ( vm )

Variable Documentation

◆ break

break

Definition at line 39 of file return.c.

◆ OP_RETURN

case OP_RETURN

Definition at line 31 of file return.c.

◆ retv

else retv = make_nil()

Definition at line 36 of file return.c.