equal
deleted
inserted
replaced
30 ! ! |
30 ! ! |
31 |
31 |
32 !PPCConfiguration methodsFor:'accessing'! |
32 !PPCConfiguration methodsFor:'accessing'! |
33 |
33 |
34 arguments |
34 arguments |
35 arguments isNil ifTrue: [ arguments := self defaultArguments ]. |
35 arguments isNil ifTrue: [ arguments := self defaultArguments ]. |
36 ^ arguments |
36 ^ arguments |
37 ! |
37 ! |
38 |
38 |
39 arguments: args |
39 arguments: args |
40 arguments := args |
40 arguments := args |
41 ! |
41 ! |
42 |
42 |
43 defaultArguments |
43 defaultArguments |
44 ^ PPCArguments default |
44 ^ PPCArguments default |
45 ! |
45 ! |
46 |
46 |
47 input: whatever |
47 input: whatever |
48 ir := whatever. |
48 ir := whatever. |
49 self remember: #input. |
49 self remember: #input. |
96 ! |
96 ! |
97 |
97 |
98 cacheFollowSetWithTokens |
98 cacheFollowSetWithTokens |
99 "Creates a PPCNodes from a PPParser" |
99 "Creates a PPCNodes from a PPParser" |
100 | followSets | |
100 | followSets | |
101 followSets := ir firstSetsSuchThat: [:e | e isTerminal or: [ e isTokenNode ] ]. |
101 followSets := ir followSetsSuchThat: [:e | e isTerminal or: [ e isTokenNode ] ]. |
102 ir allNodesDo: [ :node | |
102 ir allNodesDo: [ :node | |
103 node followSetWithTokens: (followSets at: node) |
103 node followSetWithTokens: (followSets at: node) |
104 ] |
104 ] |
105 ! ! |
105 ! ! |
106 |
106 |
107 !PPCConfiguration methodsFor:'compiling'! |
107 !PPCConfiguration methodsFor:'compiling'! |
108 |
108 |
|
109 buildClass: compiler |
|
110 self subclassResponsibility |
|
111 ! |
|
112 |
109 compile: whatever |
113 compile: whatever |
|
114 | time | |
110 self input: whatever. |
115 self input: whatever. |
111 self invokePhases. |
116 |
|
117 time := [ self invokePhases ] timeToRun asMilliSeconds. |
|
118 self reportTime: time. |
|
119 |
112 ^ ir |
120 ^ ir |
113 ! |
121 ! |
114 |
122 |
115 invokePhases |
123 invokePhases |
116 self subclassResponsibility |
124 self subclassResponsibility |
128 ] |
136 ] |
129 ! ! |
137 ! ! |
130 |
138 |
131 !PPCConfiguration methodsFor:'hooks'! |
139 !PPCConfiguration methodsFor:'hooks'! |
132 |
140 |
|
141 codeCompiler |
|
142 ^ PPCCodeGen on: arguments |
|
143 ! |
|
144 |
133 codeCompilerOn: args |
145 codeCompilerOn: args |
134 ^ PPCCompiler on: args |
146 ^ PPCCodeGen on: args |
135 ! |
147 ! |
136 |
148 |
137 codeGeneratorVisitorOn: compiler |
149 codeGeneratorVisitorOn: compiler |
138 ^ arguments codeGenerator on: compiler |
150 ^ arguments codeGenerator on: compiler |
139 ! ! |
151 ! ! |
176 visit: ir. |
188 visit: ir. |
177 self remember: #createTokens |
189 self remember: #createTokens |
178 ! |
190 ! |
179 |
191 |
180 generate |
192 generate |
181 | compiler rootMethod compiledParser | |
193 | compiler rootMethod compiledParser | |
182 arguments generate ifFalse: [ ^ self ]. |
194 arguments generate ifFalse: [ ^ self ]. |
183 |
195 |
184 compiler := self codeCompilerOn: arguments. |
196 compiler := self codeCompiler. |
185 |
197 |
186 rootMethod := (self codeGeneratorVisitorOn: compiler) |
198 rootMethod := (self codeGeneratorVisitorOn: compiler) |
187 arguments: arguments; |
199 arguments: arguments; |
188 visit: ir. |
200 visit: ir. |
189 |
201 |
190 compiler compileParser. |
202 compiledParser := self buildClass: compiler. |
191 compiler compiledParser startSymbol: rootMethod methodName. |
203 compiledParser startSymbol: rootMethod methodName. |
192 compiledParser := compiler compiledParser new. |
204 compiledParser := compiledParser new. |
193 |
205 |
194 ir := compiledParser. |
206 ir := compiledParser. |
195 ! |
207 ! |
196 |
208 |
197 inline |
209 inline |
232 "Creates a PPCNodes from a PPParser" |
244 "Creates a PPCNodes from a PPParser" |
233 ir := ir asCompilerTree. |
245 ir := ir asCompilerTree. |
234 self remember: #ppcNodes |
246 self remember: #ppcNodes |
235 ! ! |
247 ! ! |
236 |
248 |
|
249 !PPCConfiguration methodsFor:'reporting'! |
|
250 |
|
251 reportTime: timeInMs |
|
252 arguments profile ifTrue: [ |
|
253 Transcript show: 'Time to compile: ', timeInMs asString, ' ms'; cr. |
|
254 ] |
|
255 ! ! |
|
256 |