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

Implements the OP_AND opcode for logical AND 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_AND
Value a = pop_value(vm)
int res = value_is_truthy(&a) && value_is_truthy(&b)
 break

Detailed Description

Implements the OP_AND opcode for logical AND in the VM.

This file handles the OP_AND instruction, which performs a logical AND 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 AND 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_AND
  • Stack before: [1, 0]
  • Stack after: [0]

Definition in file and.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 and.c.

◆ break

break

Definition at line 38 of file and.c.

◆ OP_AND

case OP_AND

Definition at line 31 of file and.c.

◆ res

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

Definition at line 34 of file and.c.