|
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
|
2 |
|
3 "{ NameSpace: Smalltalk }" |
|
4 |
|
5 PPCNodeVisitor subclass:#PPCInliningVisitor |
|
6 instanceVariableNames:'acceptedNodes' |
|
7 classVariableNames:'' |
|
8 poolDictionaries:'' |
|
9 category:'PetitCompiler-Visitors' |
|
10 ! |
|
11 |
|
12 !PPCInliningVisitor methodsFor:'initialization'! |
|
13 |
|
14 initialize |
|
15 super initialize. |
|
16 |
|
17 acceptedNodes := 0 |
|
18 ! ! |
|
19 |
|
20 !PPCInliningVisitor methodsFor:'testing'! |
|
21 |
|
22 canInline |
|
23 ^ acceptedNodes > 1 |
|
24 ! ! |
|
25 |
|
26 !PPCInliningVisitor methodsFor:'visiting'! |
|
27 |
|
28 beforeAccept: node |
|
29 acceptedNodes := acceptedNodes + 1. |
|
30 super beforeAccept: node |
|
31 ! |
|
32 |
|
33 markForInline: node |
|
34 self canInline ifTrue: [ |
|
35 node markForInline. |
|
36 ]. |
|
37 ^ node |
|
38 ! |
|
39 |
|
40 visitCharSetPredicateNode: node |
|
41 ^ self markForInline: node |
|
42 ! |
|
43 |
|
44 visitCharacterNode: node |
|
45 ^ self markForInline: node |
|
46 ! |
|
47 |
|
48 visitLiteralNode: node |
|
49 ^ self markForInline: node |
|
50 ! |
|
51 |
|
52 visitMessagePredicateNode: node |
|
53 ^ self markForInline: node |
|
54 ! |
|
55 |
|
56 visitNilNode: node |
|
57 ^ self markForInline: node |
|
58 ! |
|
59 |
|
60 visitNotCharSetPredicateNode: node |
|
61 ^ self markForInline: node |
|
62 ! |
|
63 |
|
64 visitNotLiteralNode: node |
|
65 ^ self markForInline: node |
|
66 ! |
|
67 |
|
68 visitNotMessagePredicateNode: node |
|
69 ^ self markForInline: node |
|
70 ! |
|
71 |
|
72 visitPluggableNode: node |
|
73 "Sadly, on Smalltalk/X blocks cannot be inlined because |
|
74 the VM does not provide enough information to map |
|
75 it back to source code. Very bad indeed!!" |
|
76 ((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifFalse:[ |
|
77 ^ self markForInline: node |
|
78 ]. |
|
79 ^ super visitPluggableNode: node. |
|
80 |
|
81 "Modified: / 23-04-2015 / 12:15:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
82 ! |
|
83 |
|
84 visitTokenStarMessagePredicateNode: node |
|
85 ^ self markForInline: node |
|
86 ! |
|
87 |
|
88 visitTokenStarSeparatorNode: node |
|
89 ^ self markForInline: node |
|
90 ! ! |
|
91 |