-
Notifications
You must be signed in to change notification settings - Fork 71
/
RBBlockNode.extension.st
53 lines (46 loc) · 1.74 KB
/
RBBlockNode.extension.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
Extension { #name : #RBBlockNode }
{ #category : #'*VMMakerCompatibilityForPharo6-C translation' }
RBBlockNode >> asTranslatorNodeIn: aTMethod [
body := body asTranslatorNodeIn: aTMethod.
body statements ifEmpty: [
body statements add: (TConstantNode value: nil).
].
^ body
]
{ #category : #'*VMMakerCompatibilityForPharo6-testing' }
RBBlockNode >> isBlockNode [
^true
]
{ #category : #'*VMMakerCompatibilityForPharo6-C translation' }
RBBlockNode >> isPotentialCCaseLabel: stmt in: aTMethod [
(stmt isVariable
or: [stmt isLiteralNode
and: [stmt isConstantNumber or: [stmt literalValue isSymbol]]]) ifTrue:
[^true].
stmt isMessage ifTrue:
[| selector implementingClass method |
selector := stmt selector.
(#(* + -) includes: selector) ifTrue:
[^(self isPotentialCCaseLabel: stmt receiver in: aTMethod)
and: [self isPotentialCCaseLabel: stmt arguments first in: aTMethod]].
(selector = #asSymbol
and: [stmt receiver isLiteralNode
and: [stmt receiver literalValue isSymbol]]) ifTrue:
[^true].
(stmt arguments isEmpty
and: [implementingClass := aTMethod definingClass whichClassIncludesSelector: selector.
implementingClass ifNil:
[implementingClass := aTMethod definingClass objectMemoryClass whichClassIncludesSelector: selector].
method := implementingClass >> selector.
(method isQuick
or: [(method literalAt: 1) isInteger
and: [method numLiterals = 3]])
and: [(implementingClass basicNew perform: selector) isInteger]]) ifTrue:
[^true]].
^false
]
{ #category : #'*VMMakerCompatibilityForPharo6-C translation' }
RBBlockNode >> isPotentialCCaseLabelIn: aTMethod [
body statements size ~= 1 ifTrue: [^false].
^self isPotentialCCaseLabel: body statements first in: aTMethod
]