Fun
0.41.5
The programming language that makes You have fun
Main Page
Data Structures
Files
File List
Globals
Loading...
Searching...
No Matches
src
vm
typeof.c
Go to the documentation of this file.
1
/*
2
* This file is part of the Fun programming language.
3
* https://fun-lang.xyz/
4
*
5
* Copyright 2025 Johannes Findeisen <you@hanez.org>
6
* Licensed under the terms of the Apache-2.0 license.
7
* https://opensource.org/license/apache-2-0
8
*/
9
23
24
case
OP_TYPEOF
: {
25
Value
v
= pop_value(vm);
26
const
char
*
tname
=
"Unknown"
;
27
switch
(
v
.type) {
28
case
VAL_INT
:
29
tname
=
"Number"
;
30
break
;
31
case
VAL_FLOAT
:
32
tname
=
"Float"
;
33
break
;
34
case
VAL_BOOL
:
35
tname
=
"Boolean"
;
36
break
;
37
case
VAL_STRING
:
38
tname
=
"String"
;
39
break
;
40
case
VAL_FUNCTION
:
41
tname
=
"Function"
;
42
break
;
43
case
VAL_ARRAY
:
44
tname
=
"Array"
;
45
break
;
46
case
VAL_MAP
:
47
tname
=
"Map"
;
48
break
;
49
case
VAL_NIL
:
50
tname
=
"Nil"
;
51
break
;
52
default
:
53
tname
=
"Unknown"
;
54
break
;
55
}
56
/* push a new string value; make_string duplicates the C string */
57
push_value
(vm,
make_string
(
tname
));
58
free_value
(
v
);
59
break
;
60
}
OP_TYPEOF
@ OP_TYPEOF
Definition
bytecode.h:96
v
Value v
Definition
cast.c:22
Value
Tagged union representing a Fun value.
Definition
value.h:68
push_value
push_value(vm, make_string(tname))
tname
const char * tname
Definition
typeof.c:26
free_value
free_value(v)
make_string
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
Definition
value.c:95
VAL_BOOL
@ VAL_BOOL
Definition
value.h:52
VAL_ARRAY
@ VAL_ARRAY
Definition
value.h:55
VAL_MAP
@ VAL_MAP
Definition
value.h:56
VAL_STRING
@ VAL_STRING
Definition
value.h:53
VAL_FUNCTION
@ VAL_FUNCTION
Definition
value.h:54
VAL_NIL
@ VAL_NIL
Definition
value.h:57
VAL_INT
@ VAL_INT
Definition
value.h:51
VAL_FLOAT
@ VAL_FLOAT
Definition
value.h:58
Generated on
for Fun by
1.16.1