TB print hello world
This commit is contained in:
34
user/tb/runtime.c
Normal file
34
user/tb/runtime.c
Normal 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);
|
||||
}
|
Reference in New Issue
Block a user