Skip to content

Commit

Permalink
- simplify more
Browse files Browse the repository at this point in the history
- add  writeFromLocalContext: put:
  • Loading branch information
MarcusDenker committed Oct 1, 2019
1 parent 083ac75 commit 167f949
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/OpalCompiler-Core/OCAbstractMethodScope.class.st
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions src/OpalCompiler-Core/OCCopyingTempVariable.class.st
Expand Up @@ -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
]
9 changes: 6 additions & 3 deletions src/OpalCompiler-Core/OCTempVariable.class.st
Expand Up @@ -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
]

0 comments on commit 167f949

Please sign in to comment.