mirror of
https://github.com/nineties/planckforth
synced 2024-12-27 21:58:35 +01:00
Add 'v' to C implementation
This commit is contained in:
parent
e78f59de7f
commit
1b170522cb
1 changed files with 8 additions and 1 deletions
|
@ -56,12 +56,18 @@ static cfa find(char c) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int saved_argc = 0;
|
||||||
|
static char **saved_argv = 0;
|
||||||
|
|
||||||
#define defcode(name, label) \
|
#define defcode(name, label) \
|
||||||
static void label()
|
static void label()
|
||||||
#include "planck.c"
|
#include "planck.c"
|
||||||
#undef defcode
|
#undef defcode
|
||||||
|
|
||||||
int main(void) {
|
int main(int argc, char *argv[]) {
|
||||||
|
saved_argc = argc;
|
||||||
|
saved_argv = argv;
|
||||||
|
|
||||||
#define defcode(c, label) \
|
#define defcode(c, label) \
|
||||||
memcpy(here, &(builtin){ latest, 1, c, {0}, label }, 3*CELL); \
|
memcpy(here, &(builtin){ latest, 1, c, {0}, label }, 3*CELL); \
|
||||||
latest = (builtin*)here; \
|
latest = (builtin*)here; \
|
||||||
|
@ -112,6 +118,7 @@ defcode('k', key) {
|
||||||
defcode('t', type) { putchar(pop()); next(); }
|
defcode('t', type) { putchar(pop()); next(); }
|
||||||
defcode('x', exec) { (*(ip = (cfa) pop()))(); }
|
defcode('x', exec) { (*(ip = (cfa) pop()))(); }
|
||||||
defcode('f', find_) { push((cell) find(pop())); next(); }
|
defcode('f', find_) { push((cell) find(pop())); next(); }
|
||||||
|
defcode('v', argv_) { push((cell) saved_argv); push(saved_argc); next(); }
|
||||||
#define defbinary(c, label, op, ty) \
|
#define defbinary(c, label, op, ty) \
|
||||||
defcode(c, label) { \
|
defcode(c, label) { \
|
||||||
ty b = (ty) pop(); \
|
ty b = (ty) pop(); \
|
||||||
|
|
Loading…
Reference in a new issue