|
Class: ConstantNode
Object
|
+--ParseNode
|
+--PrimaryNode
|
+--ConstantNode
|
+--ECompletionConstantNode
|
+--JavaScriptConstantNode
- Package:
- stx:libcomp
- Category:
- System-Compiler-Support
- Version:
- rev:
1.57
date: 2019/08/11 12:20:02
- user: cg
- file: ConstantNode.st directory: libcomp
- module: stx stc-classLibrary: libcomp
- Author:
- Claus Gittinger
node for parse-trees, representing literal constants
This is a helper class for the compiler.
instance creation
-
type: t value: val
-
JV@2011-07-19: Changed not to share the nodes
usage example(s):
TrueNode := (self basicNew) type:t value:val
|
usage example(s):
FalseNode := (self basicNew) type:t value:val
|
usage example(s):
NilNode := (self basicNew) type:t value:val
|
usage example(s):
Const0Node := (self basicNew) type:t value:val
|
usage example(s):
Const1Node := (self basicNew) type:t value:val
|
usage example(s):
Float0Node := (self basicNew) type:t value:val
|
usage example(s):
^ (self basicNew) type:t value:val
|
-
type: t value: val from: startPos to: endPos
-
-
value: val
-
queries
-
typeOfConstant: anObject
-
return the constantNode type for an object
RBParser compatibility
-
token
-
for RB compatibility, I implement some of its protocol
accessing
-
lineNumber: ignoredLineNumber
-
(comment from inherited method)
set linenumber - ignored here
-
originalString
-
-
originalString: aString
-
to remember the original string from scanning
(in case of a radix-number or a c-string)
code generation
-
codeForSideEffectOn: aStream inBlock: b for: aCompiler
-
no code at all
-
codeForSimpleReturnOn: aStream inBlock: b lineNumber: lineNrOrNil for: aCompiler
-
anything else must be pushed, then top returned
-
codeOn: aStream inBlock: b for: aCompiler
-
generate code for the constant
-
codeStoreOn: aStream inBlock: codeBlock valueNeeded: valueNeeded for: aCompiler
-
not sent - parser checks for this
enumerating
-
nodeDo: anEnumerator
-
helper for parse tree walking
evaluation
-
evaluate
-
exists for performance only
-
evaluateIn: anEnvironment
-
-
store: aValue
-
not reached - parser checks for this
-
value
-
for compatibility with RB-AST
printing & storing
-
displayOn: aGCOrStream
-
Compatibility
append a printed desription on some stream (Dolphin, Squeak)
OR:
display the receiver in a graphicsContext at 0@0 (ST80).
This method allows for any object to be displayed in some view
(although the fallBack is to display its printString ...)
-
printOn: aStream indent: i
-
queries
-
canReuseAsArg: anotherNode
-
-
withConstantValueDo: aBlock
-
return true, if this evaluates to a constant value
and evaluate aBlock with it
testing
-
isConstant
-
-
isConstantNumber
-
(comment from inherited method)
return true, if this is a node for a constant number
-
isLiteralArray
-
(comment from inherited method)
for compatibility with RB-AST
-
isLiteralCString
-
(comment from inherited method)
for compatibility with RB-AST
visiting
-
acceptVisitor: aVisitor
-
Double dispatch back to the visitor, passing my type encoded in
the selector (visitor pattern)
|