Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
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
24 Value ms = pop_value(vm);
25 if (ms.type != VAL_INT) {
26 fprintf(stderr, "Runtime type error: sleep(ms) expects Number (milliseconds)\n");
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);
35 /* push Nil so statement POP does not underflow */
36 push_value(vm, make_nil());
37 break;
38}
@ OP_SLEEP_MS
Definition bytecode.h:153
long t
Definition sleep_ms.c:32
Tagged union representing a Fun value.
Definition value.h:68
Value make_nil(void)
Construct a nil Value.
Definition value.c:126
void free_value(Value v)
Free dynamic storage owned by a Value.
Definition value.c:517
@ VAL_INT
Definition value.h:51
#define fprintf
Definition vm.c:200