From 1b170522cb87d0714a875dd91320bd14001a2775 Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Tue, 5 Jan 2021 14:19:53 +0900 Subject: [PATCH] Add 'v' to C implementation --- others/planck.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/others/planck.c b/others/planck.c index 4931702..d5e9c8a 100644 --- a/others/planck.c +++ b/others/planck.c @@ -56,12 +56,18 @@ static cfa find(char c) { return 0; } +static int saved_argc = 0; +static char **saved_argv = 0; + #define defcode(name, label) \ static void label() #include "planck.c" #undef defcode -int main(void) { +int main(int argc, char *argv[]) { + saved_argc = argc; + saved_argv = argv; + #define defcode(c, label) \ memcpy(here, &(builtin){ latest, 1, c, {0}, label }, 3*CELL); \ latest = (builtin*)here; \ @@ -112,6 +118,7 @@ defcode('k', key) { defcode('t', type) { putchar(pop()); next(); } defcode('x', exec) { (*(ip = (cfa) pop()))(); } 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) \ defcode(c, label) { \ ty b = (ty) pop(); \