From efca612a20b82987179570e761aaea9e07988c3f Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Wed, 3 Jan 2024 14:34:17 +0900 Subject: [PATCH] Support Ellipsis in tools/compile.c --- tools/compile.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/compile.c b/tools/compile.c index 15b56a1c..b4d920c1 100644 --- a/tools/compile.c +++ b/tools/compile.c @@ -55,6 +55,7 @@ NativeFn ListIndex; KrkValue SeenFunctions; KrkValue UnseenFunctions; KrkValue StringTable; +KrkValue Ellipsis; static void _initListFunctions(void) { KrkValue _list_pop; @@ -69,6 +70,8 @@ static void _initListFunctions(void) { ListAppend = AS_NATIVE(_list_append)->function; ListContains = AS_NATIVE(_list_contains)->function; ListIndex = AS_NATIVE(_list_index)->function; + + krk_tableGet_fast(&vm.builtins->fields, S("Ellipsis"), &Ellipsis); } static void findInterpreter(char * argv[]) { @@ -315,6 +318,10 @@ static int doSecondPass(FILE * out) { WRITE_FUNCTION(AS_codeobject(*val)); break; default: + if (*val == Ellipsis) { + fwrite("e",1,1,out); + break; + } fprintf(stderr, "Invalid object found in constants table," "this marashal format can not store '%s'\n", @@ -439,6 +446,9 @@ static KrkValue valueFromConstant(int i, FILE * inFile) { case 'k': { return KWARGS_VAL(0); } + case 'e': { + return Ellipsis; + } default: { fprintf(stderr, "Unknown type '%c'.\n", c); return NONE_VAL();