aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-02-13 20:27:51 +0000
committers-ol <s-ol@users.noreply.github.com>2020-02-13 20:27:51 +0000
commit1c5f0eb93b2b32c4c01ec98cad81e6b4f3e715e9 (patch)
tree8f1c3978d020e9f03967d1e7448688f101b7da75
parentremove outdated tests (diff)
downloadalive-1c5f0eb93b2b32c4c01ec98cad81e6b4f3e715e9.tar.gz
alive-1c5f0eb93b2b32c4c01ec98cad81e6b4f3e715e9.zip
fix tagging
-rw-r--r--core/cell.moon1
-rw-r--r--core/registry.moon4
-rw-r--r--core/tag.moon25
3 files changed, 16 insertions, 14 deletions
diff --git a/core/cell.moon b/core/cell.moon
index 81409c3..4aa847b 100644
--- a/core/cell.moon
+++ b/core/cell.moon
@@ -43,6 +43,7 @@ class Cell
Cell @tag, children, @white
clone: (parent) =>
+ @tag\ensure!
tag = @tag\clone parent
children = [child\clone parent for child in *@children]
Cell tag, children, @white
diff --git a/core/registry.moon b/core/registry.moon
index 6afd361..3fc6d55 100644
--- a/core/registry.moon
+++ b/core/registry.moon
@@ -6,9 +6,9 @@ class Registry
last: (index) => @last_map[index]
- replace: (index, expr) =>
+ replace: (index, expr, ignore_dup=false) =>
L\trace "reg: setting #{index} to #{expr}"
- assert not @map[index], "duplicate tags with index #{index}!"
+ assert not @map[index] or ignore_dup, "duplicate tags with index #{index}!"
@map[index] = expr
init: (tag, expr) =>
diff --git a/core/tag.moon b/core/tag.moon
index 47c43fa..122c67e 100644
--- a/core/tag.moon
+++ b/core/tag.moon
@@ -2,6 +2,13 @@ import Registry from require 'core.registry'
local ClonedTag
+class DummyReg
+ destroy: =>
+
+ __tostring: => "<dummy>"
+
+dummy = DummyReg!
+
class Tag
new: (@value) =>
@@ -22,6 +29,12 @@ class Tag
else
Registry.active!\init @, expr
+ ensure: =>
+ if index = @index!
+ Registry.active!\replace index, dummy, true
+ else
+ Registry.active!\init @, dummy
+
index: => @value
set: (value) =>
@@ -36,19 +49,7 @@ class Tag
__tostring: => if @value then "#{@value}" else '[blank]'
class ClonedTag extends Tag
- class DummyReg
- destroy: =>
-
new: (@original, @parent) =>
- @dummy = DummyReg!
-
- keep: (expr) =>
- super\keep expr
- @original\replace @dummy
-
- replace: (expr) =>
- super\replace expr
- @original\replace @dummy
index: =>
orig = @original\index!