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.54 date: 2017/02/22 18:10:07
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:

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

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

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



ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Mon, 19 Nov 2018 09:15:55 GMT