annotate modules/ast.tp @ 279:eb83863fd33e

Store renderer pointer in texture object since the texture can only be used with the renderer it was created with
author Michael Pavone <pavone@retrodev.com>
date Mon, 21 Jul 2014 19:11:15 -0700
parents 98147071baf6
children 2308336790d4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 {
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
2 _binary <- 0
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
3 _string <- 1
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
4 _int <- 2
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
5 _symbol <- 3
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
6 _call <- 4
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
7 _object <- 5
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
8 _sequence <- 6
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
9 _assignment <- 7
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
10 _lambda <- 8
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 #{
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 binary <- { _binary }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 stringlit <- { _string }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 intlit <- { _int }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
16 sym <- { _symbol }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
17 call <- { _call }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
18 obj <- { _object }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
19 sequence <- { _sequence }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
20 assignment <- { _assignment }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
21 lambda <- { _lambda }
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 binaryOp:withArgs <- :opname :_left _right {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 #{
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 nodeType <- { _binary }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 left <- _left
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 op <- opname
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 right <- _right
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 leftAssociative? <- {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 op != "|"
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33 stringIndent <- :indent {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 (left stringIndent: indent) . " " . op . (right stringIndent: indent)
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 string <- {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 stringIndent: ""
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
39 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
40 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
41 acc <- _left fold: acc with: fun
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
42 _right fold: acc with: fun
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
43 }
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 stringLit <- :_val {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 #{
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 nodeType <- { _string }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50 val <- _val
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 stringIndent <- :indent {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 "\"" . val . "\""
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 string <- {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 stringIndent: ""
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
57 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
58 fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
59 }
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63 intLit:withBits:andBase:signed? <- :_val :_bits :_base :_signed? {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64 #{
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 nodeType <- { _int }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66 val <- _val
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
67 base <- _base
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68 bits <- _bits
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
69 signed? <- _signed?
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
70 stringIndent <- :indent {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
71 suffix <- ""
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72 if: bits != 32 || (not: signed?) {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
73 suffix <- (if: signed? {"i"} else: {"u"}) . bits
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
74 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
75 if: base = 16 {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
76 "0x" . (hex: val) . suffix
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
77 } else: {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
78 if: base = 2 {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
79 str <- "0b"
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80 i <- bits - 1
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
81 printzero <- false
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82 while: { i >= 0 } do: {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
83 str <- str . (if: (lshift: 1 by: i) and val > 0 {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
84 printzero <- true
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 "1"
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
86 } else: {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
87 if: printzero {"0"} else: {""}
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
88 })
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
89 i <- i - 1
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
90 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
91 str . suffix
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
92 } else: {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 (string: val) . suffix
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
94 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
95 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
96 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
97 string <- {
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
98 stringIndent: ""
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
99 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
100 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
101 fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
102 }
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
103 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
104 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
105
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
106 symbol <- :_name {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
107 #{
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
108 nodeType <- { _symbol }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
109 name <- _name
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
110 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
111 name
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
112 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
113 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
114 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
115 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
116 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
117 fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
118 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
119 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
120 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
121
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
122 funcall:withArgs:hasReceiver? <- :_tocall :_args :_receiver? {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
123 #{
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
124 nodeType <- { _call }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
125 tocall <- _tocall
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
126 args <- _args
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
127 hasReceiver? <- _receiver?
263
98147071baf6 Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents: 257
diff changeset
128 llMessage? <- {
98147071baf6 Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents: 257
diff changeset
129 (tocall nodeType) = _symbol && (tocall name) = "llMessage:withVars:andCode"
98147071baf6 Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents: 257
diff changeset
130 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
131 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
132 argparts <- []
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
133 if: (tocall nodeType) = _symbol {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
134 argparts <- (tocall name) splitOn: ":"
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
135 } else: {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
136 argparts <- [tocall stringIndent: indent]
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
137 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
138 curarg <- args
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
139 str <- ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
140 if: hasReceiver? {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
141 str <- ((curarg value) stringIndent: indent) . " "
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
142 curarg <- curarg tail
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
143 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
144 foreach: argparts :idx part {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
145 str <- str . part . ":"
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
146 if: (not: (curarg empty?)) {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
147 str <- str . " " . ((curarg value) stringIndent: indent)
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
148 curarg <- curarg tail
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
149 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
150 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
151 while: { not: (curarg empty?) } do: {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
152 str <- str . " " . ((curarg value) stringIndent: indent)
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
153 curarg <- curarg tail
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
154 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
155 str
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
156 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
157 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
158 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
159 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
160 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
161 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
162 _args fold: acc with: :acc el {
257
be224817a14b Fix fold on ast nodes so that all nodes get visited
Michael Pavone <pavone@retrodev.com>
parents: 252
diff changeset
163 el fold: acc with: fun
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
164 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
165 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
166 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
167 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
168
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
169 object <- :_messages {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
170 #{
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
171 nodeType <- { _object }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
172 messages <- _messages
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
173 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
174 nextindent <- "\t" . indent
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
175 (messages fold: "#{" with: :acc el {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
176 acc . "\n" . nextindent . (el stringIndent: nextindent)
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
177 }) . "\n" . indent . "}"
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
178 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
179 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
180 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
181 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
182 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
183 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
184 messages fold: acc with: :acc el {
257
be224817a14b Fix fold on ast nodes so that all nodes get visited
Michael Pavone <pavone@retrodev.com>
parents: 252
diff changeset
185 el fold: acc with: fun
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
186 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
187 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
188 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
189 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
190
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
191 seqLit:array? <- :_els :_array? {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
192 #{
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
193 nodeType <- { _sequence }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
194 els <- _els
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
195 array? <- _array?
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
196 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
197 nextIndent <- "\t" . indent
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
198 (els fold: (if: array? {"#["} else: {"["}) with: :acc el {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
199 acc . "\n" . nextIndent . (el stringIndent: nextIndent)
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
200 }) . "\n" . indent . "]"
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
201 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
202 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
203 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
204 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
205 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
206 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
207 els fold: acc with: :acc el {
257
be224817a14b Fix fold on ast nodes so that all nodes get visited
Michael Pavone <pavone@retrodev.com>
parents: 252
diff changeset
208 el fold: acc with: fun
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
209 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
210 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
211 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
212 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
213
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
214 assign:to <- :_expr :_sym {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
215 #{
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
216 nodeType <- { _assignment }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
217 assign <- _expr
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
218 to <- _sym
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
219 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
220 (to stringIndent: indent) . " <- " . (assign stringIndent: indent)
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
221 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
222 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
223 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
224 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
225 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
226 acc <- fun: acc self
257
be224817a14b Fix fold on ast nodes so that all nodes get visited
Michael Pavone <pavone@retrodev.com>
parents: 252
diff changeset
227 acc <- _sym fold: acc with: fun
be224817a14b Fix fold on ast nodes so that all nodes get visited
Michael Pavone <pavone@retrodev.com>
parents: 252
diff changeset
228 _expr fold: acc with: fun
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
229 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
230 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
231 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
232
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
233 lambda:withArgs <- :_exprs :_args {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
234 #{
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
235 nodeType <- { _lambda }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
236 args <- _args
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
237 expressions <- _exprs
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
238 stringIndent <- :indent {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
239 argStr <- args join: " "
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
240 if: (argStr length) > 0 {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
241 argStr <- argStr . " "
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
242 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
243 nextIndent <- "\t" . indent
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
244 (expressions fold: argStr . "{" with: :acc el {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
245 acc . "\n" . nextIndent . (el stringIndent: nextIndent)
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
246 }) . "\n" . indent . "}"
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
247 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
248 string <- {
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
249 stringIndent: ""
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
250 }
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
251 fold:with <- :acc :fun {
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
252 acc <- fun: acc self
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
253 expressions fold: acc with: :acc el {
257
be224817a14b Fix fold on ast nodes so that all nodes get visited
Michael Pavone <pavone@retrodev.com>
parents: 252
diff changeset
254 el fold: acc with: fun
252
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
255 }
004946743678 Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents: 247
diff changeset
256 }
247
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
257 }
b76f683d076e Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents: 246
diff changeset
258 }
246
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
259 }
8c81afd6d2d3 Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
260 }