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

Implements the OP_STORE_LOCAL opcode for storing 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)
 free_value (f->locals[slot])

Variables

case OP_STORE_LOCAL
Value v = pop_value(vm)
f locals [slot] = v
 break

Detailed Description

Implements the OP_STORE_LOCAL opcode for storing local variables in the VM.

This file handles the OP_STORE_LOCAL instruction, which stores a value into a local variable using its index.

Behavior:

  • Pops the value from the stack.
  • Stores the value into the local variable at the specified index.

Error Handling:

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

Example: // Bytecode: OP_STORE_LOCAL 0 // Stack before: [42] // Stack after: []

Definition in file store_local.c.

Function Documentation

◆ free_value()

free_value(f->locals[slot])

◆ if()

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

Definition at line 32 of file store_local.c.

Variable Documentation

◆ break

break

Definition at line 40 of file store_local.c.

◆ locals

f locals[slot] = v

Definition at line 39 of file store_local.c.

◆ OP_STORE_LOCAL

case OP_STORE_LOCAL

Definition at line 30 of file store_local.c.

◆ v

Value v = pop_value(vm)

Definition at line 36 of file store_local.c.