diff options
Diffstat (limited to 'alv')
| -rw-r--r-- | alv/module.moon | 2 | ||||
| -rw-r--r-- | alv/registry.moon | 6 | ||||
| -rw-r--r-- | alv/tag.moon | 28 |
3 files changed, 24 insertions, 12 deletions
diff --git a/alv/module.moon b/alv/module.moon index 6eeb10b..d3fa5e5 100644 --- a/alv/module.moon +++ b/alv/module.moon @@ -14,7 +14,7 @@ class Module --- create a new Module. -- @classmethod new: => - @registry = Registry! + @registry = Registry @ --- check when the module source has last changed. -- @function poll diff --git a/alv/registry.moon b/alv/registry.moon index b625c1f..77aae7d 100644 --- a/alv/registry.moon +++ b/alv/registry.moon @@ -100,12 +100,16 @@ class Registry @last_map = {} + --- the module associated with this Registry + -- @tfield Module module + --- static functions -- @section static --- create a new Registry. -- @classmethod - new: => + -- @tparam Module module + new: (@module) => @last_map = {} { diff --git a/alv/tag.moon b/alv/tag.moon index 1ad9b28..070b0cd 100644 --- a/alv/tag.moon +++ b/alv/tag.moon @@ -37,6 +37,13 @@ class Tag assert parent, "need parent to clone!" ClonedTag @, parent + --- get a globally-unique identifier for this tag + -- + -- prepends the module name to the tag string + -- + -- @treturn string a unique string + ident: => "#{@registry.module\name!}:#{@}" + stringify: (depth=-1) => if @value and depth == -1 then "[#{@value}]" else '' __tostring: => if @value then "#{@value}" else '?' @@ -45,8 +52,8 @@ class Tag new: (@value) => if COPILOT and "string" != type @value - registry = COPILOT.active_module.registry - @pending = registry\register @ + @registry = COPILOT.active_module.registry + @pending = @registry\register @ --- get a unique index value for this Tag. -- @@ -66,6 +73,12 @@ class Tag assert either_or, "unexpected :set #{value} on #{@}" @value = value + --- the Registry associated with this Tag + -- @tfield Registry registry + + --- whether this Tag is newly assigned this tick + -- @tfield bool pending + --- static functions -- @section static @@ -80,8 +93,8 @@ class ClonedTag extends Tag if 'string' == type @original.value return - registry = COPILOT.active_module.registry - registry\register @ + @registry = COPILOT.active_module.registry + @registry\register @ @pending = @original.pending or @parent.pending @@ -96,12 +109,7 @@ class ClonedTag extends Tag @original\set value stringify: => error "cant stringify ClonedTag" - - __tostring: => - if @parent - "#{@parent}.#{@original}" - else - tostring @original + __tostring: => "#{@parent}.#{@original}" { :Tag |
