Rearranged some internal initialization to support multiple files being run

This commit is contained in:
2022-09-05 09:55:04 +01:00
parent f80709ae41
commit 2a3206d951
6 changed files with 95 additions and 37 deletions

View File

@@ -191,6 +191,34 @@ int main() {
}
}
{
//read source
size_t dummy;
size_t exportSize, importSize;
char* exportSource = readFile("../scripts/test/separate-exports.toy", &dummy);
char* importSource = readFile("../scripts/test/separate-imports.toy", &dummy);
//compile
unsigned char* exportBinary = compileString(exportSource, &exportSize);
unsigned char* importBinary = compileString(importSource, &importSize);
//run the interpreter over both binaries
Interpreter interpreter;
initInterpreter(&interpreter);
//NOTE: supress print output for testing
setInterpreterPrint(&interpreter, noPrintFn);
runInterpreter(&interpreter, exportBinary, exportSize); //automatically frees the binary data
runInterpreter(&interpreter, importBinary, importSize); //automatically frees the binary data
freeInterpreter(&interpreter);
//cleanup
free((void*)exportSource);
free((void*)importSource);
}
printf(NOTICE "All good\n" RESET);
return 0;
}