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
public final class ForEachStatement extends LoopStatement implements IForEachStatement
Represents a foreach statement as specified in the Gosu grammar:for...in-statement for ( <identifier> in <expression> [ index <identifier> ] ) <statement>
- See Also:
IGosuParser
-
-
Field Summary
Fields Modifier and Type Field Description protected Expression
_expression
protected Symbol
_identifier
protected Symbol
_indexIdentifier
protected IStackProvider
_stackProvider
protected Statement
_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
Constructors Constructor Description ForEachStatement(ISymbolTable stackProvider)
Constructs a ForEachStatement given an ISymbolTable instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
declares(String identifierName)
Object
execute()
Execute this statement.String[]
getDeclarations()
IExpression
getExpression()
Symbol
getIdentifier()
Symbol
getIndexIdentifier()
Expression
getInExpression()
Symbol
getIteratorIdentifier()
protected ITerminalStatement
getLeastSignificantTerminalStatement_internal(boolean[] bAbsolute)
int
getNameOffset(String identifierName)
The offset of the token representing the name for the declarationStatement
getStatement()
boolean
isStructuralIterable()
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)
String
toString()
Subclasses should return a String representing the parsed statement.-
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 Detail
-
_identifier
protected Symbol _identifier
-
_expression
protected Expression _expression
-
_indexIdentifier
protected Symbol _indexIdentifier
-
_statement
protected Statement _statement
-
_stackProvider
protected IStackProvider _stackProvider
-
-
Constructor Detail
-
ForEachStatement
public ForEachStatement(ISymbolTable stackProvider)
Constructs a ForEachStatement given an ISymbolTable instance.
-
-
Method Detail
-
getIdentifier
public Symbol getIdentifier()
- Specified by:
getIdentifier
in interfaceIForEachStatement
- Returns:
- The name of the Indentifier in the statement.
-
setIdentifier
public void setIdentifier(Symbol identifier)
- Parameters:
identifier
-
-
getIndexIdentifier
public Symbol getIndexIdentifier()
- Specified by:
getIndexIdentifier
in interfaceIForEachStatement
- Returns:
- The name of the Index Identifier, or null of not specified.
-
setIndexIdentifier
public void setIndexIdentifier(Symbol indexIdentifier)
- Parameters:
indexIdentifier
-
-
getIteratorIdentifier
public Symbol getIteratorIdentifier()
- Returns:
- The name of the Index Identifier, or null of not specified.
-
setIteratorIdentifier
public void setIteratorIdentifier(Symbol iterIdentifier)
-
getExpression
public IExpression getExpression()
- Specified by:
getExpression
in interfaceILoopStatement
-
getInExpression
public Expression getInExpression()
- Specified by:
getInExpression
in interfaceIForEachStatement
- Returns:
- The In Expression.
-
setInExpression
public void setInExpression(Expression expression)
- Parameters:
expression
- The In Expression.
-
getStatement
public Statement getStatement()
- Specified by:
getStatement
in interfaceIForEachStatement
- Specified by:
getStatement
in interfaceILoopStatement
- Returns:
- The statement to execute in the interation.
-
setStatement
public void setStatement(Statement statement)
- Parameters:
statement
- The statement to execute in the interation.
-
execute
public Object execute()
Description copied from interface:IStatement
Execute this statement.- Specified by:
execute
in interfaceIStatement
- Overrides:
execute
in classStatement
-
getLeastSignificantTerminalStatement_internal
protected ITerminalStatement getLeastSignificantTerminalStatement_internal(boolean[] bAbsolute)
- Specified by:
getLeastSignificantTerminalStatement_internal
in classStatement
-
toString
public String toString()
Description copied from class:Statement
Subclasses should return a String representing the parsed statement.
-
getNameOffset
public int getNameOffset(String identifierName)
Description copied from interface:IParsedElementWithAtLeastOneDeclaration
The offset of the token representing the name for the declaration- Specified by:
getNameOffset
in interfaceIParsedElementWithAtLeastOneDeclaration
-
setNameOffset
public void setNameOffset(int iOffset, String identifierName)
- Specified by:
setNameOffset
in interfaceIParsedElementWithAtLeastOneDeclaration
-
setIndexNameOffset
public void setIndexNameOffset(int iOffset)
-
setIterNameOffset
public void setIterNameOffset(int iOffset)
-
declares
public boolean declares(String identifierName)
- Specified by:
declares
in interfaceIParsedElementWithAtLeastOneDeclaration
- Returns:
- True if this statement declares the given identifier; false otherwise
-
getDeclarations
public String[] getDeclarations()
- Specified by:
getDeclarations
in interfaceIParsedElementWithAtLeastOneDeclaration
- Returns:
- all names declared by this element
-
isStructuralIterable
public boolean isStructuralIterable()
-
setStructuralIterable
public void setStructuralIterable(boolean bStructuralIterable)
-
-