-
Notifications
You must be signed in to change notification settings - Fork 67
/
TInlineNode.class.st
142 lines (110 loc) · 3.28 KB
/
TInlineNode.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
Class {
#name : #TInlineNode,
#superclass : #TParseNode,
#instVars : [
'method'
],
#category : #'Slang-AST'
}
{ #category : #visiting }
TInlineNode >> accept: aVisitor [
^ aVisitor visitInlineNode: self
]
{ #category : #tranforming }
TInlineNode >> asCASTIn: aBuilder [
^ method asCASTInlinedIn: aBuilder
]
{ #category : #transformations }
TInlineNode >> bindVariableUsesIn: aDictionary [
method := method bindVariableUsesIn: aDictionary.
]
{ #category : #transformations }
TInlineNode >> bindVariableUsesIn: aDictionary andConstantFoldIf: constantFold in: codeGen [
"Answer either the receiver, if it contains no references to the given variables, or a new node with the given variables rebound."
| newMethod |
newMethod := method bindVariableUsesIn: aDictionary andConstantFoldIf: constantFold in: codeGen.
^newMethod = method
ifTrue: [self]
ifFalse: [self shallowCopy
method: newMethod;
yourself]
]
{ #category : #transformations }
TInlineNode >> bindVariablesIn: aDictionary [
method := method bindVariablesIn: aDictionary.
]
{ #category : #transformations }
TInlineNode >> bindVariablesIn: aDictionary unless: cautionaryBlock [
(cautionaryBlock value: self) ifTrue: [^self].
method := method bindVariablesIn: aDictionary unless: cautionaryBlock.
]
{ #category : #accessing }
TInlineNode >> children [
^ { method }
]
{ #category : #testing }
TInlineNode >> isInline [
^true
]
{ #category : #comparing }
TInlineNode >> isSameAs: anotherNode [
^ anotherNode isInline
and: [ method selector = anotherNode method selector
and: [ method parseTree isSameAs: anotherNode method parseTree ] ]
]
{ #category : #accessing }
TInlineNode >> method [
^method
]
{ #category : #accessing }
TInlineNode >> method: aTMethod [
method := aTMethod
]
{ #category : #enumerating }
TInlineNode >> nodesDo: aBlock [
"Apply aBlock to all nodes in the receiver.
N.B. This is assumed to be bottom-up, leaves first."
method parseTree nodesDo: aBlock.
aBlock value: self
]
{ #category : #enumerating }
TInlineNode >> nodesDo: aBlock parent: parent [
"Apply aBlock to all nodes in the receiver with each node's parent.
N.B. This is assumed to be bottom-up, leaves first."
method parseTree nodesDo: aBlock parent: self.
aBlock value: self value: parent
]
{ #category : #enumerating }
TInlineNode >> nodesDo: aBlock parent: parent unless: cautionaryBlock [
(cautionaryBlock value: self value: parent) ifTrue: [^self].
method parseTree nodesDo: aBlock parent: self unless: cautionaryBlock.
aBlock value: self value: parent
]
{ #category : #enumerating }
TInlineNode >> nodesDo: aBlock unless: cautionaryBlock [
(cautionaryBlock value: self) ifTrue: [^self].
method parseTree nodesDo: aBlock unless: cautionaryBlock.
aBlock value: self.
]
{ #category : #copying }
TInlineNode >> postCopy [
method := method copy
]
{ #category : #printing }
TInlineNode >> printOn: aStream level: anInteger [
method parseTree printOn: aStream level: anInteger
]
{ #category : #transformations }
TInlineNode >> replaceNodesIn: map [
^map at: self ifAbsent: [
method replaceNodesIn: map.
self]
]
{ #category : #inlining }
TInlineNode >> shouldExpand [
^method extractExpandCaseDirective
]
{ #category : #'type inference' }
TInlineNode >> typeOrNilFrom: aCodeGenerator in: aTMethod [
^method returnType
]