eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'BlockNode':

Home

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

Class: BlockNode


Inheritance:

   Object
   |
   +--ParseNode
      |
      +--BlockNode
         |
         +--JavaScriptParser::InnerJavaBlockNode

Package:
stx:libcomp
Category:
System-Compiler-Support
Version:
rev: 1.110 date: 2024/02/28 09:59:43
user: cg
file: BlockNode.st directory: libcomp
module: stx stc-classLibrary: libcomp

Description:


node for parse-trees, representing blocks
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  arguments: argList home: homeBlock

o  arguments: argList home: homeBlock variables: vars

o  home: homeBlock

o  withExpression: exprNode in: home
a utility function for code generators


Instance protocol:

accessing
o  accessedOuterBlockVars
return a collection of outer blockVars/args which are accessed
in this block

o  arguments

o  arguments: argList

o  blockArgAccessed
return true if any block argument is accessed in the block

o  blockArgAccessed: aBoolen
set/clear the flag stating if any block argument is accessed in the block

o  charEndIndex

o  charEndIndex: something

o  charStartIndex

o  charStartIndex: something

o  endLineNumber

o  endLineNumber: aNumber

o  endPointIndex

o  endPointIndex: something

o  firstStatement
sigh - its a linked list

o  home

o  home: aBlock

o  indexOfFirstTemp: index

o  inlineBlock: aBoolean

o  invocationSelector
the selector, by which this block is invoked

o  invokationSelector

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  isInlineBlock

o  lastStatement
sigh - its a linked list

o  lineNumber

o  lineNumber: aNumber

o  lineNumberOfFirstMessage

o  localVariables
for compatibility with JS functions

o  needsHome

o  needsHome: aBoolean

o  nestingLevel

o  possiblyInlined: aBoolean

o  possiblyInlined: aBoolean withSelector: selector

o  statements

o  statements: s

o  variables

o  variables: varList

o  variablesIncludingInlined: forStcCompiledCode
Returns all my local variables including those of block inlined into
the receiver. If `forStcCompiledCode` is true then assume
the code is compiled by stc, otherwise assume the code is
compiled by bytecode compiler

block messages
o  doesNotUnderstand: aMessage
mhmh - a message which I don't understand, but Block implements

code generation
o  checkForSimpleBlockCodeOn: aStream for: aCompiler
simple things can be made cheap blocks right now -
resulting in a simple pushLit instruction ...
Return:
true -- bytecodes are on aStream
aParseNode -- Parsenode creating the cheap block
nil -- cheap block not possible

o  codeForSideEffectOn: aStream inBlock: b for: aCompiler
generate code for this statement - value not needed.
For blocks, no code is generated at all.

o  codeInlineOn: aStream inBlock: b for: aCompiler

o  codeInlineOn: aStream inBlock: b valueNeeded: valueNeeded for: aCompiler
have to move blockvars into surrounding context

o  codeOn: aStream inBlock: b for: aCompiler
if result == true - code is already on aStream

code generation helpers
o  addTempVar
add a temporary variable; return its position (1-based).
Used when a block with args/locals is inlined.

o  removeTempVar
remove a temporary variable

enumerating
o  allMessageSelectorsDo: aBlock
evaluate aBlock for each message-selector sent by this statement and all followup statements

o  allMessagesDo: aBlock
evaluate aBlock for each message-node sent by this statement and all followup statements

o  allSubBlocksDo: aBlock
recursively enumerate all of my subblocks

o  messageSelectorsDo: aBlock
evaluate aBlock for each message-selector sent by this statement and all followup statements

o  messagesDo: aBlock
evaluate aBlock for each message-node sent by this statement and all followup statements

o  nodeDo: anEnumerator
helper for parse tree walking

evaluation
o  evaluateIn: anEnvironment

o  exitWith: something
return via return-statement

o  value
(comment from inherited method)
return the receiver itself.
This allows every object to be used where blocks or valueHolders
are typically used, and allows for valueHolders and blocks to be
used interchangably in some situations.

Time will show, if this is a good idea or leads to sloppy programming
style ... (the idea was borrowed from the Self language).

WARNING: don't 'optimize' away ifXXX: blocks
(i.e. do NOT replace
foo ifTrue:[var1] ifFalse:[var2]
by:
foo ifTrue:var1 ifFalse:var2
)
- the compilers will only generate inline code for the if,
iff the argument(s) are blocks - otherwise, a true send is
generated.
This 'optimization' will work semantically correct,
but execute SLOWER instead.

Using constants (foo ifTrue:1 ifFalse:2) does not introduce a performance penalty.

o  value: anArg

o  value: arg1 value: arg2

o  value: arg1 value: arg2 value: arg3

o  value: arg1 value: arg2 value: arg3 value: arg4

o  valueWithArguments: argArray

o  valueWithOptionalArgument: arg
see comment in #value

o  valueWithOptionalArgument: arg1 and: arg2
see comment in #value

o  wrongNumberOfArguments: numArgsGiven
report that the number of arguments given does not match the number expected

looping
o  whileFalse: aBlock

o  whileTrue: aBlock
evaluate the argument, aBlock while the receiver evaluates to true.

misc
o  rememberOuterBlockVarAccess: aVariableNode

o  rememberSubBlock: aBlockNode

printing & storing
o  printOn: aStream indent: i
(comment from inherited method)
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.

private-accessing
o  setArguments: argList home: h

o  setArguments: argList home: h variables: vars

o  setHome: h

queries
o  argumentCount
ANSI alias for numArgs: return the number of arguments the block represented by myself
expects for evaluation

o  collectBlocksInto: aCollection

o  containsReturn

o  endsWithReturn

o  indexOfFirstTemp

o  isInlinable
return true, if the receiver is inlinable.
For now, do NOT inline a block, if it has args/vars
which are accessed by subblocks, which are themself
not inlinable.
This limitation is needed for the following piece of code to work:
1 to:10 do:[:i |
.... [ something with i ]
]
If this block was inlined, each subblock would get the same i
(which is the old ST/V behavior)

o  isSimpleSendBlockExpression

o  numArgs
return the number of arguments the block represented by myself
expects for evaluation.
Please use argumentCount, which is ANSI

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  numVars
return the number of block local variables.

o  simpleSendBlockExpression
marked as obsolete by exept MBP at 01-12-2021

** This is an obsolete interface - do not use it (it may vanish in future versions) **

statistics
o  modifiedLocalVars

o  rememberLocalModified: name

testing
o  isBlock
a kludge, to have blocknodes mimic blocks

o  isBlockNode

o  isBlockWithArgumentCount: numArgsExpected
a kludge, to have blocknodes mimic blocks

o  isEmptyBlock

o  isInlinedInto: blockNode assumeStcCompiled: assumeStc
Returns true, if the receiver is inlined into given `blockNode`.
If `assumeStc` is true. then assume the code is compiled by stc,
otherwise assume that the code is compiled by the bytecode compiler

o  isJavaScriptBlock

o  isSingleExpressionBlock

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

o  childrenDo: aBlock



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:24:29 GMT