|
Class: RBProgramNode
Object
|
+--RBProgramNode
|
+--RBMethodNode
|
+--RBPragmaNode
|
+--RBSequenceNode
|
+--RBStatementNode
- Package:
- stx:goodies/refactoryBrowser/parser
- Category:
- Refactory-AST-Nodes
- Version:
- rev:
1.131
date: 2024/03/05 19:02:39
- user: cg
- file: RBProgramNode.st directory: goodies/refactoryBrowser/parser
- module: stx stc-classLibrary: parser
BRProgramNode is an abstract class that represents an abstract syntax tree node in a Smalltalk program.
Subclasses must implement the following messages:
accessing
start
stop
visitor
acceptVisitor:
The #start and #stop methods are used to find the source that corresponds to this node. "source copyFrom: self start to: self stop" should return the source for this node.
The #acceptVisitor: method is used by BRProgramNodeVisitors (the visitor pattern). This will also require updating all the BRProgramNodeVisitors so that they know of the new node.
Subclasses might also want to redefine match:inContext: and copyInContext: to do parse tree searching and replacing.
Subclasses that contain other nodes should override equalTo:withMapping: to compare nodes while ignoring renaming temporary variables, and children that returns a collection of our children nodes.
Instance Variables:
comments <Collection of: Interval> the intervals in the source that have comments for this node
parent <BRProgramNode> the node we're contained in
accessing
-
formatterClass
-
(comment from inherited method)
return a class to use for formatting (prettyPrinting) this class -
this can be redefined in special classes, to format classes with
JavaScript, Ruby, Lisp, Prolog, ASN1, Basic :-) or whatever syntax.
-
formatterClass: aClass
-
-
optimizedSelectors
-
answer the selectors, that are inlined by the compiler
initialization
-
initialize
-
accessing
-
asReturn
-
Change the current node to a return node.
-
blockScope
-
-
children
-
-
comments
-
-
comments: aCollection
-
-
commentsAfter
-
-
commentsAfter: aCollectionOfComments
-
-
commentsBefore
-
-
commentsBefore: aCollectionOfComments
-
'oops - loosing comments before'.
-
endPosition
-
-
formattedCode
-
-
formatterClass
-
-
lineNumber
-
lineNumber isNil ifTrue:[
-
lineNumber: anInteger
-
Modified (format): / 06-03-2012 / 11:13:19 / cg
-
methodScope
-
-
newSource
-
-
originalCode
-
-
originalFormattedCode
-
same as formattedCode, but does not rewrite '_' to ':='
-
parent
-
-
parent: anObject
-
-
parents
-
-
precedence
-
-
removeCommentsAfter
-
occasionally someone wants to move comments from one node to another;
this is a helper to clear the comments in the old node.
(see senders of why this is done)
-
source
-
-
sourceInterval
-
-
start
-
** This method must be redefined in concrete classes (subclassResponsibility) **
-
startWithoutParentheses
-
-
stop
-
** This method must be redefined in concrete classes (subclassResponsibility) **
-
stopPosition
-
-
topNode
-
-
typeInfo
-
this is a hook for the type inferer;
it may attach additional info to a node with this
-
typeInfo: someArbitraryThingy
-
this is a hook for the type inferer;
it may attach additional info to a node with this
comparing
-
equalTo: aNode exceptForVariables: variableNameCollection
-
-
equalTo: aNode withMapping: aDictionary
-
return true, if I am equal to another node, with a given variable name mapping.
-
equalTo: aNode withSelectorMapping: aDictionary
-
return true, if I am equal to another node, with a given selector name mapping.
Side effect: update the mapping dictionary as required to reflect a matching mapping (if possible)
-
semanticallyEqualTo: aNode withMapping: aDictionary
-
return true, if I am semantically equal to another node, with a given variable name mapping.
Semantical equalTo: is defined slightly less strict, than equalTo:.
Both check the parsetree, ignoring formatting and comments.
However, in some situations, semanticallyEqualTo: detects the same intention,
(which is mostly heuristic and builtin knowledge).
For example:
foo isNil ifTrue:e1 ifFalse:e2
is semantcallyEqualTo:
foo notNil ifTrue:e2 ifFalse:e1
and also to:
foo isNil ifFalse:e2 ifTrue:e1
The fallback implemented here is to ask for the regular equality.
Side effect: update the mapping dictionary as required to reflect a matching mapping (if possible)
copying
-
copy
-
This is redefined for IBM Smalltalk which doesn't have postCopy.
-
copyCommentsFrom: aNode
-
Add all comments from aNode to us. If we already have the comment, then don't add it.
copying-private
-
postCopy
-
enumeration
-
allAssignmentNodesDo: aBlock
-
-
allBlockNodesDo: aBlock
-
-
allLiteralNodesDo: aBlock
-
-
allMessageNodesDo: aBlock
-
-
allNonPatternMessageNodesDo: aBlock
-
-
allReturnNodesDo: aBlock
-
-
collect: aBlock
-
Hacked to fit collection protocols
-
detectParentForWhich: aBlock
-
-
do: aBlock
-
Hacked to fit collection protocols
-
size
-
Hacked to fit collection protocols
-
variableNodesDo: aBlock
-
evaluate a Block for all variable nodes
iteration
-
nodesDo: aBlock
-
matching
-
copyInContext: aDictionary
-
-
copyList: matchNodes inContext: aDictionary
-
-
match: aNode inContext: aDictionary
-
-
matchList: matchNodes against: programNodes inContext: aDictionary
-
Modified (format): / 05-03-2024 / 12:11:43 / cg
-
matchList: matchNodes index: matchIndex against: programNodes index: programIndex inContext: aDictionary
-
meta variable-accessing
-
cascadeListCharacter
-
-
ignoreInMatchCharacter
-
-
listCharacter
-
-
literalCharacter
-
-
recurseIntoCharacter
-
-
statementCharacter
-
printing
-
printOn: aStream
-
(comment from inherited method)
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.
The default here is to output the receiver's class name.
BUT: this method is heavily redefined for objects which
can print prettier.
querying
-
allAssignmentNodes
-
-
allMessageNodes
-
-
assigns: aVariableName
-
-
bestNodeFor: anInterval
-
-
containedBy: anInterval
-
true if the interval contains me completely
-
containsReturn
-
-
defines: aName
-
-
directlyUses: aNode
-
-
evaluatedFirst: aNode
-
-
firstLineNumber
-
-
hasAssignmentNodes
-
-
hasBlockNodes
-
-
hasFalseValue
-
-
hasReturnNodes
-
-
hasTrueValue
-
-
intersectsInterval: anInterval
-
^(anInterval first between:myStart and:myStop)
-
isChildOf: anotherNode
-
-
isDirectlyUsed
-
This node is directly used as an argument, receiver, or part of an assignment.
-
isEvaluatedFirst
-
Return true if we are the first thing evaluated in this statement.
-
isInsidePatternNode
-
-
isInsideSyntheticMessage
-
-
isLast: aNode
-
-
isLoop
-
-
isReferringToAnExceptionInContext: aSearchDictionary
-
true iff:
(node contains a ref to a global variable or node is a class variable)
and the variable refers to an Exception class (but not a Notification)
-
isSynthetic
-
true if I am a synthetic node (generated from embedded expression strings)
-
lastIsLoop
-
-
lastIsReturn
-
-
lastLineNumber
-
lineNumber isNil ifTrue:[self halt:'should always be non-nil'].
-
reads: aVariableName
-
-
references: aVariableName
-
(comment from inherited method)
return true if the receiver refers to the argument, anObject.
- for debugging only
-
selfMessages
-
warning: returns a string collection because we avoid creating symbols when parsing
-
sentMessages
-
-
statementNode
-
Return your topmost node that is contained by a sequence node.
-
superMessages
-
warning: returns a string collection because we avoid creating symbols when parsing
-
uses: aNode
-
replacing
-
removeDeadCode
-
-
replaceNode: aNode withNode: anotherNode
-
-
replaceWith: aNode
-
searching
-
whichNodeIntersects: anInterval
-
I intersect
-
whichNodeIsContainedBy: anInterval
-
-
whoDefines: aName
-
return the node (blockNode) in which this variable is defined.
(nil if instvar, classvar or global)
special queries
-
addAllCommentsTo: aCollection
-
-
addReferencedVariablesTo: aCollection
-
-
addUsedLiteralsTo: aCollection
-
adds the values of all literals to aCollection
-
addUsedSymbolsTo: aCollection
-
-
allArgumentVariables
-
-
allArgumentVariablesInto: aCollection
-
-
allComments
-
-
allDefinedVariables
-
-
allTemporaryVariables
-
-
allVariablesOnScope
-
-
blockVariables
-
-
detectNodeForWhich: aBlock
-
top level first
-
referencedVariables
-
-
temporaryVariables
-
-
usedLiterals
-
returns a set of the literal values (i.e. not the nodes)
-
usedSymbols
-
returns a set of the symbols used (i.e. not the nodes)
stx:libtool support
-
highlightInCodeView: aCodeView
-
-
leftClickMenuInCodeView: aCodeView
-
-
middleClickMenuInCodeView: aCodeView
-
-
rightClickMenuInCodeView: aCodeView
-
testing
-
isAssignment
-
-
isBlock
-
-
isCascade
-
-
isClassVariableInContext: aSearchDictionary
-
-
isGlobal
-
Return true if the variable node is for
a non-local (not really global), false otherwise.
Actually wrong: also returns true for inst- and class variables
(i.e. anything that is not a block- or method local)
-
isGlobalVariable
-
Return true if the variable node is for
a non-local (not really global), false otherwise.
Actually wrong: also returns true for inst- and class variables
(i.e. anything that is not a block- or method local)
-
isImmediate
-
-
isInstanceVariable
-
-
isKeywordMessage
-
-
isLiteral
-
-
isLiteralArray
-
-
isLiteralByteArray
-
-
isLiteralCharacter
-
-
isLiteralFloat
-
-
isLiteralInteger
-
-
isLiteralNil
-
-
isLiteralNode
-
-
isLiteralNumber
-
-
isLiteralString
-
-
isLiteralSymbol
-
-
isMessage
-
-
isMessageWithSelector: aStringOrSymbol
-
-
isMethod
-
-
isPragma
-
-
isReturn
-
-
isSTXPrimitiveCCode
-
-
isSelf
-
true if I am the self-variable node
-
isSequence
-
-
isSqueakArray
-
-
isSuper
-
-
isSyntheticMessage
-
-
isTemporary
-
Return true if the variable node is for
a temporary variable, false otherwise
-
isUsed
-
Answer true if this node could be used as part of another expression.
For example, you could use the result of this node as a receiver of a message,
an argument, the right part of an assignment, or the return value of a block.
This differs from isDirectlyUsed in that it is conservative since it also includes
return values of blocks.
-
isValue
-
-
isVariable
-
-
isVariableNotInLeftHandSideOfAssignment
-
Returns true iff receiver is variable node but not
in left-hand side of assignment
testing-matching
-
canMatchMethod: aCompiledMethod
-
the original code below iterates over the literals for each tested;
-
isList
-
-
isPatternNode
-
-
recurseInto
-
visitor
-
acceptCommentsAfterVisitor: aVisitor
-
-
acceptCommentsBeforeVisitor: aVisitor
-
-
acceptVisitor: aProgramNodeVisitor
-
(comment from inherited method)
double-dispatch onto a Visitor.
** This method must be redefined in concrete classes (subclassResponsibility) **
AuxInfo
|