aboutsummaryrefslogtreecommitdiffstats
path: root/base.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-02-02 18:34:18 +0000
committers-ol <s-ol@users.noreply.github.com>2020-02-02 18:35:58 +0000
commit1fb8e4b2e621128e043ae4091f3e25d56b9d7cc2 (patch)
tree9b95ff4e17784aaee4c14372741f2a65d76d02fb /base.moon
parentadd logger (diff)
downloadalive-1fb8e4b2e621128e043ae4091f3e25d56b9d7cc2.tar.gz
alive-1fb8e4b2e621128e043ae4091f3e25d56b9d7cc2.zip
clean out old patching implementation
Diffstat (limited to 'base.moon')
-rw-r--r--base.moon47
1 files changed, 36 insertions, 11 deletions
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: => "<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
}