diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lux/compiler.clj | 10 | ||||
-rw-r--r-- | src/lux/reader.clj | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/lux/compiler.clj b/src/lux/compiler.clj index e491fbdfe..db2c92c42 100644 --- a/src/lux/compiler.clj +++ b/src/lux/compiler.clj @@ -349,12 +349,16 @@ (if (.equals ^Object name "lux") (return* state nil) (fail* "[Compiler Error] Can't redefine a module!")) - (let [=class (doto (new ClassWriter ClassWriter/COMPUTE_MAXS) + (let [file-name (str "source/" name ".lux") + file-content (slurp file-name) + =class (doto (new ClassWriter ClassWriter/COMPUTE_MAXS) (.visit Opcodes/V1_5 (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER) - (&host/->class name) nil "java/lang/Object" nil))] + (&host/->class name) nil "java/lang/Object" nil)) + _ (doto (.visitField =class (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) "_hash" "I" nil (hash file-content)) + .visitEnd)] (matchv ::M/objects [((&/exhaust% compiler-step) (->> state - (&/set$ &/$SOURCE (&reader/from (str "source/" name ".lux"))) + (&/set$ &/$SOURCE (&reader/from file-name file-content)) (&/set$ &/$ENVS (&/|list (&/env name))) (&/update$ &/$HOST #(&/set$ &/$WRITER (&/V "lux;Some" =class) %)) (&/update$ &/$MODULES #(&/|put name &a-module/init-module %))))] diff --git a/src/lux/reader.clj b/src/lux/reader.clj index b1fcc4740..fa5d659bf 100644 --- a/src/lux/reader.clj +++ b/src/lux/reader.clj @@ -124,8 +124,8 @@ (&/T (&/T file-name line-num column-num*) line))))) (&/V "No" (str "[Reader Error] Text failed: " text)))))) -(defn from [file-name] - (let [lines (&/->list (string/split-lines (slurp file-name)))] +(defn from [file-name file-content] + (let [lines (&/->list (string/split-lines file-content))] (&/|map (fn [line+line-num] (|let [[line-num line] line+line-num] (&/T (&/T file-name line-num 0) |