diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-02-02 18:34:18 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-02-02 18:35:58 +0000 |
| commit | 1fb8e4b2e621128e043ae4091f3e25d56b9d7cc2 (patch) | |
| tree | 9b95ff4e17784aaee4c14372741f2a65d76d02fb /base.moon | |
| parent | add logger (diff) | |
| download | alive-1fb8e4b2e621128e043ae4091f3e25d56b9d7cc2.tar.gz alive-1fb8e4b2e621128e043ae4091f3e25d56b9d7cc2.zip | |
clean out old patching implementation
Diffstat (limited to 'base.moon')
| -rw-r--r-- | base.moon | 47 |
1 files changed, 36 insertions, 11 deletions
@@ -1,37 +1,62 @@ import is_object from require 'moon' class Const - types = { sym: true, scope: true, str: true, num: true, op: true, opdef: true, macro: true } + types = { + sym: true + scope: true + str: true + num: true + op: true + opdef: true + macrodef: true + } new: (@type, @value) => assert types[@type], "invalid Const type: #{@type}" get: => @value getc: => @value - __tostring: => "<#{@type}: #{@value}>" + destroy: => -class Op - new: (@node) => - @setup @node\tail! + __tostring: => + value = if @type\match 'def$' then @value.__name else @value + "<#{@type}: #{value}>" - patch: (next) => - @node = next - @setup @node\tail! +class Op + new: (...) => + @setup ... update: (dt) => get: => @value getc: => - print "WARN: stream to constant", debug.traceback! + L\warn "stream #{@} cast to constant" @value destroy: => __tostring: => "<op: #{@@__name}>" - __inherited: (cls) => - cls.__base.__tostring = @__tostring + __inherited: (cls) => cls.__base.__tostring = @__tostring + + spawn: (Opdef, ...) -> + Opdef ... + +class Macro + new: (@node) => + -- print "creating Macro #{@@__name}", debug.traceback! + + -- forwarded from ASTNode + expand: (scope) => + + -- forwarded from ASTNode + -- note: if prev_value is passed, it has to be :destroy'ed or returned + patch: (prev_value) => prev_value + + __tostring: => "<macro: #{@@__name}>" + __inherited: (cls) => cls.__base.__tostring = @__tostring { :Const :Op + :Macro } |
