File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -958,6 +958,27 @@ DebugInfoTest >> testReadOuterBlockCopiedTemporaryVariableFromClosure [
958958 self assert: debugInfo notNil
959959]
960960
961+ { #category : ' tests - read variables' }
962+ DebugInfoTest >> testReadOuterBlockCopiedTemporaryVariableFromClosureWithDeadOuter [
963+ " This test is tricky.
964+
965+ This is a variation of testReadOuterBlockCopiedTemporaryVariableFromClosure where the outer context is dead.
966+ The value was copied into the current context so, we should be able to read it!
967+ "
968+
969+ | debugInfo context |
970+ context := [ :blockArgument |
971+ | tempInBlock |
972+ tempInBlock := 42 .
973+ [ " tempInBlock is candidate to be copied in the block activation"
974+ tempInBlock.
975+
976+ thisContext copy ] value ] value: 7 .
977+
978+ debugInfo := self newDebugInfoFor: context method.
979+ self assert: (debugInfo readVariableNamed: #tempInBlock fromContext: context) equals: 42
980+ ]
981+
961982{ #category : ' tests - read variables' }
962983DebugInfoTest >> testReadOuterBlockTempVectorTemporaryVariableFromClosure [
963984 " This test is tricky.
Original file line number Diff line number Diff line change @@ -87,9 +87,10 @@ OnlineSourceDebugInfo >> asOfflineDebugInfo [
8787
8888 scopes := Dictionary new .
8989 astScopes do: [ :astScope |
90- | cachedScope tempDescriptions |
90+ | onlineScope cachedScope tempDescriptions |
91+ onlineScope := OnlineSourceDebugScope on: astScope.
9192 cachedScope := OfflineSourceDebugScope new .
92- tempDescriptions := astScope allTemps collect: [ :temp |
93+ tempDescriptions := onlineScope variables collect: [ :temp |
9394 temp descriptionArrayForScope: astScope ].
9495 (astScope isBlockScope and : [ astScope isOptimized ])
9596 ifTrue: [
Original file line number Diff line number Diff line change @@ -61,5 +61,12 @@ OnlineSourceDebugScope >> variableNames [
6161{ #category : ' accessing' }
6262OnlineSourceDebugScope >> variables [
6363
64- ^ astScope allTemps
64+ " Consider copied vars first.
65+ They override variables from the scope"
66+ | vars |
67+ vars := astScope copiedVars copy.
68+ astScope allTemps do: [ :e |
69+ vars at: e name ifAbsentPut: e.
70+ ].
71+ ^ vars values
6572]
You can’t perform that action at this time.
0 commit comments