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
math
exp.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 2026 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
28
29
#include <math.h>
30
31
case
OP_EXP
: {
32
Value
v
= pop_value(vm);
33
if
(
v
.type ==
VAL_INT
||
v
.type ==
VAL_FLOAT
) {
34
double
x
= (
v
.type ==
VAL_FLOAT
) ?
v
.d : (double)
v
.i;
35
double
r
=
exp
(
x
);
36
push_value(vm,
make_float
(
r
));
37
free_value
(
v
);
38
}
else
{
39
fprintf
(stderr,
"Runtime type error: EXP expects number, got %s\n"
, value_type_name(
v
.type));
40
exit
(1);
41
}
42
break
;
43
}
r
uint32_t r
Definition
band.c:33
OP_EXP
@ OP_EXP
Definition
bytecode.h:262
v
Value v
Definition
cast.c:22
x
Value x
Definition
clamp.c:32
exp
int64_t exp
Definition
pow.c:39
Value
Tagged union representing a Fun value.
Definition
value.h:68
free_value
void free_value(Value v)
Free dynamic storage owned by a Value.
Definition
value.c:517
make_float
Value make_float(double v)
Construct a Value representing a double-precision float.
Definition
value.c:64
VAL_INT
@ VAL_INT
Definition
value.h:51
VAL_FLOAT
@ VAL_FLOAT
Definition
value.h:58
fprintf
#define fprintf
Definition
vm.c:200
exit
#define exit(code)
Definition
vm.c:230
Generated on
for Fun by
1.16.1