eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ConstantNode':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ConstantNode


Inheritance:

   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

Description:


node for parse-trees, representing literal constants
This is a helper class for the compiler.


Class protocol:

instance creation
o  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

o  type: t value: val from: startPos to: endPos

o  value: val

queries
o  typeOfConstant: anObject
return the constantNode type for an object


Instance protocol:

RBParser compatibility
o  token
for RB compatibility, I implement some of its protocol

accessing
o  lineNumber: ignoredLineNumber
(comment from inherited method)
set linenumber - ignored here

o  originalString

o  originalString: aString
to remember the original string from scanning
(in case of a radix-number or a c-string)

code generation
o  codeForSideEffectOn: aStream inBlock: b for: aCompiler
no code at all

o  codeForSimpleReturnOn: aStream inBlock: b lineNumber: lineNrOrNil for: aCompiler
anything else must be pushed, then top returned

o  codeOn: aStream inBlock: b for: aCompiler
generate code for the constant

o  codeStoreOn: aStream inBlock: codeBlock valueNeeded: valueNeeded for: aCompiler
not sent - parser checks for this

enumerating
o  nodeDo: anEnumerator
helper for parse tree walking

evaluation
o  evaluate
exists for performance only

o  evaluateIn: anEnvironment

o  store: aValue
not reached - parser checks for this

o  value
for compatibility with RB-AST

printing & storing
o  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 ...)

o  printOn: aStream indent: i

queries
o  canReuseAsArg: anotherNode

o  withConstantValueDo: aBlock
return true, if this evaluates to a constant value
and evaluate aBlock with it

testing
o  isConstant

o  isConstantNumber
(comment from inherited method)
return true, if this is a node for a constant number

o  isLiteralArray
(comment from inherited method)
for compatibility with RB-AST

o  isLiteralCString
(comment from inherited method)
for compatibility with RB-AST

visiting
o  acceptVisitor: aVisitor
Double dispatch back to the visitor, passing my type encoded in
the selector (visitor pattern)



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 19 Apr 2024 04:45:54 GMT