Reorganize makefile and scripts.

This commit is contained in:
Bob Nystrom
2014-01-23 23:29:50 -08:00
parent a4162a2eb3
commit 96d728cc5d
12 changed files with 237 additions and 44 deletions
+8 -6
View File
@@ -9,9 +9,6 @@
// This is the source file for the standalone command line interpreter. It is
// not needed if you are embedding Wren in an application.
// TODO: Don't hardcode this.
#define MAX_LINE 1024
static void failIf(bool condition, int exitCode, const char* format, ...)
{
if (!condition) return;
@@ -66,8 +63,10 @@ static int runRepl(WrenVM* vm)
for (;;)
{
printf("> ");
char line[MAX_LINE];
fgets(line, MAX_LINE, stdin);
char* line = NULL;
size_t size = 0;
getline(&line, &size, stdin);
// If stdin was closed (usually meaning the used entered Ctrl-D), exit.
if (feof(stdin))
@@ -77,7 +76,10 @@ static int runRepl(WrenVM* vm)
}
// TODO: Handle failure.
wrenInterpret(vm, "(repl)", line);
wrenInterpret(vm, "Prompt", line);
free(line);
// TODO: Figure out how this should work with wren API.
/*
ObjFn* fn = compile(vm, line);
+4 -2
View File
@@ -478,7 +478,8 @@ static bool runInterpreter(WrenVM* vm)
&&code_CLASS,
&&code_SUBCLASS,
&&code_METHOD_INSTANCE,
&&code_METHOD_STATIC
&&code_METHOD_STATIC,
&&code_END
};
#define INTERPRET_LOOP DISPATCH();
@@ -1022,7 +1023,8 @@ static bool runInterpreter(WrenVM* vm)
CASE_CODE(END):
// A CODE_END should always be preceded by a CODE_RETURN. If we get here,
// the compiler generated wrong code.
ASSERT(0, "Should not execute past end of bytecode.");
UNREACHABLE();
DISPATCH();
}
ASSERT(0, "Should not reach end of interpret.");