From b93defbaf71d203d297787422cb1da21edc45a27 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 14 Jun 2021 00:02:26 -0600 Subject: [PATCH] fix multiple-loading regression --- kiss/src/kiss/Kiss.hx | 3 +++ kiss/src/kiss/Macros.hx | 8 ++------ projects/aoc/src/year2020/Solutions.kiss | 4 +--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/kiss/src/kiss/Kiss.hx b/kiss/src/kiss/Kiss.hx index d1e22c2c..b61a4473 100644 --- a/kiss/src/kiss/Kiss.hx +++ b/kiss/src/kiss/Kiss.hx @@ -128,6 +128,9 @@ class Kiss { if (loadingDirectory == null) loadingDirectory = k.loadingDirectory; var fullPath = Path.join([loadingDirectory, kissFile]); + if (k.loadedFiles.exists(fullPath)) { + return; + } k.loadedFiles[fullPath] = true; var stream = Stream.fromFile(fullPath); Reader.readAndProcess(stream, k, (nextExp) -> { diff --git a/kiss/src/kiss/Macros.hx b/kiss/src/kiss/Macros.hx index 590dbc7f..0f75f3d6 100644 --- a/kiss/src/kiss/Macros.hx +++ b/kiss/src/kiss/Macros.hx @@ -24,9 +24,7 @@ class Macros { wholeExp.checkNumArgs(1, 1, '(load "[file]")'); switch (args[0].def) { case StrExp(otherKissFile): - if (!k.loadedFiles.exists(otherKissFile)) { - Kiss.load(otherKissFile, k); - } + Kiss.load(otherKissFile, k); default: 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) { case StrExp(otherKissFile): - if (!k.loadedFiles.exists(otherKissFile)) { - Kiss.load(otherKissFile, k, libPath); - } + Kiss.load(otherKissFile, k, libPath); default: throw CompileError.fromExp(args[1], "second argument to loadFrom should be a string literal of a .kiss file path"); } diff --git a/projects/aoc/src/year2020/Solutions.kiss b/projects/aoc/src/year2020/Solutions.kiss index 4a7e09da..3a435c46 100644 --- a/projects/aoc/src/year2020/Solutions.kiss +++ b/projects/aoc/src/year2020/Solutions.kiss @@ -87,13 +87,11 @@ // Day 8 (when (<= 0 (days.indexOf 8)) - (print "BootCodeExample") (let [example (new BootCodeExample)] (example.setBreakHandler (lambda [example] (assert (= 5 .accumulator example)))) (example.run)) - (print "BootCodeReal") (let [bootCode (new BootCodeReal)] - (bootCode.setBreakHandler (lambda [bootCode] (assert (= 2058 (print bootCode.accumulator))))) + (bootCode.setBreakHandler (lambda [bootCode] (assert (= 2058 bootCode.accumulator)))) (bootCode.run)) /* (print "BootCodeFixExample") (let [bootCode (new BootCodeFixExample)]