Files
my-os-project2/user/tb/runtime.c
2025-09-14 23:31:14 +02:00

35 lines
597 B
C

#include <stddef.h>
#include <stdbool.h>
#include <linklist.h>
#include <dlmalloc/malloc.h>
#include <uprintf.h>
#include "runtime.h"
#include "interp.h"
RtCmd *RTCMDS = NULL;
#define RTCMD(name) \
do { \
RtCmd *_cmd = dlmalloc(sizeof(*_cmd)); \
_cmd->cmdname = #name; \
_cmd->fn = rt_##name; \
LL_APPEND(RTCMDS, _cmd); \
} while(0)
bool rt_print(Token *tks) {
Token *tk = tks;
while (tk) {
uprintf("%.*s", (int)tk->len, tk->ptr);
if (tk->next != NULL) {
uprintf(" ");
}
tk = tk->next;
}
return true;
}
void rt_init(void) {
RTCMD(print);
}