fix multiple-loading regression

This commit is contained in:
2021-06-14 00:02:26 -06:00
parent 3de68c4b79
commit b93defbaf7
3 changed files with 6 additions and 9 deletions

View File

@@ -128,6 +128,9 @@ class Kiss {
if (loadingDirectory == null) if (loadingDirectory == null)
loadingDirectory = k.loadingDirectory; loadingDirectory = k.loadingDirectory;
var fullPath = Path.join([loadingDirectory, kissFile]); var fullPath = Path.join([loadingDirectory, kissFile]);
if (k.loadedFiles.exists(fullPath)) {
return;
}
k.loadedFiles[fullPath] = true; k.loadedFiles[fullPath] = true;
var stream = Stream.fromFile(fullPath); var stream = Stream.fromFile(fullPath);
Reader.readAndProcess(stream, k, (nextExp) -> { Reader.readAndProcess(stream, k, (nextExp) -> {

View File

@@ -24,9 +24,7 @@ class Macros {
wholeExp.checkNumArgs(1, 1, '(load "[file]")'); wholeExp.checkNumArgs(1, 1, '(load "[file]")');
switch (args[0].def) { switch (args[0].def) {
case StrExp(otherKissFile): case StrExp(otherKissFile):
if (!k.loadedFiles.exists(otherKissFile)) { Kiss.load(otherKissFile, k);
Kiss.load(otherKissFile, k);
}
default: default:
throw CompileError.fromExp(args[0], "only argument to load should be a string literal of a .kiss file path"); throw CompileError.fromExp(args[0], "only argument to load should be a string literal of a .kiss file path");
} }
@@ -44,9 +42,7 @@ class Macros {
}; };
switch (args[1].def) { switch (args[1].def) {
case StrExp(otherKissFile): case StrExp(otherKissFile):
if (!k.loadedFiles.exists(otherKissFile)) { Kiss.load(otherKissFile, k, libPath);
Kiss.load(otherKissFile, k, libPath);
}
default: default:
throw CompileError.fromExp(args[1], "second argument to loadFrom should be a string literal of a .kiss file path"); throw CompileError.fromExp(args[1], "second argument to loadFrom should be a string literal of a .kiss file path");
} }

View File

@@ -87,13 +87,11 @@
// Day 8 // Day 8
(when (<= 0 (days.indexOf 8)) (when (<= 0 (days.indexOf 8))
(print "BootCodeExample")
(let [example (new BootCodeExample)] (let [example (new BootCodeExample)]
(example.setBreakHandler (lambda [example] (assert (= 5 .accumulator example)))) (example.setBreakHandler (lambda [example] (assert (= 5 .accumulator example))))
(example.run)) (example.run))
(print "BootCodeReal")
(let [bootCode (new BootCodeReal)] (let [bootCode (new BootCodeReal)]
(bootCode.setBreakHandler (lambda [bootCode] (assert (= 2058 (print bootCode.accumulator))))) (bootCode.setBreakHandler (lambda [bootCode] (assert (= 2058 bootCode.accumulator))))
(bootCode.run)) (bootCode.run))
/* (print "BootCodeFixExample") /* (print "BootCodeFixExample")
(let [bootCode (new BootCodeFixExample)] (let [bootCode (new BootCodeFixExample)]