aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-02-11 13:08:12 +0000
committers-ol <s-ol@users.noreply.github.com>2020-02-11 13:08:12 +0000
commitdf9615f114ce8cd23d3293dd8d66ff0811a877dc (patch)
treef34572b4e720cac5a538ef8315647225d90a9875
parentadd MIDI input ops (diff)
downloadalive-df9615f114ce8cd23d3293dd8d66ff0811a877dc.tar.gz
alive-df9615f114ce8cd23d3293dd8d66ff0811a877dc.zip
fix def-and-reused op updaterate
-rw-r--r--core/const.moon23
-rw-r--r--lib/builtin.moon2
2 files changed, 24 insertions, 1 deletions
diff --git a/core/const.moon b/core/const.moon
index 45c44eb..99e4178 100644
--- a/core/const.moon
+++ b/core/const.moon
@@ -10,6 +10,15 @@ ancestor = (klass) ->
klass = klass.__parent
klass
+class Ref
+ new: (@original) =>
+
+ get: (...) => @original\get ...
+ getc: (...) => @original\get ...
+
+ destroy: =>
+ update: =>
+
class Const
types = {
sym: true
@@ -110,4 +119,18 @@ class Const
Const typ, val
+ @wrap_ref: (val) ->
+ if base = rawget val, '__base'
+ -- a class
+ error "#{name}: cannot wrap_ref class '#{val.__name}'"
+ elseif val.__class
+ -- an instance
+ switch ancestor val.__class
+ when Op then Ref val
+ when Const then val
+ else
+ error "#{name}: cannot wrap_ref '#{val.__class.__name}' instance"
+ else
+ error "#{name}: cannot wrap_ref Lua type '#{type val}'"
+
:Const, :load_
diff --git a/lib/builtin.moon b/lib/builtin.moon
index 8e97271..0ae2bd5 100644
--- a/lib/builtin.moon
+++ b/lib/builtin.moon
@@ -43,7 +43,7 @@ updates all val-exprs."
name = (name\quote scope, @registry)\getc 'sym'
val = val_expr\eval scope, @registry
- scope\set name, val
+ scope\set name, Const.wrap_ref val
val
UpdateChildren values