aboutsummaryrefslogtreecommitdiffstats
path: root/core/base.moon
diff options
context:
space:
mode:
Diffstat (limited to 'core/base.moon')
-rw-r--r--core/base.moon30
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