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

Implements the OP_LOAD_GLOBAL opcode for loading global 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 (idx< 0||idx >=MAX_GLOBALS)
 push_value (vm, copy_value(&vm->globals[idx]))

Variables

case OP_LOAD_GLOBAL
 break

Detailed Description

Implements the OP_LOAD_GLOBAL opcode for loading global variables in the VM.

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

Behavior:

  • Loads the global 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_GLOBAL 0 // Stack before: [] // Stack after: [global_value]

Definition in file load_global.c.

Function Documentation

◆ if()

if(idx< 0||idx > = MAX_GLOBALS)

Definition at line 32 of file load_global.c.

◆ push_value()

push_value(vm,
copy_value &->[]idx )

Variable Documentation

◆ break

break

Definition at line 40 of file load_global.c.

◆ OP_LOAD_GLOBAL

case OP_LOAD_GLOBAL

Definition at line 30 of file load_global.c.