|
Class: BlockNode
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
node for parse-trees, representing blocks
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
-
arguments: argList home: homeBlock
-
-
arguments: argList home: homeBlock variables: vars
-
-
home: homeBlock
-
-
withExpression: exprNode in: home
-
a utility function for code generators
accessing
-
accessedOuterBlockVars
-
return a collection of outer blockVars/args which are accessed
in this block
-
arguments
-
-
arguments: argList
-
-
blockArgAccessed
-
return true if any block argument is accessed in the block
-
blockArgAccessed: aBoolen
-
set/clear the flag stating if any block argument is accessed in the block
-
charEndIndex
-
-
charEndIndex: something
-
-
charStartIndex
-
-
charStartIndex: something
-
-
endLineNumber
-
-
endLineNumber: aNumber
-
-
endPointIndex
-
-
endPointIndex: something
-
-
firstStatement
-
sigh - its a linked list
-
home
-
-
home: aBlock
-
-
indexOfFirstTemp: index
-
-
inlineBlock: aBoolean
-
-
invocationSelector
-
the selector, by which this block is invoked
-
invokationSelector
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
isInlineBlock
-
-
lastStatement
-
sigh - its a linked list
-
lineNumber
-
-
lineNumber: aNumber
-
-
lineNumberOfFirstMessage
-
-
localVariables
-
for compatibility with JS functions
-
needsHome
-
-
needsHome: aBoolean
-
-
nestingLevel
-
-
possiblyInlined: aBoolean
-
-
possiblyInlined: aBoolean withSelector: selector
-
-
statements
-
-
statements: s
-
-
variables
-
-
variables: varList
-
-
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
-
doesNotUnderstand: aMessage
-
mhmh - a message which I don't understand, but Block implements
code generation
-
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
-
codeForSideEffectOn: aStream inBlock: b for: aCompiler
-
generate code for this statement - value not needed.
For blocks, no code is generated at all.
-
codeInlineOn: aStream inBlock: b for: aCompiler
-
-
codeInlineOn: aStream inBlock: b valueNeeded: valueNeeded for: aCompiler
-
have to move blockvars into surrounding context
-
codeOn: aStream inBlock: b for: aCompiler
-
if result == true - code is already on aStream
code generation helpers
-
addTempVar
-
add a temporary variable; return its position (1-based).
Used when a block with args/locals is inlined.
-
removeTempVar
-
remove a temporary variable
enumerating
-
allMessageSelectorsDo: aBlock
-
evaluate aBlock for each message-selector sent by this statement and all followup statements
-
allMessagesDo: aBlock
-
evaluate aBlock for each message-node sent by this statement and all followup statements
-
allSubBlocksDo: aBlock
-
recursively enumerate all of my subblocks
-
messageSelectorsDo: aBlock
-
evaluate aBlock for each message-selector sent by this statement and all followup statements
-
messagesDo: aBlock
-
evaluate aBlock for each message-node sent by this statement and all followup statements
-
nodeDo: anEnumerator
-
helper for parse tree walking
evaluation
-
evaluateIn: anEnvironment
-
-
exitWith: something
-
return via return-statement
-
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.
-
value: anArg
-
-
value: arg1 value: arg2
-
-
value: arg1 value: arg2 value: arg3
-
-
value: arg1 value: arg2 value: arg3 value: arg4
-
-
valueWithArguments: argArray
-
-
valueWithOptionalArgument: arg
-
see comment in #value
-
valueWithOptionalArgument: arg1 and: arg2
-
see comment in #value
-
wrongNumberOfArguments: numArgsGiven
-
report that the number of arguments given does not match the number expected
looping
-
whileFalse: aBlock
-
-
whileTrue: aBlock
-
evaluate the argument, aBlock while the receiver evaluates to true.
misc
-
rememberOuterBlockVarAccess: aVariableNode
-
-
rememberSubBlock: aBlockNode
-
printing & storing
-
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
-
setArguments: argList home: h
-
-
setArguments: argList home: h variables: vars
-
-
setHome: h
-
queries
-
argumentCount
-
ANSI alias for numArgs: return the number of arguments the block represented by myself
expects for evaluation
-
collectBlocksInto: aCollection
-
-
containsReturn
-
-
endsWithReturn
-
-
indexOfFirstTemp
-
-
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)
-
isSimpleSendBlockExpression
-
-
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) **
-
numVars
-
return the number of block local variables.
-
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
-
modifiedLocalVars
-
-
rememberLocalModified: name
-
testing
-
isBlock
-
a kludge, to have blocknodes mimic blocks
-
isBlockNode
-
-
isBlockWithArgumentCount: numArgsExpected
-
a kludge, to have blocknodes mimic blocks
-
isEmptyBlock
-
-
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
-
isJavaScriptBlock
-
-
isSingleExpressionBlock
-
visiting
-
acceptVisitor: aVisitor
-
Double dispatch back to the visitor, passing my type encoded in
the selector (visitor pattern)
-
childrenDo: aBlock
-
|