diff options
author | Eduardo Julian | 2020-03-18 21:38:34 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-03-18 21:38:34 -0400 |
commit | 30801bcf8fbb1be7ae8f193edfa71e6c4909a4c3 (patch) | |
tree | d6f4f9335664f4d25c6c037e848d0743d211ff74 /stdlib/source/lux/tool/compiler/meta/archive | |
parent | 71c99d63a313d497c3881ab06752f05e3af33350 (diff) |
No passing the archive as a parameter to all phases.
Diffstat (limited to 'stdlib/source/lux/tool/compiler/meta/archive')
-rw-r--r-- | stdlib/source/lux/tool/compiler/meta/archive/artifact.lux | 48 | ||||
-rw-r--r-- | stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux | 7 |
2 files changed, 53 insertions, 2 deletions
diff --git a/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux new file mode 100644 index 000000000..222bb2479 --- /dev/null +++ b/stdlib/source/lux/tool/compiler/meta/archive/artifact.lux @@ -0,0 +1,48 @@ +(.module: + [lux #* + [data + ["." text] + [collection + ["." row (#+ Row)] + ["." dictionary (#+ Dictionary)]]] + [type + abstract]]) + +(type: #export ID Nat) + +(type: Artifact + (#Resource ID) + (#Definition [ID Text])) + +(abstract: #export Registry + {} + {#next ID + #artifacts (Row Artifact) + #resolver (Dictionary Text ID)} + + (def: #export empty + Registry + (:abstraction {#next 0 + #artifacts row.empty + #resolver (dictionary.new text.hash)})) + + (def: #export (resource registry) + (-> Registry [ID Registry]) + (let [id (get@ #next (:representation registry))] + [id + (|> registry + :representation + (update@ #next inc) + (update@ #artifacts (row.add (#Resource id))) + :abstraction)])) + + (def: #export (definition name registry) + (-> Text Registry [ID Registry]) + (let [id (get@ #next (:representation registry))] + [id + (|> registry + :representation + (update@ #next inc) + (update@ #artifacts (row.add (#Definition id name))) + :abstraction)])) + ) diff --git a/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux b/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux index 5daf10016..4582ab702 100644 --- a/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux +++ b/stdlib/source/lux/tool/compiler/meta/archive/descriptor.lux @@ -4,7 +4,9 @@ [collection [set (#+ Set)]]] [world - [file (#+ Path)]]]) + [file (#+ Path)]]] + [// + [artifact (#+ Registry)]]) (type: #export Module Text) @@ -13,4 +15,5 @@ #name Module #file Path #references (Set Module) - #state Module-State}) + #state Module-State + #registry Registry}) |