equal
deleted
inserted
replaced
46 |
46 |
47 compiledParserSuperclass |
47 compiledParserSuperclass |
48 ^ compiledParserSuperclass ifNil: [ PPCompiledParser ] |
48 ^ compiledParserSuperclass ifNil: [ PPCompiledParser ] |
49 ! |
49 ! |
50 |
50 |
|
51 currentMethod |
|
52 ^ currentMethod |
|
53 ! |
|
54 |
51 currentNonInlineMethod |
55 currentNonInlineMethod |
52 ^ compilerStack |
56 ^ compilerStack |
53 detect:[:m | m isInline not ] |
57 detect:[:m | m isInline not ] |
54 ifNone:[ self error: 'No non-inlined method'] |
58 ifNone:[ self error: 'No non-inlined method'] |
55 |
59 |
80 ! |
84 ! |
81 |
85 |
82 cleanGeneratedMethods: class |
86 cleanGeneratedMethods: class |
83 ((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifTrue:[ |
87 ((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifTrue:[ |
84 class methodsDo: [ :mthd | |
88 class methodsDo: [ :mthd | |
85 mthd category = #generated ifTrue:[ |
89 (mthd category beginsWith: 'generated') ifTrue:[ |
86 class removeSelector: mthd selector. |
90 class removeSelector: mthd selector. |
87 ] |
91 ] |
88 ] |
92 ] |
89 ] ifFalse: [ |
93 ] ifFalse: [ |
90 (class allSelectorsInProtocol: #generated) do: [ :selector | |
94 (class allProtocolsUpTo: class) do: [ :protocol | |
91 class removeSelectorSilently: selector ]. |
95 (protocol beginsWith: 'generated') ifTrue: [ |
|
96 class removeProtocol: protocol. |
|
97 ] |
|
98 ] |
92 ] |
99 ] |
93 ! |
100 ! |
94 |
101 |
95 cleanInstVars: class |
102 cleanInstVars: class |
96 class class instanceVariableNames: ''. |
103 class class instanceVariableNames: ''. |
169 |
176 |
170 "TODO JK: Hack alert, whatever is magic constant!!" |
177 "TODO JK: Hack alert, whatever is magic constant!!" |
171 (variable == #whatever) ifFalse: [ |
178 (variable == #whatever) ifFalse: [ |
172 "Do not assign, if somebody does not care!!" |
179 "Do not assign, if somebody does not care!!" |
173 self add: variable ,' := ', code. |
180 self add: variable ,' := ', code. |
174 ] ifTrue: [ |
181 ] ifTrue: [ |
175 "In case code hava a side effect" |
182 "In case code hava a side effect" |
176 self add: code |
183 self add: code |
177 ] |
184 ] |
178 ! |
185 ! |
179 |
186 |
180 codeClearError |
187 codeClearError |
181 self add: 'self clearError.'. |
188 self add: 'self clearError.'. |
188 codeHalt |
195 codeHalt |
189 self add: 'self halt. ' |
196 self add: 'self halt. ' |
190 ! |
197 ! |
191 |
198 |
192 codeHaltIfShiftPressed |
199 codeHaltIfShiftPressed |
193 arguments debug ifTrue: [ |
200 arguments debug ifTrue: [ |
194 self add: 'Halt ifShiftPressed.' |
201 ((Smalltalk respondsTo: #isSmalltalkX) and:[Smalltalk isSmalltalkX]) ifFalse:[ |
195 ] |
202 self add: 'Halt ifShiftPressed.' |
|
203 ] |
|
204 ] |
|
205 |
|
206 "Modified: / 10-05-2015 / 07:39:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
196 ! |
207 ! |
197 |
208 |
198 codeNextToken |
209 codeNextToken |
199 self add: 'self nextToken.' |
210 self add: 'self nextToken.' |
200 |
211 |
202 "Modified: / 23-04-2015 / 20:51:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
213 "Modified: / 23-04-2015 / 20:51:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
203 ! |
214 ! |
204 |
215 |
205 codeReturn |
216 codeReturn |
206 currentMethod isInline ifTrue: [ |
217 currentMethod isInline ifTrue: [ |
207 "If inlined, the return variable already holds the value" |
218 "If inlined, the return variable already holds the value" |
208 ] ifFalse: [ |
219 ] ifFalse: [ |
209 self add: '^ ', currentMethod returnVariable |
220 self add: '^ ', currentMethod returnVariable |
210 ]. |
221 ]. |
211 |
222 |
212 "Created: / 23-04-2015 / 18:01:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
223 "Created: / 23-04-2015 / 18:01:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
213 "Modified: / 23-04-2015 / 20:51:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
224 "Modified: / 23-04-2015 / 20:51:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
214 ! |
225 ! |
215 |
226 |
216 codeReturn: code |
227 codeReturn: code |
217 " - returns whatever is in code OR |
228 " - returns whatever is in code OR |
218 - assigns whatever is in code into the returnVariable" |
229 - assigns whatever is in code into the returnVariable" |
258 |
269 |
259 asSelector: string |
270 asSelector: string |
260 "e.g. '234znak 43 ) 2' asLegalSelector = #v234znak432" |
271 "e.g. '234znak 43 ) 2' asLegalSelector = #v234znak432" |
261 |
272 |
262 | toUse | |
273 | toUse | |
263 toUse := string select: [:char | char isAlphaNumeric or: [ char = $_ ] ]. |
274 |
|
275 toUse := string select: [:char | char isAlphaNumeric or: [ char = $_ ] ]. |
264 (toUse isEmpty or: [ toUse first isLetter not ]) |
276 (toUse isEmpty or: [ toUse first isLetter not ]) |
265 ifTrue: [ toUse := 'v', toUse ]. |
277 ifTrue: [ toUse := 'v', toUse ]. |
266 ^ toUse uncapitalized asSymbol. |
278 toUse first isUppercase ifFalse:[ |
|
279 toUse := toUse copy. |
|
280 toUse at: 1 put: toUse first asLowercase |
|
281 ]. |
|
282 ^toUse |
|
283 |
|
284 "Modified: / 10-05-2015 / 07:29:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
267 ! |
285 ! |
268 |
286 |
269 idFor: object |
287 idFor: object |
270 self assert: (object isKindOf: PPCNode). |
288 self assert: (object isKindOf: PPCNode). |
271 ^ self idFor: object prefixed: object prefix suffixed: object suffix effect: #none |
289 ^ self idFor: object prefixed: object prefix suffixed: object suffix effect: #none |
377 ! |
395 ! |
378 |
396 |
379 stopMethod |
397 stopMethod |
380 self cache: currentMethod methodName as: currentMethod. |
398 self cache: currentMethod methodName as: currentMethod. |
381 |
399 |
382 arguments profile ifTrue: [ Transcript crShow: currentMethod code ]. |
400 arguments profile ifTrue: [ Transcript show: currentMethod code; cr. ]. |
383 ^ self pop. |
401 ^ self pop. |
384 |
402 |
385 "Modified: / 23-04-2015 / 18:36:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
403 "Modified: / 01-05-2015 / 14:18:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
386 ! |
404 ! |
387 |
405 |
388 top |
406 top |
389 ^ compilerStack top |
407 ^ compilerStack top |
390 ! ! |
408 ! ! |
429 ] |
447 ] |
430 ! |
448 ! |
431 |
449 |
432 installMethods |
450 installMethods |
433 cache keysAndValuesDo: [ :key :method | |
451 cache keysAndValuesDo: [ :key :method | |
434 compiledParser compileSilently: method code classified: 'generated'. |
452 compiledParser compileSilently: method code classified: method category. |
435 ] |
453 ] |
436 ! |
454 ! |
437 |
455 |
438 installVariables |
456 installVariables |
439 | varString | |
457 | varString | |