aboutsummaryrefslogtreecommitdiffstats
path: root/core/init.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-02-11 17:35:26 +0000
committers-ol <s-ol@users.noreply.github.com>2020-02-13 08:39:03 +0000
commit85df7feacac36f5cd058e86ff81b3f4aa9f0ded8 (patch)
treeadf72d8d77016eb8e9d211f256dbdc52d5f14350 /core/init.moon
parentadd edge and pilot/* (diff)
downloadalive-85df7feacac36f5cd058e86ff81b3f4aa9f0ded8.tar.gz
alive-85df7feacac36f5cd058e86ff81b3f4aa9f0ded8.zip
new Registry tagging mechanism
Diffstat (limited to 'core/init.moon')
-rw-r--r--core/init.moon20
1 files changed, 15 insertions, 5 deletions
diff --git a/core/init.moon b/core/init.moon
index c91f0e4..c8f0265 100644
--- a/core/init.moon
+++ b/core/init.moon
@@ -6,28 +6,38 @@ import Const, load_ from require 'core.const'
import Scope from require 'core.scope'
load_!
+import Registry from require 'core.registry'
+
import Cell, RootCell from require 'core.cell'
import cell, program from require 'core.parsing'
+globals = Scope.from_table require 'core.builtin'
+
{
:Const, :Cell, :RootCell
:Op, :Action, :FnDef
:Scope
+ :Registry
+ :globals
+
parse: program\match
eval: do
class BuiltinRegistry
new: =>
- @last = 1
+ @cnt = 1
+
+ init: (tag, expr) =>
+ tag\set @cnt
+ @cnt += 1
- register: (thing, tag) =>
- with tag or Const.sym "builtin.#{@last}"
- @last += 1
+ last: (index) =>
+ replace: (index, expr) =>
registry = BuiltinRegistry!
(str, inject) ->
- scope = Scope.from_table require 'lib.builtin'
+ scope = Scope nil, globals
scope\use inject if inject
ast = assert (cell\match str), "failed to parse: #{str}"