Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
bayerf42 committed May 31, 2023
1 parent 40bdf64 commit 672c5db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ static int argumentList(bool* isVarArg, TokenType terminator) {
if (*isVarArg)
emitByte(OP_SWAP); // bubble list arguments count to TOS
if (argCount == UINT8_MAX)
error("Can't have more than 255 items in an argument list.");
error("Too many arguments.");
argCount++;
}
} while (match(TOKEN_COMMA));
Expand Down
12 changes: 8 additions & 4 deletions native.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,14 +693,15 @@ static bool clockNative(int argCount, Value* args) {
////////////////////////////////////////////////////////////////////////////////////////////////////

static void defineNative(const char* name, const char* signature, NativeFn function) {
push(OBJ_VAL(copyString(name, strlen(name))));
push(OBJ_VAL(newNative(signature, function)));
vm.stack[0] = OBJ_VAL(copyString(name, strlen(name)));
vm.stack[1] = OBJ_VAL(newNative(signature, function));
tableSet(&vm.globals, vm.stack[0], vm.stack[1]);
drop();
drop();
}

void defineAllNatives(void) {
push(NIL_VAL);
push(NIL_VAL);

defineNative("abs", "R", absNative);
defineNative("trunc", "R", truncNative);
defineNative("sqrt", "R", sqrtNative);
Expand Down Expand Up @@ -778,6 +779,9 @@ void defineAllNatives(void) {
defineNative("dbg_trace", "B", dbgTraceNative);
defineNative("dbg_gc", "N", dbgGcNative);
defineNative("dbg_stat", "B", dbgStatNative);

drop();
drop();
}

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 672c5db

Please sign in to comment.