Skip to content

Commit

Permalink
Support Ellipsis in tools/compile.c
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Jan 3, 2024
1 parent ae6ec7f commit efca612
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ NativeFn ListIndex;
KrkValue SeenFunctions;
KrkValue UnseenFunctions;
KrkValue StringTable;
KrkValue Ellipsis;

static void _initListFunctions(void) {
KrkValue _list_pop;
Expand All @@ -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[]) {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit efca612

Please sign in to comment.