From 6b4de4bcb32c1f67a65ec0d7e06daaf9918eac0a Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Thu, 18 Aug 2022 16:17:30 +0200 Subject: [PATCH 1/6] updating ASTInterpreter and visitors according to nez API for TemporaryVariable and ArgumentVariable --- DebuggableASTInterpreter/DASTInterpreter.class.st | 5 +++++ .../DASTPostOrderTreeVisitor.class.st | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/DebuggableASTInterpreter/DASTInterpreter.class.st b/DebuggableASTInterpreter/DASTInterpreter.class.st index d0970dd..bff841c 100644 --- a/DebuggableASTInterpreter/DASTInterpreter.class.st +++ b/DebuggableASTInterpreter/DASTInterpreter.class.st @@ -310,6 +310,11 @@ DASTInterpreter >> visitArgumentNode: aRBArgumentNode [ self stackPush: (currentContext findVariable: aRBArgumentNode name) ] +{ #category : #visiting } +DASTInterpreter >> visitArgumentVariableNode: aRBVariableNode [ + self visitVariableNode: aRBVariableNode . +] + { #category : #visiting } DASTInterpreter >> visitArrayNode: aRBArrayNode [ | literals size arrayMirror | diff --git a/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st b/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st index 75436db..1716250 100644 --- a/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st +++ b/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st @@ -37,6 +37,12 @@ DASTPostOrderTreeVisitor >> visitArgumentNode: aRBArgumentNode [ ^ stack push: aRBArgumentNode ] +{ #category : #visiting } +DASTPostOrderTreeVisitor >> visitArgumentVariableNode: aRBVariableNode [ + + stack push: aRBVariableNode +] + { #category : #visiting } DASTPostOrderTreeVisitor >> visitArrayNode: aRBArrayNode [ stack push: aRBArrayNode. @@ -138,6 +144,12 @@ DASTPostOrderTreeVisitor >> visitTemporaryNode: aRBTemporaryNode [ stack push: aRBTemporaryNode ] +{ #category : #visiting } +DASTPostOrderTreeVisitor >> visitTemporaryVariableNode: aRBVariableNode [ + + stack push: aRBVariableNode +] + { #category : #visiting } DASTPostOrderTreeVisitor >> visitThisContextNode: aRBThisContextNode [ stack push: aRBThisContextNode From 474dbd3c6efa8a550d614b3e05cbdc87de81f56e Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Tue, 30 Aug 2022 12:08:04 +0200 Subject: [PATCH 2/6] updating ASTInterpreter and ASTPostOrderTreeVisitor according to new AST Visitor API --- .../DASTInterpreter.class.st | 27 +++++++++++++++++ .../DASTPostOrderTreeVisitor.class.st | 29 ++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/DebuggableASTInterpreter/DASTInterpreter.class.st b/DebuggableASTInterpreter/DASTInterpreter.class.st index bff841c..2efd49c 100644 --- a/DebuggableASTInterpreter/DASTInterpreter.class.st +++ b/DebuggableASTInterpreter/DASTInterpreter.class.st @@ -347,6 +347,12 @@ DASTInterpreter >> visitCascadeNode: aRBCascadeNode [ self flag: 'I do nothing'. ] +{ #category : #visiting } +DASTInterpreter >> visitClassVariableNode: aNode [ + + ^ self visitLiteralVariableNode: aNode +] + { #category : #visiting } DASTInterpreter >> visitGlobalNode: aRBGlobalNode [ @@ -354,6 +360,12 @@ DASTInterpreter >> visitGlobalNode: aRBGlobalNode [ ] +{ #category : #visiting } +DASTInterpreter >> visitGlobalVariableNode: aNode [ + + ^ self visitLiteralVariableNode: aNode +] + { #category : #visiting } DASTInterpreter >> visitInstanceVariableNode: aRBInstanceVariableNode [ self stackPush: (self readInstanceVariableNamed: aRBInstanceVariableNode name) @@ -379,6 +391,21 @@ DASTInterpreter >> visitLiteralValueNode: aRBLiteralValueNode [ self visitLiteralNode: aRBLiteralValueNode ] +{ #category : #visiting } +DASTInterpreter >> visitLiteralVariableNode: aNode [ + "to be backward compatible, we visit for Gloabls here (there used to be no difference)" + + ^ self visitGlobalNode: aNode +] + +{ #category : #visiting } +DASTInterpreter >> visitLocalVariableNode: aNode [ + + "call visitTemporaryNode: for backward compatibility" + + ^ self visitTemporaryNode: aNode +] + { #category : #visiting } DASTInterpreter >> visitMessageNode: aRBMessageNode [ | arguments receiver method newContext | diff --git a/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st b/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st index 1716250..4e8af2e 100644 --- a/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st +++ b/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st @@ -67,11 +67,23 @@ DASTPostOrderTreeVisitor >> visitCascadeNode: aRBCascadeNode [ aRBCascadeNode children reverse do: [ :e | e acceptVisitor: self ] ] +{ #category : #visiting } +DASTPostOrderTreeVisitor >> visitClassVariableNode: aNode [ + + ^ self visitLiteralVariableNode: aNode +] + { #category : #visiting } DASTPostOrderTreeVisitor >> visitGlobalNode: aRBGlobalNode [ stack push: aRBGlobalNode ] +{ #category : #visiting } +DASTPostOrderTreeVisitor >> visitGlobalVariableNode: aNode [ + + ^ self visitLiteralVariableNode: aNode +] + { #category : #visiting } DASTPostOrderTreeVisitor >> visitInstanceVariableNode: aRBInstanceVariableNode [ stack push: aRBInstanceVariableNode @@ -95,6 +107,21 @@ DASTPostOrderTreeVisitor >> visitLiteralValueNode: aRBLiteralValueNode [ ^ self visitLiteralNode: aRBLiteralValueNode ] +{ #category : #visiting } +DASTPostOrderTreeVisitor >> visitLiteralVariableNode: aNode [ + "to be backward compatible, we visit for Gloabls here (there used to be no difference)" + + ^ self visitGlobalNode: aNode +] + +{ #category : #visiting } +DASTPostOrderTreeVisitor >> visitLocalVariableNode: aNode [ + + "call visitTemporaryNode: for backward compatibility" + + ^ self visitTemporaryNode: aNode +] + { #category : #visiting } DASTPostOrderTreeVisitor >> visitMessageNode: aRBMessageNode [ @@ -139,7 +166,7 @@ DASTPostOrderTreeVisitor >> visitSuperNode: aRBSuperNode [ ^ stack push: aRBSuperNode ] -{ #category : #'as yet unclassified' } +{ #category : #visiting } DASTPostOrderTreeVisitor >> visitTemporaryNode: aRBTemporaryNode [ stack push: aRBTemporaryNode ] From 91d5689100516379577dcfb0bfb45da09d3e488e Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Tue, 6 Sep 2022 16:45:29 +0200 Subject: [PATCH 3/6] removing deprecated spec-debugger dependency + adding espell dependency to the baseline --- ...aselineOfDebuggableASTInterpreter.class.st | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/BaselineOfDebuggableASTInterpreter/BaselineOfDebuggableASTInterpreter.class.st b/BaselineOfDebuggableASTInterpreter/BaselineOfDebuggableASTInterpreter.class.st index 442f871..803bc35 100644 --- a/BaselineOfDebuggableASTInterpreter/BaselineOfDebuggableASTInterpreter.class.st +++ b/BaselineOfDebuggableASTInterpreter/BaselineOfDebuggableASTInterpreter.class.st @@ -8,27 +8,28 @@ Class { BaselineOfDebuggableASTInterpreter >> baseline: spec [ - spec - for: #common - do: [ - "Dependencies" - spec - baseline: 'SpecDebugger' - with: [ spec repository: 'github://dupriezt/Spec-Debugger' ]. - spec - baseline: 'Ghost' - with: [ spec repository: 'gitlab://gitlab.inria.fr:RMOD/Ghost' ]. - - "Packages" - spec - package: 'DebuggableASTInterpreter'; - package: 'DebuggableASTDebugger' with: [ spec requires: #('DebuggableASTInterpreter' 'SpecDebugger') ]; - package: 'DebuggableASTInterpreterOverlays' with: [ spec requires: #('DebuggableASTDebugger' 'Ghost') ]]. + spec for: #common do: [ "Dependencies" + spec + baseline: 'Espell' + with: [ spec repository: 'github://guillep/espell' ]. + spec + baseline: 'Ghost' + with: [ spec repository: 'gitlab://gitlab.inria.fr:RMOD/Ghost' ]. + + "Packages" + spec + package: 'DebuggableASTInterpreter' + with: [ spec requires: #( 'Espell' ) ]; + package: 'DebuggableASTDebugger' + with: [ spec requires: #( 'DebuggableASTInterpreter' ) ]; + package: 'DebuggableASTInterpreterOverlays' + with: [ spec requires: #( 'DebuggableASTDebugger' + 'Ghost' ) ] ]. - "Groups" - spec - group: 'default' with: #('Model'); - group: 'Model' with: #('DebuggableASTInterpreter'); - group: 'Debugger' with: #('DebuggableASTDebugger'); - group: 'Overlay' with: #('DebuggableASTInterpreterOverlays') + "Groups" + spec + group: 'default' with: #( 'Model' ); + group: 'Model' with: #( 'DebuggableASTInterpreter' ); + group: 'Debugger' with: #( 'DebuggableASTDebugger' ); + group: 'Overlay' with: #( 'DebuggableASTInterpreterOverlays' ) ] From 21444f567e2f7ef93876ec40cb87243c15f00149 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Fri, 23 Sep 2022 11:05:23 +0200 Subject: [PATCH 4/6] synch with RMODINRIA/DebuggableASTInterpreter --- ...aselineOfDebuggableASTInterpreter.class.st | 21 +++++-------------- .../DASTInterpreter.class.st | 13 ++++++------ .../DASTPostOrderTreeVisitor.class.st | 14 ++++++------- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/BaselineOfDebuggableASTInterpreter/BaselineOfDebuggableASTInterpreter.class.st b/BaselineOfDebuggableASTInterpreter/BaselineOfDebuggableASTInterpreter.class.st index 803bc35..deeab82 100644 --- a/BaselineOfDebuggableASTInterpreter/BaselineOfDebuggableASTInterpreter.class.st +++ b/BaselineOfDebuggableASTInterpreter/BaselineOfDebuggableASTInterpreter.class.st @@ -8,28 +8,17 @@ Class { BaselineOfDebuggableASTInterpreter >> baseline: spec [ - spec for: #common do: [ "Dependencies" - spec - baseline: 'Espell' - with: [ spec repository: 'github://guillep/espell' ]. - spec - baseline: 'Ghost' - with: [ spec repository: 'gitlab://gitlab.inria.fr:RMOD/Ghost' ]. + spec for: #common do: [ "Packages" spec - package: 'DebuggableASTInterpreter' - with: [ spec requires: #( 'Espell' ) ]; - package: 'DebuggableASTDebugger' - with: [ spec requires: #( 'DebuggableASTInterpreter' ) ]; - package: 'DebuggableASTInterpreterOverlays' - with: [ spec requires: #( 'DebuggableASTDebugger' - 'Ghost' ) ] ]. + package: 'DebuggableASTInterpreter'; + package: 'DebuggableASTDebugger' with: [ + spec requires: #( 'DebuggableASTInterpreter' ) ] ]. "Groups" spec group: 'default' with: #( 'Model' ); group: 'Model' with: #( 'DebuggableASTInterpreter' ); - group: 'Debugger' with: #( 'DebuggableASTDebugger' ); - group: 'Overlay' with: #( 'DebuggableASTInterpreterOverlays' ) + group: 'Debugger' with: #( 'DebuggableASTDebugger' ) ] diff --git a/DebuggableASTInterpreter/DASTInterpreter.class.st b/DebuggableASTInterpreter/DASTInterpreter.class.st index 2abbed5..8d9365d 100644 --- a/DebuggableASTInterpreter/DASTInterpreter.class.st +++ b/DebuggableASTInterpreter/DASTInterpreter.class.st @@ -311,8 +311,9 @@ DASTInterpreter >> visitArgumentNode: aRBArgumentNode [ ] { #category : #visiting } -DASTInterpreter >> visitArgumentVariableNode: aRBVariableNode [ - self visitVariableNode: aRBVariableNode . +DASTInterpreter >> visitArgumentVariableNode: aRBVariableNode [ + + ^ self visitTemporaryNode: aRBVariableNode ] { #category : #visiting } @@ -348,9 +349,9 @@ DASTInterpreter >> visitCascadeNode: aRBCascadeNode [ ] { #category : #visiting } -DASTInterpreter >> visitClassVariableNode: aNode [ +DASTInterpreter >> visitClassVariableNode: aRBVariableNode [ - ^ self visitLiteralVariableNode: aNode + ^ self visitGlobalNode: aRBVariableNode ] { #category : #visiting } @@ -361,9 +362,9 @@ DASTInterpreter >> visitGlobalNode: aRBGlobalNode [ ] { #category : #visiting } -DASTInterpreter >> visitGlobalVariableNode: aNode [ +DASTInterpreter >> visitGlobalVariableNode: aRBVariableNode [ - ^ self visitLiteralVariableNode: aNode + ^ self visitGlobalNode: aRBVariableNode ] { #category : #visiting } diff --git a/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st b/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st index 4e8af2e..acc1791 100644 --- a/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st +++ b/DebuggableASTInterpreter/DASTPostOrderTreeVisitor.class.st @@ -40,7 +40,7 @@ DASTPostOrderTreeVisitor >> visitArgumentNode: aRBArgumentNode [ { #category : #visiting } DASTPostOrderTreeVisitor >> visitArgumentVariableNode: aRBVariableNode [ - stack push: aRBVariableNode + ^ self visitTemporaryNode: aRBVariableNode ] { #category : #visiting } @@ -68,9 +68,9 @@ DASTPostOrderTreeVisitor >> visitCascadeNode: aRBCascadeNode [ ] { #category : #visiting } -DASTPostOrderTreeVisitor >> visitClassVariableNode: aNode [ +DASTPostOrderTreeVisitor >> visitClassVariableNode: aRBVariableNode [ - ^ self visitLiteralVariableNode: aNode + ^ self visitGlobalNode: aRBVariableNode ] { #category : #visiting } @@ -79,9 +79,9 @@ DASTPostOrderTreeVisitor >> visitGlobalNode: aRBGlobalNode [ ] { #category : #visiting } -DASTPostOrderTreeVisitor >> visitGlobalVariableNode: aNode [ +DASTPostOrderTreeVisitor >> visitGlobalVariableNode: aRBVariableNode [ - ^ self visitLiteralVariableNode: aNode + ^ self visitGlobalNode: aRBVariableNode ] { #category : #visiting } @@ -172,9 +172,9 @@ DASTPostOrderTreeVisitor >> visitTemporaryNode: aRBTemporaryNode [ ] { #category : #visiting } -DASTPostOrderTreeVisitor >> visitTemporaryVariableNode: aRBVariableNode [ +DASTPostOrderTreeVisitor >> visitTemporaryVariableNode: aRBVariableNode [ - stack push: aRBVariableNode + ^ self visitTemporaryNode: aRBVariableNode ] { #category : #visiting } From fc04a52ac92d208553278560631bb55da345b799 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Thu, 15 Jun 2023 09:21:45 +0200 Subject: [PATCH 5/6] fixing #testGetClassVariableFromMethodInInstanceSide that didn't set the class variable before accessing it --- DebuggableASTInterpreter/DASTInterpreterTests.class.st | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DebuggableASTInterpreter/DASTInterpreterTests.class.st b/DebuggableASTInterpreter/DASTInterpreterTests.class.st index ee27ea3..f7ab861 100644 --- a/DebuggableASTInterpreter/DASTInterpreterTests.class.st +++ b/DebuggableASTInterpreter/DASTInterpreterTests.class.st @@ -261,8 +261,13 @@ DASTInterpreterTests >> testFalse [ { #category : #'tests-variables-class' } DASTInterpreterTests >> testGetClassVariableFromMethodInInstanceSide [ - self assert: (self evaluateProgram: 'DASTInterpreterClassForTests3 new getClassVariable' ) - equals: 42 + + | value | + value := DASTInterpreterClassForTests3 new getClassVariable. + self + assert: (self evaluateProgram: + 'DASTInterpreterClassForTests3 new getClassVariable') + equals: value ] From f779b68bea9f5586d2da5235c3b14d9436f7b9f5 Mon Sep 17 00:00:00 2001 From: adri09070 <97704417+adri09070@users.noreply.github.com> Date: Thu, 15 Jun 2023 09:24:19 +0200 Subject: [PATCH 6/6] setting class variable to nil in a test, to ensure that the setter with DAST is well tested --- .../DASTInterpreterClassForTests3.class.st | 5 +++++ DebuggableASTInterpreter/DASTInterpreterTests.class.st | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DebuggableASTInterpreter/DASTInterpreterClassForTests3.class.st b/DebuggableASTInterpreter/DASTInterpreterClassForTests3.class.st index 35c133d..1342c84 100644 --- a/DebuggableASTInterpreter/DASTInterpreterClassForTests3.class.st +++ b/DebuggableASTInterpreter/DASTInterpreterClassForTests3.class.st @@ -38,3 +38,8 @@ DASTInterpreterClassForTests3 >> initialize [ DASTInterpreterClassForTests3 >> setClassVariable [ classVar := 42 ] + +{ #category : #initialization } +DASTInterpreterClassForTests3 >> setClassVariableToNil [ + classVar := nil +] diff --git a/DebuggableASTInterpreter/DASTInterpreterTests.class.st b/DebuggableASTInterpreter/DASTInterpreterTests.class.st index f7ab861..5002048 100644 --- a/DebuggableASTInterpreter/DASTInterpreterTests.class.st +++ b/DebuggableASTInterpreter/DASTInterpreterTests.class.st @@ -778,10 +778,12 @@ DASTInterpreterTests >> testSendMessageToBlock [ { #category : #'tests-variables-class' } DASTInterpreterTests >> testSetAndGetClassVariableFromMethodInInstanceSide [ "ToDo: reimplement when the environment contains representation of objects" - self assert: (self evaluateProgram: 'DASTInterpreterClassForTests3 new setClassVariable. DASTInterpreterClassForTests3 new getClassVariable' ) - equals: 42 - + DASTInterpreterClassForTests3 new setClassVariableToNil. + self + assert: (self evaluateProgram: + 'DASTInterpreterClassForTests3 new setClassVariable. DASTInterpreterClassForTests3 new getClassVariable') + equals: 42 ] { #category : #'tests-variables-class' }