TB print hello world

This commit is contained in:
2025-09-14 23:31:14 +02:00
parent 062e98d714
commit 40ccb7d476
6 changed files with 322 additions and 0 deletions

34
user/tb/runtime.c Normal file
View File

@ -0,0 +1,34 @@
#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);
}