-
Notifications
You must be signed in to change notification settings - Fork 65
/
RBReturnNode.extension.st
31 lines (30 loc) · 1.1 KB
/
RBReturnNode.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
Extension { #name : #RBReturnNode }
{ #category : #'*VMMakerCompatibilityForPharo6-C translation' }
RBReturnNode >> asTranslatorNodeIn: aTMethod [
"Answer a TParseNode subclass equivalent of a return."
| exprTranslation lastExpr |
exprTranslation := value asTranslatorNodeIn: aTMethod.
(value isMessage
and: [value receiver isVariable
and: [value receiver name = 'super'
and: [exprTranslation isStatementList]]]) ifTrue:
["super expansions containing returns are fine, and (as of 6/25/2012 19:27) the last
return is elided from the expansion by TMethod>>superExpansionNodeFor:args:.
So we need to ensure the last expression is a return and simply reuse any other
returns in the expansion."
lastExpr := exprTranslation statements last.
(lastExpr isReturn
or: [lastExpr isReturningIf]) ifFalse:
[exprTranslation statements
at: exprTranslation statements size
put:
(TReturnNode new
setExpression: lastExpr;
comment: self commentOrNil;
yourself)].
^exprTranslation].
^TReturnNode new
setExpression: exprTranslation;
comment: self commentOrNil;
yourself
]