diff --git a/src/OpalCompiler-Core/OCAbstractMethodScope.class.st b/src/OpalCompiler-Core/OCAbstractMethodScope.class.st index d33c6ee8547..727a560a37c 100644 --- a/src/OpalCompiler-Core/OCAbstractMethodScope.class.st +++ b/src/OpalCompiler-Core/OCAbstractMethodScope.class.st @@ -265,13 +265,11 @@ OCAbstractMethodScope >> removeTemp: tempVar [ { #category : #'temp vars - copying' } OCAbstractMethodScope >> setCopyingTempToAllScopesUpToDefTemp: aVar to: aValue from: aContext [ - | copiedVar | "we need to update all the copies if we change the value of a copied temp" self = aVar scope - ifTrue: [ ^ self ]. - copiedVar := self lookupVar: aVar name. - aContext tempAt: copiedVar indexFromIR put: aValue. + ifTrue: [ ^ aVar writeFromLocalContext: aContext put: aValue ]. + (self lookupVar: aVar name) writeFromLocalContext: aContext put: aValue. self outerScope setCopyingTempToAllScopesUpToDefTemp: aVar to: aValue diff --git a/src/OpalCompiler-Core/OCCopyingTempVariable.class.st b/src/OpalCompiler-Core/OCCopyingTempVariable.class.st index eac6695afa8..89f16c1d356 100644 --- a/src/OpalCompiler-Core/OCCopyingTempVariable.class.st +++ b/src/OpalCompiler-Core/OCCopyingTempVariable.class.st @@ -52,9 +52,6 @@ OCCopyingTempVariable >> tempVectorForTempStoringIt [ { #category : #debugging } OCCopyingTempVariable >> writeFromContext: aContext scope: contextScope value: aValue [ - "we need to change this var all the copies, too" - contextScope setCopyingTempToAllScopesUpToDefTemp: originalVar to: aValue from: aContext. - "the original temp" - ^originalVar writeFromContext: aContext scope: contextScope value: aValue - + "we need to change this var, all the other copies, and the orginal" + contextScope setCopyingTempToAllScopesUpToDefTemp: originalVar to: aValue from: aContext ] diff --git a/src/OpalCompiler-Core/OCTempVariable.class.st b/src/OpalCompiler-Core/OCTempVariable.class.st index 9b60f7888bd..5916b999682 100644 --- a/src/OpalCompiler-Core/OCTempVariable.class.st +++ b/src/OpalCompiler-Core/OCTempVariable.class.st @@ -150,8 +150,11 @@ OCTempVariable >> writeFromContext: aContext scope: contextScope value: aValue [ | definitionContext | definitionContext := contextScope lookupDefiningContextForVariable: self startingFrom: aContext. + self writeFromLocalContext: definitionContext put: aValue +] + +{ #category : #debugging } +OCTempVariable >> writeFromLocalContext: aContext put: aValue [ - ^definitionContext - tempAt: self indexFromIR - put: aValue + ^ aContext tempAt: self indexFromIR put: aValue ]