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

Implements the OP_LOAD_LOCAL opcode for loading local variables 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 (slot< 0||slot >=MAX_FRAME_LOCALS)
 push_value (vm, val)

Variables

case OP_LOAD_LOCAL
Value val = copy_value(&f->locals[slot])
 break

Detailed Description

Implements the OP_LOAD_LOCAL opcode for loading local variables in the VM.

This file handles the OP_LOAD_LOCAL instruction, which loads a local variable onto the stack using its index.

Behavior:

  • Loads the local variable at the specified index.
  • Pushes the value onto the stack.

Error Handling:

  • Exits with an error if the index is out of bounds.

Example: // Bytecode: OP_LOAD_LOCAL 0 // Stack before: [] // Stack after: [local_value]

Definition in file load_local.c.

Function Documentation

◆ if()

if(slot< 0||slot > = MAX_FRAME_LOCALS)

Definition at line 32 of file load_local.c.

◆ push_value()

push_value(vm,
val )

Variable Documentation

◆ break

break

Definition at line 38 of file load_local.c.

◆ OP_LOAD_LOCAL

case OP_LOAD_LOCAL

Definition at line 30 of file load_local.c.

◆ val

Value val = copy_value(&f->locals[slot])

Definition at line 36 of file load_local.c.