cosmoV_register now uses the stack to pass params

This commit is contained in:
2020-12-19 21:15:12 -06:00
parent f6aaeb3417
commit de3a89ad4f
5 changed files with 23 additions and 53 deletions

View File

@@ -52,9 +52,13 @@ static void repl() {
cosmoB_loadLibrary(state);
cosmoB_loadDebug(state);
// TODO: there's gotta be a better way to do this
cosmoV_register(state, "quit", cosmoV_newObj(cosmoO_newCFunction(state, cosmoB_quitRepl)));
cosmoV_register(state, "input", cosmoV_newObj(cosmoO_newCFunction(state, cosmoB_input)));
cosmoV_pushString(state, "quit");
cosmoV_pushCFunction(state, cosmoB_quitRepl);
cosmoV_pushString(state, "input");
cosmoV_pushCFunction(state, cosmoB_input);
cosmoV_register(state, 2);
while (_ACTIVE) {
printf("> ");
@@ -107,8 +111,6 @@ static void runFile(const char* fileName) {
CState *state = cosmoV_newState();
cosmoB_loadLibrary(state);
cosmoV_register(state, "input", cosmoV_newObj(cosmoO_newCFunction(state, cosmoB_input)));
interpret(state, script, fileName);
cosmoV_freeState(state);