Mercurial > repos > tabletprog
annotate modules/ast.tp @ 333:577406b25f89
Added binding for SDL_SetTextureColorMod and SDL_GetTextureColorMod and updated the Freetype sample to use it for setting the color of text
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 29 Mar 2015 09:43:24 -0700 |
parents | 2308336790d4 |
children | 27477c8c2823 |
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 |
310
2308336790d4
WIP compiler module for low-level dialect
Michael Pavone <pavone@retrodev.com>
parents:
263
diff
changeset
|
69 size <- { _bits / 8 } |
246
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 signed? <- _signed? |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 stringIndent <- :indent { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 suffix <- "" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 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
|
74 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
|
75 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 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
|
77 "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
|
78 } else: { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 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
|
80 str <- "0b" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 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
|
82 printzero <- false |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 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
|
84 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
|
85 printzero <- true |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 "1" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 } else: { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 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
|
89 }) |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 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
|
91 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 str . suffix |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 } else: { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 (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
|
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 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 string <- { |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 stringIndent: "" |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 } |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
101 fold:with <- :acc :fun { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
102 fun: acc self |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
103 } |
246
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 } |
247
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
106 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
107 symbol <- :_name { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
108 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
109 nodeType <- { _symbol } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
110 name <- _name |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
111 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
112 name |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
113 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
114 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
115 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
116 } |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
117 fold:with <- :acc :fun { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
118 fun: acc self |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
119 } |
247
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 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
123 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
|
124 #{ |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
125 nodeType <- { _call } |
247
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
126 tocall <- _tocall |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
127 args <- _args |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
128 hasReceiver? <- _receiver? |
263
98147071baf6
Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents:
257
diff
changeset
|
129 llMessage? <- { |
98147071baf6
Add support for llMessage definitions in buildMethodTables
Michael Pavone <pavone@retrodev.com>
parents:
257
diff
changeset
|
130 (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
|
131 } |
247
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
132 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
133 argparts <- [] |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
134 if: (tocall nodeType) = _symbol { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
135 argparts <- (tocall name) splitOn: ":" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
136 } else: { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
137 argparts <- [tocall stringIndent: indent] |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
138 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
139 curarg <- args |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
140 str <- "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
141 if: hasReceiver? { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
142 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
|
143 curarg <- curarg tail |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
144 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
145 foreach: argparts :idx part { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
146 str <- str . part . ":" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
147 if: (not: (curarg empty?)) { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
148 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
|
149 curarg <- curarg tail |
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 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
152 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
|
153 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
|
154 curarg <- curarg tail |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
155 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
156 str |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
157 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
158 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
159 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
160 } |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
161 fold:with <- :acc :fun { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
162 acc <- fun: acc self |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
163 _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
|
164 el fold: acc with: fun |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
165 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
166 } |
247
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 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
170 object <- :_messages { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
171 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
172 nodeType <- { _object } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
173 messages <- _messages |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
174 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
175 nextindent <- "\t" . indent |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
176 (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
|
177 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
|
178 }) . "\n" . indent . "}" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
179 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
180 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
181 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
182 } |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
183 fold:with <- :acc :fun { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
184 acc <- fun: acc self |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
185 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
|
186 el fold: acc with: fun |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
187 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
188 } |
247
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 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
192 seqLit:array? <- :_els :_array? { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
193 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
194 nodeType <- { _sequence } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
195 els <- _els |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
196 array? <- _array? |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
197 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
198 nextIndent <- "\t" . indent |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
199 (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
|
200 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
|
201 }) . "\n" . indent . "]" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
202 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
203 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
204 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
205 } |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
206 fold:with <- :acc :fun { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
207 acc <- fun: acc self |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
208 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
|
209 el fold: acc with: fun |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
210 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
211 } |
247
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 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
215 assign:to <- :_expr :_sym { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
216 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
217 nodeType <- { _assignment } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
218 assign <- _expr |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
219 to <- _sym |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
220 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
221 (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
|
222 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
223 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
224 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
225 } |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
226 fold:with <- :acc :fun { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
227 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
|
228 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
|
229 _expr fold: acc with: fun |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
230 } |
247
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 |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
234 lambda:withArgs <- :_exprs :_args { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
235 #{ |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
236 nodeType <- { _lambda } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
237 args <- _args |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
238 expressions <- _exprs |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
239 stringIndent <- :indent { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
240 argStr <- args join: " " |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
241 if: (argStr length) > 0 { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
242 argStr <- argStr . " " |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
243 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
244 nextIndent <- "\t" . indent |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
245 (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
|
246 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
|
247 }) . "\n" . indent . "}" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
248 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
249 string <- { |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
250 stringIndent: "" |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
251 } |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
252 fold:with <- :acc :fun { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
253 acc <- fun: acc self |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
254 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
|
255 el fold: acc with: fun |
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
256 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
247
diff
changeset
|
257 } |
247
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
258 } |
b76f683d076e
Finish moving ast object definitions to a separate ast module
Michael Pavone <pavone@retrodev.com>
parents:
246
diff
changeset
|
259 } |
246
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 } |
8c81afd6d2d3
Refactor some of the AST node object constructors into a separate AST module
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
261 } |