diff options
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 } |
