Skip to content

Commit

Permalink
#write:inContext: is a reflective version of a variable assignment. T…
Browse files Browse the repository at this point in the history
…he value of "var := aValue" is aValue, thus the return of the reflective operation should do the same.

The clients (e.g. tempNamed:put:) show that this is indeed what we should do.
  • Loading branch information
MarcusDenker committed Aug 24, 2020
1 parent 014043b commit 40d3ffb
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/Debugging-Core/Context.extension.st
Expand Up @@ -380,8 +380,7 @@ Context >> tempNamed: aName [
Context >> tempNamed: aName put: anObject [
"Assign the value of the temp with name in aContext"

(self lookupTempVar: aName) write: anObject inContext: self.
^ anObject
^(self lookupTempVar: aName) write: anObject inContext: self
]

{ #category : #'*Debugging-Core' }
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/LiteralVariable.class.st
Expand Up @@ -257,5 +257,5 @@ LiteralVariable >> write: aValue inContext: aContext [
self isWritable ifFalse: [
^self error: 'Variable ' , name, ' is read only'].

value := aValue
^value := aValue
]
2 changes: 1 addition & 1 deletion src/Kernel/Slot.class.st
Expand Up @@ -345,7 +345,7 @@ Slot >> wantsInitialization [

{ #category : #debugging }
Slot >> write: aValue inContext: aContext [
self write: aValue to: aContext receiver
^self write: aValue to: aContext receiver
]

{ #category : #'meta-object-protocol' }
Expand Down
4 changes: 3 additions & 1 deletion src/Kernel/Variable.class.st
Expand Up @@ -303,5 +303,7 @@ Variable >> usingMethods [

{ #category : #debugging }
Variable >> write: aValue inContext: aContext [
self subclassResponsibility
"write the value in aContext. All #write:inContext: methods need to return the assigned value,
as this is the reflective version of assignment which has the assigned value as a value"
^self subclassResponsibility
]
4 changes: 1 addition & 3 deletions src/OpalCompiler-Core/LocalVariable.class.st
Expand Up @@ -277,9 +277,7 @@ LocalVariable >> usingMethods [
{ #category : #debugging }
LocalVariable >> write: aValue inContext: aContext [

| contextScope |
contextScope := aContext astScope.
self writeFromContext: aContext scope: contextScope value: aValue
^self writeFromContext: aContext scope: aContext astScope value: aValue
]

{ #category : #debugging }
Expand Down
3 changes: 1 addition & 2 deletions src/Reflectivity/RFTempWrite.class.st
Expand Up @@ -22,8 +22,7 @@ RFTempWrite >> context: anObject [

{ #category : #evaluating }
RFTempWrite >> value [
variable write: assignedValue inContext: context.
^assignedValue
^variable write: assignedValue inContext: context
]

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion src/Slot-Examples/ExampleSlotWithState.class.st
Expand Up @@ -56,5 +56,5 @@ ExampleSlotWithState >> read: anObject [

{ #category : #'meta-object-protocol' }
ExampleSlotWithState >> write: aValue to: anObject [
value := aValue
^value := aValue
]
2 changes: 1 addition & 1 deletion src/Slot-Examples/ToOneRelationSlot.class.st
Expand Up @@ -29,7 +29,7 @@ ToOneRelationSlot >> updateOld: oldValue new: newValue in: anObject [
{ #category : #'meta-object-protocol' }
ToOneRelationSlot >> write: newValue to: anObject [
self updateOld: (self read: anObject) new: newValue in: anObject.
super write: newValue to: anObject
^super write: newValue to: anObject
]

{ #category : #internal }
Expand Down

0 comments on commit 40d3ffb

Please sign in to comment.