Class BlockStatement
- java.lang.Object
-
- org.glassfish.pfl.dynamic.codegen.impl.AttributedObjectBase
-
- org.glassfish.pfl.dynamic.codegen.impl.NodeBase
-
- org.glassfish.pfl.dynamic.codegen.impl.StatementBase
-
- org.glassfish.pfl.dynamic.codegen.impl.BlockStatement
-
- All Implemented Interfaces:
AttributedObject,Node,Statement,CopyInterceptor
- Direct Known Subclasses:
CaseBranch
public class BlockStatement extends StatementBase
Main factory for creating statements. Represents a block of statements which also defines a scope for local variable declarations.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Statement>bodyprivate java.util.Map<java.lang.String,DefinitionStatement>definitionsprivate ExpressionFactoryefactory
-
Constructor Summary
Constructors Constructor Description BlockStatement(Node parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(Visitor visitor)Accept the visitor and allow it to perform actions on this Node.voidaddAssign(Expression left, Expression right)voidaddBreak()Add a break statement to this BlockStatement.ExpressionaddDefinition(Type type, java.lang.String ident, Expression value)voidaddExpression(Expression expr)IfStatementaddIf(Expression cond)voidaddReturn()Add an empty return to this BlockStatement.voidaddReturn(Expression expr)Add a return with an expression to this BlockStatement.SwitchStatementaddSwitch(Expression value)voidaddThrow(Expression expr)TryStatementaddTry()WhileStatementaddWhile(Expression expr)java.util.List<Statement>body()Return the list of Statements in this BlockStatement.private voidcheckSwitchExpressionType(Type type)ExpressionFactoryexprFactory()Return the ExpressionFactory that must be used to create any expressions occuring either in expressions added to the body, or in other statements immediately contained in this BlockStatement.VariablegetVar(java.lang.String ident)Look up the ident to see if it has an associated Variable in this block.booleanisEmpty()Return true iff this BlockStatement contains no local variables or statements.-
Methods inherited from class org.glassfish.pfl.dynamic.codegen.impl.NodeBase
copy, copy, getAncestor, id, parent, parent, postCopy, preCopy, toString
-
Methods inherited from class org.glassfish.pfl.dynamic.codegen.impl.AttributedObjectBase
attributes, get, set
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.glassfish.pfl.dynamic.codegen.impl.AttributedObject
attributes, get, set
-
-
-
-
Field Detail
-
body
private java.util.List<Statement> body
-
efactory
private ExpressionFactory efactory
-
definitions
private java.util.Map<java.lang.String,DefinitionStatement> definitions
-
-
Constructor Detail
-
BlockStatement
BlockStatement(Node parent)
-
-
Method Detail
-
getVar
public Variable getVar(java.lang.String ident)
Look up the ident to see if it has an associated Variable in this block.
-
isEmpty
public boolean isEmpty()
Return true iff this BlockStatement contains no local variables or statements.
-
body
public java.util.List<Statement> body()
Return the list of Statements in this BlockStatement.
-
exprFactory
public ExpressionFactory exprFactory()
Return the ExpressionFactory that must be used to create any expressions occuring either in expressions added to the body, or in other statements immediately contained in this BlockStatement.
-
addBreak
public void addBreak()
Add a break statement to this BlockStatement.
-
addReturn
public void addReturn()
Add an empty return to this BlockStatement. The enclosing MethodGenerator must have a void return type.
-
addReturn
public void addReturn(Expression expr)
Add a return with an expression to this BlockStatement. The enclosing MethodGenerator must have a return type that is assignment compatible with the type of expr.
-
addIf
public IfStatement addIf(Expression cond)
-
addTry
public TryStatement addTry()
-
addThrow
public void addThrow(Expression expr)
-
checkSwitchExpressionType
private void checkSwitchExpressionType(Type type)
-
addSwitch
public SwitchStatement addSwitch(Expression value)
-
addWhile
public WhileStatement addWhile(Expression expr)
-
addExpression
public void addExpression(Expression expr)
-
addAssign
public void addAssign(Expression left, Expression right)
-
addDefinition
public Expression addDefinition(Type type, java.lang.String ident, Expression value)
-
-