Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
or.c File Reference

Implements the OP_OR opcode for logical OR in the VM. More...

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

Go to the source code of this file.

Functions

 free_value (a)
 free_value (b)
 push_value (vm, make_bool(res))

Variables

case OP_OR
Value a = pop_value(vm)
int res = value_is_truthy(&a) || value_is_truthy(&b)
 break

Detailed Description

Implements the OP_OR opcode for logical OR in the VM.

This file handles the OP_OR instruction, which performs a logical OR operation on two boolean values. The values are popped from the stack, and the result is pushed back.

Behavior:

  • Pops two boolean values from the stack.
  • Performs a logical OR operation.
  • Pushes the result (1 or 0) onto the stack.

Error Handling:

  • Exits with an error if the operands are not boolean values.

Example:

  • Bytecode: OP_OR
  • Stack before: [1, 0]
  • Stack after: [1]

Definition in file or.c.

Function Documentation

◆ free_value() [1/2]

free_value ( a )

◆ free_value() [2/2]

free_value ( b )

◆ push_value()

push_value ( vm ,
make_bool(res)  )

Variable Documentation

◆ a

Value a = pop_value(vm)

Definition at line 33 of file or.c.

◆ break

break

Definition at line 38 of file or.c.

◆ OP_OR

case OP_OR

Definition at line 31 of file or.c.

◆ res

int res = value_is_truthy(&a) || value_is_truthy(&b)

Definition at line 34 of file or.c.