Skip to content

Commit 9934ec8

Browse files
Merge pull request #33 from adri09070/31-fixing-skipping-message-that-puts-nil-on-stack
Fixing skip command so that it leaves the receiver on the stack instead of putting nil on the stack
2 parents ac665c0 + 2d56cfb commit 9934ec8

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

Sindarin-Tests/SindarinDebuggerTest.class.st

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,22 @@ SindarinDebuggerTest >> testSkip [
565565
self assert: a equals: 1.
566566
scdbg skip.
567567
scdbg step.
568-
self assert: p equals: nil
568+
self assert: p equals: Point
569+
]
570+
571+
{ #category : #tests }
572+
SindarinDebuggerTest >> testSkipSkipsMessagesByPuttingReceiverOnStack [
573+
574+
| a scdbg |
575+
a := 1.
576+
scdbg := SindarinDebugger
577+
debug: [ a := a + 2 ].
578+
self assert: a equals: 1.
579+
580+
scdbg skip.
581+
scdbg step.
582+
583+
self assert: a equals: 1
569584
]
570585

571586
{ #category : #tests }
@@ -621,7 +636,7 @@ SindarinDebuggerTest >> testSkipThroughNode [
621636
self assert: realValueOfA equals: 5.
622637
self assert: (dbg temporaryNamed: #a) equals: 1.
623638
self assert: realExecTopStack equals: 3.
624-
self assert: dbg topStack equals: nil
639+
self assert: dbg topStack equals: '3'
625640
]
626641

627642
{ #category : #'tests - skipping' }
@@ -919,5 +934,5 @@ SindarinDebuggerTest >> testskipUpToNodeSkipTargetNode [
919934
returnNode := (self class >> #helperMethod1) ast statements last.
920935
dbg step; skipThroughNode: returnNode.
921936
self assert: dbg node equals: returnNode.
922-
self assert: dbg topStack equals: nil
937+
self assert: dbg topStack equals: Point
923938
]

Sindarin/SindarinDebugger.class.st

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,11 @@ SindarinDebugger >> sindarinSession: aSindarinDebugSession [
524524

525525
{ #category : #'stepping - skip' }
526526
SindarinDebugger >> skip [
527+
527528
"If it is a message send or assignment, skips the execution of the current instruction, and puts nil on the execution stack."
528-
self node isAssignment
529-
ifTrue: [ ^ self skipAssignmentNodeCompletely ].
529+
530+
self node isAssignment ifTrue: [ ^ self skipAssignmentNodeCompletely ].
531+
self node isMessage ifTrue: [ ^ self skipMessageNode ].
530532
self skipWith: nil
531533
]
532534

@@ -564,18 +566,31 @@ SindarinDebugger >> skipAssignmentNodeWith: replacementValue [
564566
stepToFirstInterestingBytecodeIn: self debugSession interruptedProcess
565567
]
566568

569+
{ #category : #'stepping - skip' }
570+
SindarinDebugger >> skipMessageNode [
571+
572+
self node arguments do: [ :arg | self context pop ]. "Pop the arguments of the message send from the context's value stack"
573+
574+
"Increase the pc to go over the message send"
575+
self context pc: self context pc + 1.
576+
"Execute bytecodes the debugger usually executes without stopping the execution (for example popping the return value of the just executed message send if it is not used afterwards)"
577+
self debugSession stepToFirstInterestingBytecodeIn:
578+
self debugSession interruptedProcess
579+
]
580+
567581
{ #category : #'stepping - skip' }
568582
SindarinDebugger >> skipMessageNodeWith: replacementValue [
569-
self node arguments do: [ :arg | self context pop ]. "Pop the arguments of the message send from the context's value stack"
583+
584+
self node arguments do: [ :arg | self context pop ]. "Pop the arguments of the message send from the context's value stack"
570585
"Pop the receiver from the context's value stack"
571586
self context pop.
572587
"Push the replacement value on the context's value stack, to simulate that the message send happened and returned nil"
573588
self context push: replacementValue.
574589
"Increase the pc to go over the message send"
575590
self context pc: self context pc + 1.
576591
"Execute bytecodes the debugger usually executes without stopping the execution (for example popping the return value of the just executed message send if it is not used afterwards)"
577-
self debugSession
578-
stepToFirstInterestingBytecodeIn: self debugSession interruptedProcess
592+
self debugSession stepToFirstInterestingBytecodeIn:
593+
self debugSession interruptedProcess
579594
]
580595

581596
{ #category : #'stepping - skip' }

0 commit comments

Comments
 (0)