|
Class: ConstantNode
Object
|
+--ParseNode
|
+--PrimaryNode
|
+--ConstantNode
|
+--ECompletionConstantNode
|
+--JavaScriptConstantNode
- Package:
- stx:libcomp
- Category:
- System-Compiler-Support
- Version:
- rev:
1.67
date: 2021/11/07 12:24:36
- user: cg
- file: ConstantNode.st directory: libcomp
- module: stx stc-classLibrary: libcomp
node for parse-trees, representing literal constants
This is a helper class for the compiler.
copyrightCOPYRIGHT (c) 1989 by Claus Gittinger
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.
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)
-
radix
-
the constant's original radix;
remembered so that we can prettyprint it later in the same radix
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)
return true, if this is a node for an array constant
-
isLiteralCString
-
(comment from inherited method)
return true, if this is a node for a c-string constant
-
isLiteralEString
-
-
isLiteralIString
-
-
isLiteralRString
-
-
isLiteralString
-
(comment from inherited method)
return true, if this is a node for a string constant
-
isSTXSpecialLiteralString: typeChar
-
visiting
-
acceptVisitor: aVisitor
-
Double dispatch back to the visitor, passing my type encoded in
the selector (visitor pattern)
|