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
os
sleep_ms.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
22
23
case
OP_SLEEP_MS
: {
24
Value
ms
= pop_value(vm);
25
if
(
ms
.type !=
VAL_INT
) {
26
fprintf
(stderr,
"Runtime type error: sleep(ms) expects Number (milliseconds)\n"
);
27
free_value
(
ms
);
28
/* push Nil so caller-side POP is safe */
29
push_value(vm,
make_nil
());
30
break
;
31
}
32
long
t
= (long)
ms
.i;
33
if
(
t
> 0) fun_sleep_ms(
t
);
34
free_value
(
ms
);
35
/* push Nil so statement POP does not underflow */
36
push_value(vm,
make_nil
());
37
break
;
38
}
OP_SLEEP_MS
@ OP_SLEEP_MS
Definition
bytecode.h:153
ms
ms
Definition
clock_mono_ms.c:33
t
long t
Definition
sleep_ms.c:32
Value
Tagged union representing a Fun value.
Definition
value.h:68
make_nil
Value make_nil(void)
Construct a nil Value.
Definition
value.c:126
free_value
void free_value(Value v)
Free dynamic storage owned by a Value.
Definition
value.c:517
VAL_INT
@ VAL_INT
Definition
value.h:51
fprintf
#define fprintf
Definition
vm.c:200
Generated on
for Fun by
1.16.1