Skip to content

Commit

Permalink
factor out binding re-lookup and fix as #lookupAndFixBinding: and cal…
Browse files Browse the repository at this point in the history
…l it at the end of blocks and method on the temp defintion nodes

fixes pharo-project#4641
  • Loading branch information
MarcusDenker committed Sep 18, 2019
1 parent 8435b02 commit e135872
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/OpalCompiler-Core/OCASTClosureAnalyzer.class.st
Expand Up @@ -25,6 +25,14 @@ OCASTClosureAnalyzer >> doRemotes [

]

{ #category : #variables }
OCASTClosureAnalyzer >> lookupAndFixBinding: aVariableNode [
| var |
var := scope lookupVar: aVariableNode name.
aVariableNode binding: var.
^var
]

{ #category : #visiting }
OCASTClosureAnalyzer >> visitArgumentNode: aVariableNode [

Expand All @@ -38,6 +46,7 @@ OCASTClosureAnalyzer >> visitBlockNode: aBlockNode [
scope := aBlockNode scope.
self doRemotes; doCopying.
self visitNode: aBlockNode body.
aBlockNode temporaries do: [ :each | self lookupAndFixBinding: each ].
scope := scope popScope.
]

Expand All @@ -48,6 +57,7 @@ OCASTClosureAnalyzer >> visitMethodNode: aMethodNode [
scope := aMethodNode scope.
self doRemotes; doCopying.
self visitNode: aMethodNode body.
aMethodNode temporaries do: [ :each | self lookupAndFixBinding: each ]
]

{ #category : #visiting }
Expand All @@ -57,8 +67,7 @@ OCASTClosureAnalyzer >> visitVariableNode: aVariableNode [
| var |
aVariableNode adaptToSemanticNode.
aVariableNode isTemp ifFalse: [^self].
var := scope lookupVar: aVariableNode name.
aVariableNode binding: var.
var := self lookupAndFixBinding: aVariableNode.
var isTempVectorTemp ifTrue: [scope addCopyingTempToAllScopesUpToDefVector: var vectorName].
var isCopying ifTrue: [scope addCopyingTempToAllScopesUpToDefTemp: var].
]

0 comments on commit e135872

Please sign in to comment.