BreakpointNode.st
author Jan Vrany <jan.vrany@labware.com>
Thu, 27 Oct 2022 14:53:59 +0100
branchjv
changeset 4735 3b11fb3ede98
parent 4723 524785227024
permissions -rw-r--r--
Allow single underscore as method / block argument and temporaries This commit is a follow up for 38b221e.

"
 COPYRIGHT (c) 2006 by eXept Software AG
 COPYRIGHT (c) 2020 LabWare
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libcomp' }"

"{ NameSpace: Smalltalk }"

ParseNode subclass:#BreakpointNode
	instanceVariableNames:'breakpoint expression lineNumber'
	classVariableNames:''
	poolDictionaries:''
	category:'System-Compiler-Debugging'
!

!BreakpointNode class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2006 by eXept Software AG
 COPYRIGHT (c) 2020 LabWare
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    compiler support for statement breakpoints.
"
! !

!BreakpointNode methodsFor:'accessing'!

breakpoint
    ^ breakpoint
!

breakpoint:something
    breakpoint := something.
!

endPosition
    ^ expression endPosition
!

expression
    ^ expression
!

expression: aParseNode
    expression := aParseNode.
    expression parent: self

    "Modified: / 08-08-2020 / 22:46:45 / Jan Vrany <jan.vrany@labware.com>"
!

lineNumber
    ^ lineNumber
!

lineNumber:lineNumberArg
    self assert:(lineNumberArg >= 0).
    lineNumber := lineNumberArg.
!

realNode
    ^ expression
!

selectorPosition
    ^ expression selectorPosition
!

startPosition
    ^ expression startPosition
! !

!BreakpointNode methodsFor:'code generation'!

codeForCascadeOn:aStream inBlock:b for:aCompiler
    |node|

    node := UnaryNode
                receiver: (ConstantNode value: breakpoint)
                selector: #break.
    node lineNumber:lineNumber.
    node codeForSideEffectOn:aStream inBlock:b for:aCompiler.
    expression notNil ifTrue:[
        expression codeForCascadeOn:aStream inBlock:b for:aCompiler
    ].

    "Modified: / 26-03-2018 / 15:39:38 / stefan"
!

codeForSideEffectOn:aStream inBlock:b for:aCompiler
    |node|

    node := UnaryNode
                receiver: (ConstantNode value: breakpoint)
                selector: #break.
    node lineNumber:lineNumber.
    node codeForSideEffectOn:aStream inBlock:b for:aCompiler.
    expression notNil ifTrue:[
        expression codeForSideEffectOn:aStream inBlock:b for:aCompiler
    ].

    "Modified: / 26-03-2018 / 15:39:33 / stefan"
!

codeOn:aStream inBlock:codeBlock for:aCompiler
    |node|

    "/ Transcript showCR:'**** bpCode: %1 expr: %2' with:lineNumber with:expression printString.

    node := UnaryNode
                receiver: (ConstantNode value: breakpoint)
                selector: #break.
    node lineNumber:lineNumber.
    node codeForSideEffectOn:aStream inBlock:codeBlock for:aCompiler.
    expression notNil ifTrue:[
        expression codeOn:aStream inBlock:codeBlock for:aCompiler
    ].

    "Created: / 16-06-2011 / 15:17:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 22-07-2013 / 16:08:34 / cg"
    "Modified: / 26-03-2018 / 15:38:22 / stefan"
! !

!BreakpointNode methodsFor:'enumerating'!

childrenDo:aBlock
    aBlock value:expression
! !

!BreakpointNode methodsFor:'enumeration'!

allSubNodesDo:aBlock
    aBlock value: expression.
    expression allSubNodesDo:aBlock.

    "Created: / 08-08-2020 / 08:45:51 / Jan Vrany <jan.vrany@labware.com>"
!

blockNodesDo:aBlock recursively: aBoolean
    "
    Evaluate `aBlock` for each `BlockNode` in receicer's subtree. 

    If, `aBoolean` is true, then recurse into block nodes themselves, 
    evaluating `aBlock` for (all) nested blocks.
    If `aBoolean` is false, stop at any block node.
    " 
    ^ expression blockNodesDo:aBlock recursively: aBoolean

    "Created: / 08-08-2020 / 08:46:44 / Jan Vrany <jan.vrany@labware.com>"
!

messagesDo:aBlock
    "evaluate aBlock for each message-node here and in subnodes"

    ^ expression messagesDo:aBlock

    "Created: / 08-08-2020 / 08:46:12 / Jan Vrany <jan.vrany@labware.com>"
!

variableNodesDo:aBlock
    "evaluate aBlock for each variable-node here and in subnodes"

    ^ expression variableNodesDo:aBlock

    "Created: / 08-08-2020 / 08:46:24 / Jan Vrany <jan.vrany@labware.com>"
! !

!BreakpointNode methodsFor:'evaluation'!

evaluateIn:anEnvironment
    ^ expression evaluateIn:anEnvironment

    "Created: / 20-02-2019 / 22:17:35 / Claus Gittinger"
! !

!BreakpointNode methodsFor:'node protocol forwarding'!

arg1
    "must forward - otherwise cascades won't work"

    ^ expression arg1
!

args
    "must forward - otherwise keywordExpression won't work"

    ^ expression args
!

argumentCount
    "must forward - otherwise checkCondition won't work"

    ^ expression argumentCount
!

arguments
    "must forward - otherwise cascades won't work"

    ^ expression arguments
!

isMessage
    "must forward - otherwise cascades won't work"

    ^ expression isMessage
!

isUnaryMessage
    "must forward - otherwise cascades won't work"

    ^ expression isUnaryMessage

    "Created: / 26-07-2020 / 18:24:18 / cg"
!

numArgs
    <resource: #obsolete>

    "must forward - otherwise checkCondition won't work.
     Please use argumentCount, which is ANSI"

    ^ expression numArgs
!

plausibilityCheckIn:aParser
    ^ expression plausibilityCheckIn:aParser

    "Created: / 20-11-2016 / 19:17:54 / cg"
!

receiver
    "must forward - otherwise cascades won't work"

    ^ expression receiver
!

selector
    "must forward - otherwise cascades won't work"

    ^ expression selector
! !

!BreakpointNode methodsFor:'printing'!

printOn:aStream indent:indent
    "append a user printed representation of the receiver to aStream.
     The format is suitable for a human - not meant to be read back."

    aStream show:'BP [%1] before: ' with:lineNumber.
    expression printOn:aStream indent:indent.

    "Created: / 06-07-2011 / 14:31:10 / cg"
! !

!BreakpointNode methodsFor:'testing'!

isBreakPointNode
    ^ true

    "Created: / 05-07-2011 / 21:13:52 / cg"
! !

!BreakpointNode class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
!

version_HG

    ^ '$Changeset: <not expanded> $'
!

version_SVN
    ^ '$ Id $'
! !