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.67 date: 2021/11/07 12:24:36
user: cg
file: ConstantNode.st directory: libcomp
module: stx stc-classLibrary: libcomp

Description:


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

copyright

COPYRIGHT (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.

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)

o  radix
the constant's original radix;
remembered so that we can prettyprint it later in the same radix

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)
return true, if this is a node for an array constant

o  isLiteralCString
(comment from inherited method)
return true, if this is a node for a c-string constant

o  isLiteralEString

o  isLiteralIString

o  isLiteralRString

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

o  isSTXSpecialLiteralString: typeChar

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



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 08:43:17 GMT