Skip to content

Commit

Permalink
Merge pull request #6798 from MarcusDenker/Improve-MetaLinks-onVariables
Browse files Browse the repository at this point in the history
Improve-MetaLinks-onVariables
  • Loading branch information
MarcusDenker committed Jul 11, 2020
2 parents 65ff6bd + 22585d5 commit ab58204
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
11 changes: 6 additions & 5 deletions src/Reflectivity-Tests/ReflectivityControlTest.class.st
Expand Up @@ -1020,13 +1020,12 @@ ReflectivityControlTest >> testInsteadClassVariable [
control: #instead.
classVar link: link.
self assert: classVar hasMetalinkInstead.
self
assert:
(ReflectivityExamples >> #exampleClassVarRead) class
equals: ReflectiveMethod.
self assert: tag isNil.
self
assert: ReflectivityExamples new exampleClassVarRead equals: #AClassVar.
assert: (ReflectivityExamples >> #exampleClassVarRead) class
equals: ReflectiveMethod.
self
assert: ReflectivityExamples new exampleClassVarRead class equals: self class.
self assert: tag equals: 'yes'.
self
assert: (ReflectivityExamples >> #exampleClassVarRead) class
Expand Down Expand Up @@ -1190,6 +1189,8 @@ ReflectivityControlTest >> testInsteadVariableReadIvar [
{ #category : #'tests - instead' }
ReflectivityControlTest >> testInsteadVariableReadTemp [
| varNode instance |
self skip.
"skip for now as #usingMethods of the variable gets confused with instead"
varNode := (ReflectivityExamples >> #exampleAssignment) variableReadNodes first.
link := MetaLink new
metaObject: #context;
Expand Down
3 changes: 2 additions & 1 deletion src/Reflectivity-Tests/ReflectivityReificationTest.class.st
Expand Up @@ -1847,7 +1847,8 @@ ReflectivityReificationTest >> testReifyTempOperationAfter [
{ #category : #'tests - operations' }
ReflectivityReificationTest >> testReifyTempOperationInstead [
| varNode instance executed |
self skip. "Skipped for now, seems to have problems with stack balancing leading to strange test failures"
self skip.
"skip for now as #usingMethods of the variable gets confused with instead"
varNode := (ReflectivityExamples >> #exampleAssignment) ast body statements last value.
executed := false.
link := MetaLink new
Expand Down
8 changes: 5 additions & 3 deletions src/Reflectivity/RFASTTranslator.class.st
Expand Up @@ -308,7 +308,9 @@ RFASTTranslator >> visitVariableNode: aVariableNode [
{ #category : #reflectivity }
RFASTTranslator >> visitVariableValue: aVariable [
self emitPreamble: aVariable.
self emitMetaLinkBefore: aVariable.
aVariable emitValue: methodBuilder.
self emitMetaLinkAfterNoEnsure: aVariable
self emitMetaLinkBefore: aVariable.
aVariable hasMetalinkInstead
ifTrue: [self emitMetaLinkInstead: aVariable]
ifFalse: [aVariable emitValue: methodBuilder].
self emitMetaLinkAfterNoEnsure: aVariable.
]
6 changes: 1 addition & 5 deletions src/Reflectivity/RFSemanticAnalyzer.class.st
Expand Up @@ -113,9 +113,5 @@ RFSemanticAnalyzer >> visitVarWrite: aNode [
{ #category : #visiting }
RFSemanticAnalyzer >> visitVariableNode: aVariableNode [
super visitVariableNode: aVariableNode.
self flag: #pharoTodo. "needs to be extendend to other kinds of variables and cleaned"
aVariableNode isGlobal ifTrue: [
self analyseForLinksForVariables: aVariableNode ].
(aVariableNode isInstance) ifTrue: [
self analyseForLinksForVariables: aVariableNode ]
self analyseForLinksForVariables: aVariableNode
]
17 changes: 8 additions & 9 deletions src/Reflectivity/Variable.extension.st
Expand Up @@ -84,20 +84,19 @@ Variable >> insteadLinks [
^ self links select: [ :each | each control == #instead ]
]

{ #category : #'*Reflectivity' }
Variable >> invalidate [
self usingMethods do: [:method | method invalidate].
]

{ #category : #'*Reflectivity' }
Variable >> link: aMetaLink [
| methods |
(aMetaLink checkForCompatibilityWith: self) ifFalse: [ self error: 'link requests reification that can not be provided by this node' ].

methods := self usingMethods.
(self propertyAt: #links ifAbsentPut: [ OrderedCollection new ]) add: aMetaLink.
aMetaLink installOnVariable: self.
methods
do: [ :method |
method
createTwin;
invalidate.
method installLink: aMetaLink ]
self clearReflectivityAnnotations.
self usingMethods do: [ :method |
method method installLink: aMetaLink ]
]

{ #category : #'*Reflectivity' }
Expand Down

0 comments on commit ab58204

Please sign in to comment.