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

Implements the OP_TYPEOF opcode for obtaining a human-readable type name. More...

Go to the source code of this file.

Functions

 switch (v.type)
 push_value (vm, make_string(tname))
 free_value (v)

Variables

case OP_TYPEOF
const char * tname = "Unknown"
 break

Detailed Description

Implements the OP_TYPEOF opcode for obtaining a human-readable type name.

This snippet is included by the VM's opcode dispatch. It pops a single value from the stack, determines its runtime type, pushes a new string with a human-readable type name (e.g., "Number", "String", "Array"), and frees the original value.

Stack contract:

  • Pops: value (any)
  • Pushes: string (type name)

Definition in file typeof.c.

Function Documentation

◆ free_value()

free_value(v)

◆ push_value()

push_value(vm,
make_string(tname) )

◆ switch()

switch(v.type)

Definition at line 27 of file typeof.c.

Variable Documentation

◆ break

break

Definition at line 59 of file typeof.c.

◆ OP_TYPEOF

case OP_TYPEOF

Definition at line 24 of file typeof.c.

◆ tname

const char* tname = "Unknown"

Definition at line 26 of file typeof.c.