aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/cell.moon11
-rw-r--r--core/const.moon2
-rw-r--r--core/init.moon2
-rw-r--r--core/invoke.moon2
4 files changed, 16 insertions, 1 deletions
diff --git a/core/cell.moon b/core/cell.moon
index 199c4c3..1a25c0a 100644
--- a/core/cell.moon
+++ b/core/cell.moon
@@ -30,8 +30,14 @@ class Cell
action\eval scope, @tail!
quote: (scope, registry) =>
- tag = registry\register @, @tag
children = [child\quote scope, registry for child in *@children]
+ with cell = Cell nil, children, @white
+ cell.tag = registry\register cell, @tag
+ @tag = cell.tag -- for writing back to file
+
+ clone: (prefix) =>
+ tag = Const.sym prefix\getc! .. @tag\getc!
+ children = [child\clone prefix for child in *@children]
Cell tag, children, @white
stringify: (depth=-1) =>
@@ -82,4 +88,7 @@ class RootCell extends Cell
buf
+ @parse: (...) =>
+ @__parent.parse @, (Const.num 0), ...
+
:Cell, :RootCell
diff --git a/core/const.moon b/core/const.moon
index 564ab53..e1d19d9 100644
--- a/core/const.moon
+++ b/core/const.moon
@@ -53,6 +53,8 @@ class Const
stringify: => @raw
+ clone: (prefix) => Const @type, @value, @raw
+
-- static
__tostring: =>
value = if @type == 'opdef' or @type == 'builtin' then @value.__name else @value
diff --git a/core/init.moon b/core/init.moon
index 713f326..ed385fe 100644
--- a/core/init.moon
+++ b/core/init.moon
@@ -1,3 +1,5 @@
+L or= setmetatable {}, __index: => ->
+
import Op, Action from require 'core.base'
import Const, load_ from require 'core.const'
diff --git a/core/invoke.moon b/core/invoke.moon
index 78c40a2..6458f2b 100644
--- a/core/invoke.moon
+++ b/core/invoke.moon
@@ -58,6 +58,8 @@ class fn_invoke extends Action
argm = tail[i]
fn_scope\set name, L\push argm\eval, scope, @registry
+ body = body\clone @tag
+
body\eval fn_scope, @registry
class do_expr extends Action