Class ForEachStatement
java.lang.Object
gw.internal.gosu.parser.ParsedElement
gw.internal.gosu.parser.Statement
gw.internal.gosu.parser.statements.LoopStatement
gw.internal.gosu.parser.statements.ForEachStatement
- All Implemented Interfaces:
IParsedElement
,IParsedElementWithAtLeastOneDeclaration
,IStatement
,IForEachStatement
,ILoopStatement
Represents a foreach statement as specified in the Gosu grammar:
for...in-statement for ( <identifier> in <expression> [ index <identifier> ] ) <statement>
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class gw.internal.gosu.parser.statements.LoopStatement
LoopStatement.ArrayIterator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
protected Expression
protected Symbol
private int
private int
private int
protected Symbol
private Symbol
protected IStackProvider
protected Statement
Fields inherited from class gw.internal.gosu.parser.Statement
VOID_RETURN_VALUE
Fields inherited from class gw.internal.gosu.parser.ParsedElement
_tokens, UNDEF_FILE, UNDEF_FUNCTION, UNDEF_MODULE
-
Constructor Summary
ConstructorsConstructorDescriptionForEachStatement
(ISymbolTable stackProvider) Constructs a ForEachStatement given an ISymbolTable instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
execute()
Execute this statement.String[]
protected ITerminalStatement
getLeastSignificantTerminalStatement_internal
(boolean[] bAbsolute) int
getNameOffset
(String identifierName) The offset of the token representing the name for the declarationboolean
void
setIdentifier
(Symbol identifier) void
setIndexIdentifier
(Symbol indexIdentifier) void
setIndexNameOffset
(int iOffset) void
setInExpression
(Expression expression) void
setIteratorIdentifier
(Symbol iterIdentifier) void
setIterNameOffset
(int iOffset) void
setNameOffset
(int iOffset, String identifierName) void
setStatement
(Statement statement) void
setStructuralIterable
(boolean bStructuralIterable) toString()
Subclasses should return a String representing the parsed statement.private String
Methods inherited from class gw.internal.gosu.parser.statements.LoopStatement
getArrayComponentType, getArrayLength, isConditionLiteralTrue, isIteratorType, makeIterator
Methods inherited from class gw.internal.gosu.parser.Statement
execute, getExcludedReturnTypeElements, getLeastSignificant, getLeastSignificantTerminalStatement, getReturnType, hasContent, isNoOp, setParent
Methods inherited from class gw.internal.gosu.parser.ParsedElement
addExceptionsFrom, addParseException, addParseException, addParseException, addParseExceptions, addParseIssues, addParseWarning, addParseWarning, addParseWarnings, addToken, adjustColumn, adjustLineNum, assignTokens, clearParseExceptions, clearParseTreeInformation, clearParseWarnings, compactParseTree, findAncestorParsedElementByType, findDeclaringStatement, findLineNumberOfDeclaration, findRootParsedElement, getAnnotations, getColumn, getContainedParsedElementsByType, getContainedParsedElementsByTypes, getContainedParsedElementsByTypesWithIgnoreSet, getEnclosingFeatureInfo, getFunctionName, getGosuClass, getGosuProgram, getImmediateParseIssue, getImmediateParseIssues, getLineNum, getLocation, getModule, getParent, getParseExceptions, getParseIssues, getParseWarnings, getQualifyingEnclosingTypeInfo, getTokens, hasImmediateParseIssue, hasImmediateParseWarning, hasImmediateParseWarnings, hasParseException, hasParseExceptions, hasParseIssue, hasParseIssues, hasParseWarning, hasParseWarnings, initEmptyParseTree, initLocation, isCompileTimeConstant, isSuppressed, isSuppressed, isSynthetic, makeDoubleValue, makeFloatValue, makeInteger, makeLong, removeParseException, removeParseWarning, removeParseWarningRecursively, setGosuProgram, setLineNum, setLocation, setSynthetic, shouldClearParseInfo, visit
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface gw.lang.parser.statements.ILoopStatement
isConditionLiteralTrue
Methods inherited from interface gw.lang.parser.IParsedElement
addExceptionsFrom, addParseException, addParseException, addParseWarning, addParseWarning, clearParseExceptions, clearParseTreeInformation, clearParseWarnings, findAncestorParsedElementByType, findDeclaringStatement, findRootParsedElement, getColumn, getContainedParsedElementsByType, getContainedParsedElementsByTypes, getContainedParsedElementsByTypesWithIgnoreSet, getFunctionName, getGosuClass, getGosuProgram, getImmediateParseIssue, getImmediateParseIssues, getLineNum, getLocation, getModule, getParent, getParseExceptions, getParseIssues, getParseWarnings, getReturnType, getTokens, hasImmediateParseIssue, hasImmediateParseWarnings, hasParseException, hasParseExceptions, hasParseIssue, hasParseIssues, hasParseWarning, hasParseWarnings, isCompileTimeConstant, isSuppressed, isSynthetic, setLocation, setParent, visit
Methods inherited from interface gw.lang.parser.IStatement
execute, getLeastSignificantTerminalStatement, hasContent
-
Field Details
-
_identifier
-
_expression
-
_indexIdentifier
-
_iterIdentifier
-
_statement
-
_stackProvider
-
_iIdentifierOffset
private int _iIdentifierOffset -
_iIndexIdentifierOffset
private int _iIndexIdentifierOffset -
_iIterOffset
private int _iIterOffset -
_bStructuralIterable
private boolean _bStructuralIterable
-
-
Constructor Details
-
ForEachStatement
Constructs a ForEachStatement given an ISymbolTable instance.
-
-
Method Details
-
getIdentifier
- Specified by:
getIdentifier
in interfaceIForEachStatement
- Returns:
- The name of the Indentifier in the statement.
-
setIdentifier
- Parameters:
identifier
-
-
getIndexIdentifier
- Specified by:
getIndexIdentifier
in interfaceIForEachStatement
- Returns:
- The name of the Index Identifier, or null of not specified.
-
setIndexIdentifier
- Parameters:
indexIdentifier
-
-
getIteratorIdentifier
- Returns:
- The name of the Index Identifier, or null of not specified.
-
setIteratorIdentifier
-
getExpression
- Specified by:
getExpression
in interfaceILoopStatement
-
getInExpression
- Specified by:
getInExpression
in interfaceIForEachStatement
- Returns:
- The In Expression.
-
setInExpression
- Parameters:
expression
- The In Expression.
-
getStatement
- Specified by:
getStatement
in interfaceIForEachStatement
- Specified by:
getStatement
in interfaceILoopStatement
- Returns:
- The statement to execute in the interation.
-
setStatement
- Parameters:
statement
- The statement to execute in the interation.
-
execute
Description copied from interface:IStatement
Execute this statement.- Specified by:
execute
in interfaceIStatement
- Overrides:
execute
in classStatement
-
getLeastSignificantTerminalStatement_internal
- Specified by:
getLeastSignificantTerminalStatement_internal
in classStatement
-
toString
Description copied from class:Statement
Subclasses should return a String representing the parsed statement. -
toString
-
getNameOffset
Description copied from interface:IParsedElementWithAtLeastOneDeclaration
The offset of the token representing the name for the declaration- Specified by:
getNameOffset
in interfaceIParsedElementWithAtLeastOneDeclaration
-
setNameOffset
- Specified by:
setNameOffset
in interfaceIParsedElementWithAtLeastOneDeclaration
-
setIndexNameOffset
public void setIndexNameOffset(int iOffset) -
setIterNameOffset
public void setIterNameOffset(int iOffset) -
declares
- Specified by:
declares
in interfaceIParsedElementWithAtLeastOneDeclaration
- Returns:
- True if this statement declares the given identifier; false otherwise
-
getDeclarations
- Specified by:
getDeclarations
in interfaceIParsedElementWithAtLeastOneDeclaration
- Returns:
- all names declared by this element
-
isStructuralIterable
public boolean isStructuralIterable() -
setStructuralIterable
public void setStructuralIterable(boolean bStructuralIterable)
-