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

Implements the OP_GTE opcode for greater-than-or-equal comparison in the VM. More...

Go to the source code of this file.

Functions

 if (a.type !=VAL_INT||b.type !=VAL_INT)
 push_value (vm, make_int(a.i >=b.i ? 1 :0))
 free_value (a)
 free_value (b)

Variables

case OP_GTE
Value a = pop_value(vm)
 break

Detailed Description

Implements the OP_GTE opcode for greater-than-or-equal comparison in the VM.

This file handles the OP_GTE instruction, which checks if the first value is greater than or equal to the second. The values are popped from the stack, and the result (1 or 0) is pushed back.

Behavior:

  • Pops two values from the stack.
  • Checks if the first value is greater than or equal to the second.
  • Pushes 1 (true) or 0 (false) onto the stack.

Error Handling:

  • Exits with an error if the operands are of incompatible types.

Example: // Bytecode: OP_GTE // Stack before: [42, 42] // Stack after: [1]

Definition in file gte.c.

Function Documentation

◆ free_value() [1/2]

free_value(a)

◆ free_value() [2/2]

free_value(b)

◆ if()

if(a.type ! = VAL_INT || b.type != VAL_INT)

Definition at line 34 of file gte.c.

◆ push_value()

push_value(vm,
make_int(a.i >=b.i ? 1 :0) )

Variable Documentation

◆ a

Value a = pop_value(vm)

Definition at line 33 of file gte.c.

◆ break

break

Definition at line 41 of file gte.c.

◆ OP_GTE

case OP_GTE

Definition at line 31 of file gte.c.