equal
deleted
inserted
replaced
104 ] |
104 ] |
105 ! |
105 ! |
106 |
106 |
107 openDetected: node |
107 openDetected: node |
108 ^ compiler checkCache: (compiler idFor: node) |
108 ^ compiler checkCache: (compiler idFor: node) |
|
109 ! ! |
|
110 |
|
111 !PPCCodeGenerator methodsFor:'private'! |
|
112 |
|
113 withAllVariableNodesOf: anRBProgramNode do: aBlock |
|
114 "Enumerate all chilren of `anRBProgramNode` (including itself) |
|
115 and evaluate `aBlock` for each variable node. |
|
116 This is a replacement for Smalltalk/X's RBProgramNode>>variableNodesDo: |
|
117 which is not present in Pharo" |
|
118 |
|
119 anRBProgramNode isVariable ifTrue:[ |
|
120 aBlock value: anRBProgramNode. |
|
121 ^ self. |
|
122 ]. |
|
123 anRBProgramNode children do:[:each | |
|
124 self withAllVariableNodesOf: each do: aBlock |
|
125 ]. |
|
126 |
|
127 "Created: / 18-06-2015 / 22:02:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
109 ! ! |
128 ! ! |
110 |
129 |
111 !PPCCodeGenerator methodsFor:'support'! |
130 !PPCCodeGenerator methodsFor:'support'! |
112 |
131 |
113 compileTokenWhitespace: node |
132 compileTokenWhitespace: node |
233 blockNeedsCollection := true. |
252 blockNeedsCollection := true. |
234 node child isSequenceNode ifTrue:[ |
253 node child isSequenceNode ifTrue:[ |
235 blockNeedsCollection := false. |
254 blockNeedsCollection := false. |
236 blockMatches := IdentityDictionary new."Must use IDENTITY dict as nodes have overwritten their #=!!!!!!" |
255 blockMatches := IdentityDictionary new."Must use IDENTITY dict as nodes have overwritten their #=!!!!!!" |
237 childValueVars := node child preferredChildrenVariableNames. |
256 childValueVars := node child preferredChildrenVariableNames. |
238 blockBody variableNodesDo:[:variableNode| |
257 self withAllVariableNodesOf: blockBody do:[:variableNode| |
239 variableNode name = blockNodesVar name ifTrue:[ |
258 variableNode name = blockNodesVar name ifTrue:[ |
240 "Check if variable node matches..." |
259 "Check if variable node matches..." |
241 variableNode parent isMessage ifTrue:[ |
260 variableNode parent isMessage ifTrue:[ |
242 | parent | |
261 | parent | |
243 |
262 |
302 compiler codeReturn: 'failure'. |
321 compiler codeReturn: 'failure'. |
303 ] else: [ |
322 ] else: [ |
304 compiler code: blockBody. |
323 compiler code: blockBody. |
305 ] |
324 ] |
306 |
325 |
307 "Modified: / 16-06-2015 / 07:41:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
326 "Modified: / 18-06-2015 / 22:03:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
308 ! |
327 ! |
309 |
328 |
310 visitAndNode: node |
329 visitAndNode: node |
311 | mementoVar | |
330 | mementoVar | |
312 |
331 |
510 In the block, replace all references to block argument to |
529 In the block, replace all references to block argument to |
511 my retvalVar. " |
530 my retvalVar. " |
512 | blockArg | |
531 | blockArg | |
513 |
532 |
514 blockArg := blockNode arguments first. |
533 blockArg := blockNode arguments first. |
515 blockBody variableNodesDo:[:variableNode| |
534 self withAllVariableNodesOf: blockBody do:[:variableNode| |
516 variableNode name = blockArg name ifTrue:[ |
535 variableNode name = blockArg name ifTrue:[ |
517 variableNode token value: self retvalVar. |
536 variableNode token value: self retvalVar. |
518 ]. |
537 ]. |
519 ]. |
538 ]. |
520 ]. |
539 ]. |
536 ]. |
555 ]. |
537 compiler code: blockBody. |
556 compiler code: blockBody. |
538 ] |
557 ] |
539 |
558 |
540 "Created: / 02-06-2015 / 17:28:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
559 "Created: / 02-06-2015 / 17:28:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
541 "Modified: / 18-06-2015 / 06:34:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
560 "Modified: / 18-06-2015 / 22:03:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
542 ! |
561 ! |
543 |
562 |
544 visitMessagePredicateNode: node |
563 visitMessagePredicateNode: node |
545 compiler add: '(context peek ', node message, ') ifFalse: ['. |
564 compiler add: '(context peek ', node message, ') ifFalse: ['. |
546 compiler codeError: 'predicate not found'. |
565 compiler codeError: 'predicate not found'. |