From 1fb8e4b2e621128e043ae4091f3e25d56b9d7cc2 Mon Sep 17 00:00:00 2001 From: s-ol Date: Sun, 2 Feb 2020 19:34:18 +0100 Subject: clean out old patching implementation --- base.moon | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'base.moon') diff --git a/base.moon b/base.moon index 72dd62f..334431c 100644 --- a/base.moon +++ b/base.moon @@ -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: => "" - __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: => "" + __inherited: (cls) => cls.__base.__tostring = @__tostring { :Const :Op + :Macro } -- cgit v1.2.3