"
COPYRIGHT (c) 1995 by Claus Gittinger
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:#MethodNode
instanceVariableNames:'selector arguments locals statements encoder'
classVariableNames:''
poolDictionaries:''
category:'System-Compiler ST-80-compatibility'
!
!MethodNode class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
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
"
This is a pure mimicri class.
It is not used by ST/X, but provided to support limited
compatibility for applications which build up codetrees,
knowing internals of ST-80's compiler class hierarchy.
This classes protocol is not (not meant to be) fully covering
the corresponding ST-80's classes protocol. It maps ST-80 messages
to corresponding ST/X messages (as far as possible).
NO WARRANTY and GUARANTEE; this class may be removed without notice.
"
! !
!MethodNode methodsFor:'accessing'!
arguments
^ arguments
!
arguments:something
arguments := something.
!
arguments:argVars locals:localVars statements:stats
arguments := argVars.
locals := localVars.
self statements: statements.
"Created: / 06-08-2006 / 03:04:18 / cg"
"Modified: / 09-06-2020 / 14:34:57 / Jan Vrany <jan.vrany@labware.com>"
!
encoder
^ encoder
!
encoder:something
encoder := something.
!
locals
^ locals
!
numArgs
^ arguments size
"Created: / 09-06-2020 / 14:30:41 / Jan Vrany <jan.vrany@labware.com>"
!
selector
^ selector
!
selector:sel
selector := sel.
"Created: / 06-08-2006 / 01:17:42 / cg"
!
selector:sel arguments:argVars locals:localVars statements:stats
selector := sel.
arguments := argVars.
locals := localVars.
self statements: stats.
"Modified: / 09-06-2020 / 14:35:40 / Jan Vrany <jan.vrany@labware.com>"
!
statementCollection
"returns an orderedColl for my linked statement list"
|coll stat|
coll := OrderedCollection new.
stat := statements.
[stat notNil] whileTrue:[
coll add:stat.
stat := stat nextStatement.
].
^ coll
!
statements
^ statements
!
statements:aCollection
statements := aCollection.
statements notEmpty ifTrue:[
statements first parent: self.
].
"Modified: / 09-06-2020 / 14:32:14 / Jan Vrany <jan.vrany@labware.com>"
! !
!MethodNode methodsFor:'code generation'!
codeForSideEffectOn:aStream inBlock:b for:aCompiler
statements do:[:stat |
stat isSequenceable ifTrue:[
stat do:[:eachSubStat |
eachSubStat codeForSideEffectOn:aStream inBlock:nil for:aCompiler
]
] ifFalse:[
stat codeForSideEffectOn:aStream inBlock:nil for:aCompiler
].
].
"Created: / 06-08-2006 / 03:29:54 / cg"
"Modified: / 06-08-2006 / 23:19:01 / cg"
!
emitEffect:aStream
statements do:[:stat |
stat codeForSideEffectOn:aStream inBlock:nil for:nil
].
! !
!MethodNode methodsFor:'debug info'!
dbgVariableTable
"Return a DIVariableTable for this method"
| table |
table := DIVariableTable new.
self dbgVariablesInto:table.
^ table
"Created: / 15-07-2018 / 14:51:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
dbgVariablesInto:aDIVariableTable
"Add a variable table blocks describing this method's variables
and variables of all nested blocks into given `aDIVariableTable`"
arguments ? #()
withIndexDo:[:arg :idx |
aDIVariableTable
addVariableNamed:arg name
isArgument:true
offset:idx
physicalBlock: nil
lexicalBlock: nil
].
locals ? #()
withIndexDo:[:arg :idx |
aDIVariableTable
addVariableNamed:arg name
isArgument:false
offset:arguments size + idx
physicalBlock: nil
lexicalBlock: nil
].
self
blockNodesDo:[:block | block dbgVariablesInto:aDIVariableTable ]
recursively:false.
"Created: / 15-07-2018 / 15:03:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 06-02-2019 / 22:24:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!MethodNode methodsFor:'enumerating'!
childrenDo:aBlock
self statements:statements do:aBlock
! !
!MethodNode methodsFor:'enumeration'!
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.
"
statements notEmpty ifTrue:[
statements first blockNodesDo:aBlock recursively: aBoolean
]
"Created: / 15-07-2018 / 15:50:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 15-07-2018 / 23:57:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 09-06-2020 / 13:57:44 / Jan Vrany <jan.vrany@labware.com>"
! !
!MethodNode methodsFor:'printing'!
printOn:aStream indent:i
|n parts|
selector isNil ifTrue:[
self basicPrintOn:aStream.
^ self.
].
n := selector argumentCount.
n == 0 ifTrue:[
aStream nextPutAll:selector printString.
] ifFalse:[
parts := selector partsIfSelector.
parts with:arguments do:[:part :arg |
aStream nextPutAll:part; space.
aStream nextPutAll:arg name.
aStream space.
]
].
aStream cr.
statements notNil ifTrue:[
statements do:[:stat |
aStream spaces:i+4.
stat printOn:aStream indent:i+4.
aStream nextPut:$..
aStream cr.
].
].
"Modified: / 06-08-2006 / 15:12:15 / cg"
! !
!MethodNode methodsFor:'testing'!
isMethodNode
^ true
! !
!MethodNode class methodsFor:'documentation'!
version
^ '$Header$'
!
version_HG
^ '$Changeset: <not expanded> $'
! !