diff options
author | Eduardo Julian | 2017-05-03 18:17:00 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-05-03 18:17:00 -0400 |
commit | bf47bd7b3d4f70bc3a481761b8e9ff074313fb44 (patch) | |
tree | 7f5f0f625b59eff108d2b2652fa604c4b4aec3fc /new-luxc/source/luxc/module.lux | |
parent | 3f146f8372758c39ece0b9a4c19f4f408e8400ea (diff) |
- WIP: Implemented more functionality.
- Lots of refactorings.
Diffstat (limited to 'new-luxc/source/luxc/module.lux')
-rw-r--r-- | new-luxc/source/luxc/module.lux | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/new-luxc/source/luxc/module.lux b/new-luxc/source/luxc/module.lux index 2d48b3617..e5848fccb 100644 --- a/new-luxc/source/luxc/module.lux +++ b/new-luxc/source/luxc/module.lux @@ -1,6 +1,59 @@ (;module: lux (lux (control monad) - (data text/format)) + (data [text "T/" Eq<Text>] + text/format + ["E" error])) (luxc ["&" base])) +(def: (new-module hash) + (-> Nat Module) + {#;module-hash hash + #;module-aliases (list) + #;defs (list) + #;imports (list) + #;tags (list) + #;types (list) + #;module-anns (list) + #;module-state #;Active}) + +(def: #export (create hash name) + (-> Nat Text (Lux Module)) + (function [compiler] + (let [module (new-module hash)] + (#E;Success [(update@ #;modules + (&;pl::put name module) + compiler) + module])))) + +(do-template [<flagger> <asker> <tag>] + [(def: #export (<flagger> module-name) + (-> Text (Lux Unit)) + (function [compiler] + (case (|> compiler (get@ #;modules) (&;pl::get module-name)) + (#;Some module) + (#E;Success [(update@ #;modules + (&;pl::put module-name (set@ #;module-state <tag> module)) + compiler) + []]) + + #;None + (#E;Error (format "Module does not exist: " module-name))))) + (def: #export (<asker> module-name) + (-> Text (Lux Bool)) + (function [compiler] + (case (|> compiler (get@ #;modules) (&;pl::get module-name)) + (#;Some module) + (#E;Success [compiler + (case (get@ #;module-state module) + <tag> true + _ false)]) + + #;None + (#E;Error (format "Module does not exist: " module-name))) + ))] + + [flag-active! active? #;Active] + [flag-compiled! compiled? #;Compiled] + [flag-cached! cached? #;Cached] + ) |