diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-02-11 17:35:26 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-02-13 08:39:03 +0000 |
| commit | 85df7feacac36f5cd058e86ff81b3f4aa9f0ded8 (patch) | |
| tree | adf72d8d77016eb8e9d211f256dbdc52d5f14350 /core/init.moon | |
| parent | add edge and pilot/* (diff) | |
| download | alive-85df7feacac36f5cd058e86ff81b3f4aa9f0ded8.tar.gz alive-85df7feacac36f5cd058e86ff81b3f4aa9f0ded8.zip | |
new Registry tagging mechanism
Diffstat (limited to 'core/init.moon')
| -rw-r--r-- | core/init.moon | 20 |
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}" |
