sandbox/kf.c

37 lines
559 B
C
Raw Normal View History

2018-03-03 01:03:32 +00:00
#include "defs.h"
#include "eval.h"
#include "stack.h"
#include "word.h"
#include <stdio.h>
#include <stdlib.h>
2018-03-03 01:03:32 +00:00
#include <string.h>
void
hello(void)
{
printf("hello, world\n");
}
int
main(void)
{
dstack_push(2);
dstack_push(3);
append_native_word("hello", 5, hello);
uintptr_t hwb = 0;
2018-03-03 01:03:32 +00:00
if (!lookup("hello", 5, &hwb)) {
fprintf(stderr, "failed to lookup 'hello'\n");
exit(1);
}
printf("hello: 0x%lx\n", (unsigned long)hwb);
if (!execute("hello", 5)) {
fprintf(stderr, "failed to execute 'hello'\n");
exit(1);
}
2018-03-03 01:03:32 +00:00
printf("finished\n");
}