diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-02-11 17:35:26 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-02-13 08:39:03 +0000 |
| commit | 85df7feacac36f5cd058e86ff81b3f4aa9f0ded8 (patch) | |
| tree | adf72d8d77016eb8e9d211f256dbdc52d5f14350 /core/base.moon | |
| parent | add edge and pilot/* (diff) | |
| download | alive-85df7feacac36f5cd058e86ff81b3f4aa9f0ded8.tar.gz alive-85df7feacac36f5cd058e86ff81b3f4aa9f0ded8.zip | |
new Registry tagging mechanism
Diffstat (limited to 'core/base.moon')
| -rw-r--r-- | core/base.moon | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/core/base.moon b/core/base.moon index 05f7590..3be2a98 100644 --- a/core/base.moon +++ b/core/base.moon @@ -22,12 +22,10 @@ class Op class Action -- common - new: (head, @tag, @registry) => + new: (head, @tag) => + @registry = @tag.registry -- @TODO: remove @patch head - register: => - @tag = @registry\register @, @tag - -- AST interface -- * eval args -- * perform scope effects @@ -49,21 +47,29 @@ class Action @head = head -- static - @get_or_create: (ActionType, head, tag, registry) -> - last = tag and registry\prev tag + @get_or_create: (ActionType, head, tag) -> + last = tag\last! compatible = last and (last.__class == ActionType) and (last\patch head) and last - if not compatible + L\trace if compatible + "reusing #{last} for #{tag} <#{ActionType.__name} #{head}>" + else if last + "replacing #{last} with new #{tag} <#{ActionType.__name} #{head}>" + else + "initializing #{tag} <#{ActionType.__name} #{head}>" + + if compatible + tag\keep compatible + compatible + else last\destroy! if last - compatible = ActionType head, tag, registry - - with compatible - \register! + with next = ActionType head, tag + tag\replace next - __tostring: => "<action: #{@@__name}>" + __tostring: => "<#{@@__name} #{@head}>" __inherited: (cls) => cls.__base.__tostring = @__tostring class FnDef |
