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...

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

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]

Definition in file to_number.c.

Function Documentation

◆ if()

if ( v. type = VAL_INT)

Definition at line 33 of file to_number.c.

◆ push_value()

push_value ( vm ,
make_int(0)  )

Variable Documentation

◆ break

break

Definition at line 91 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 87 of file to_number.c.

◆ OP_TO_NUMBER

case OP_TO_NUMBER

Definition at line 31 of file to_number.c.