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

Implements the OP_SWAP opcode for stack manipulation in the VM. More...

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

Go to the source code of this file.

Functions

 exit (1)

Variables

case OP_SWAP
case Runtime error
Value a = vm->stack[vm->sp]
Value b = vm->stack[vm->sp - 1]
vm stack [vm->sp] = b
 break

Detailed Description

Implements the OP_SWAP opcode for stack manipulation in the VM.

This file handles the OP_SWAP instruction, which swaps the top two values on the stack.

Behavior:

  • Swaps stack[sp] and stack[sp-1]
  • No type checking

Error Handling:

  • Exits if stack underflow

Definition in file swap.c.

Function Documentation

◆ exit()

exit(1)

Variable Documentation

◆ a

Value a = vm->stack[vm->sp]

Definition at line 30 of file swap.c.

◆ b

Value b = vm->stack[vm->sp - 1]

Definition at line 31 of file swap.c.

◆ break

break

Definition at line 34 of file swap.c.

◆ error

case Runtime error

Definition at line 27 of file swap.c.

◆ OP_SWAP

case OP_SWAP

Definition at line 25 of file swap.c.

◆ stack

vm stack = b

Definition at line 32 of file swap.c.