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

Implements the OP_ABS opcode for absolute value in the VM. More...

Go to the source code of this file.

Functions

 if (x.type !=VAL_INT)
 if (v< 0) v
 push_value (vm, make_int(v))
 free_value (x)

Variables

case OP_ABS
int64_t v = x.i
 break

Detailed Description

Implements the OP_ABS opcode for absolute value in the VM.

This file handles the OP_ABS instruction, which computes the absolute value of an integer.

Behavior:

  • Pops value from stack
  • Pushes |value|

Error Handling:

  • Exits if not integer
Author
Johannes Findeisen
Date
2025-10-16

Definition in file abs.c.

Function Documentation

◆ free_value()

free_value(x)

◆ if() [1/2]

if()

Definition at line 42 of file insert.c.

◆ if() [2/2]

if(x.type ! = VAL_INT)

Definition at line 30 of file abs.c.

◆ push_value()

push_value(vm,
make_int(v) )

Variable Documentation

◆ break

break

Definition at line 38 of file abs.c.

◆ OP_ABS

case OP_ABS

Definition at line 28 of file abs.c.

◆ v

int64_t v = x.i

Definition at line 34 of file abs.c.