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

Implements the OP_TO_NUMBER opcode for converting values to integers in the VM. More...

Go to the source code of this file.

Functions

 if (v.type==VAL_INT)
 push_value (vm, make_int(0))

Variables

case OP_TO_NUMBER
 else
 break

Detailed Description

Implements the OP_TO_NUMBER opcode for converting values to integers in the VM.

This file handles the OP_TO_NUMBER instruction, which converts a value to an integer. The value is popped from the stack, and the result is pushed back.

Behavior:

  • Pops the value from the stack.
  • Converts the value to an integer.
  • Pushes the result onto the stack.

Error Handling:

  • Exits with an error if the conversion fails.

Example: // Bytecode: OP_TO_NUMBER // Stack before: ["42"] // Stack after: [42]

Author
Johannes Findeisen
Date
2025-10-16

Definition in file to_number.c.

Function Documentation

◆ if()

if(v.type = VAL_INT)

Definition at line 36 of file to_number.c.

Here is the call graph for this function:

◆ push_value()

push_value(vm,
make_int(0) )
Here is the caller graph for this function:

Variable Documentation

◆ break

break

Definition at line 94 of file to_number.c.

◆ else

else
Initial value:
{
Value v
Definition cast.c:22
void free_value(Value v)
Free dynamic storage owned by a Value.
Definition value.c:517

Definition at line 90 of file to_number.c.

◆ OP_TO_NUMBER

case OP_TO_NUMBER

Definition at line 34 of file to_number.c.