|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.dms.kjc.EmptyAttributeVisitor
at.dms.kjc.ReplacingVisitor
at.dms.kjc.SLIRReplacingVisitor
at.dms.kjc.sir.lowering.BlockFlattener
public class BlockFlattener
This class flattens nested blocks in methods.
Having single flat blocks for the bodies of methods, and
the branches of ifs, and bodies of fors makes some optimizations
more effective.
BranchAnalyzer
assumes / requires that blocks have been flattenned.
N.B. BlockFlattener does not raise declarations.
BlockFlattener loses scope information -- that is its purpose --
so (like almost all optimization passes) it should not be run before
variables have been renamed to unique names.
Field Summary |
---|
Fields inherited from class at.dms.kjc.EmptyAttributeVisitor |
---|
forwards |
Fields inherited from interface at.dms.kjc.Constants |
---|
CMP_VERSION, JAV_CLASS, JAV_CLONE, JAV_CLONEABLE, JAV_CONSTRUCTOR, JAV_ERROR, JAV_EXCEPTION, JAV_INIT, JAV_LENGTH, JAV_NAME_SEPARATOR, JAV_OBJECT, JAV_OUTER_THIS, JAV_RUNTIME, JAV_RUNTIME_EXCEPTION, JAV_STATIC_INIT, JAV_STRING, JAV_STRINGBUFFER, JAV_THIS, JAV_THROWABLE, OPE_BAND, OPE_BNOT, OPE_BOR, OPE_BSR, OPE_BXOR, OPE_EQ, OPE_GE, OPE_GT, OPE_LE, OPE_LNOT, OPE_LT, OPE_MINUS, OPE_NE, OPE_PERCENT, OPE_PLUS, OPE_POSTDEC, OPE_POSTINC, OPE_PREDEC, OPE_PREINC, OPE_SIMPLE, OPE_SL, OPE_SLASH, OPE_SR, OPE_STAR, TID_ARRAY, TID_BIT, TID_BOOLEAN, TID_BYTE, TID_CHAR, TID_CLASS, TID_DOUBLE, TID_FLOAT, TID_INT, TID_LONG, TID_SHORT, TID_VECTOR, TID_VOID, VECTOR_EMPTY |
Constructor Summary | |
---|---|
BlockFlattener()
|
Method Summary | |
---|---|
void |
flattenBlocks(SIROperator str)
|
Object |
visitBlockStatement(JBlock self,
JavaStyleComment[] comments)
prints an expression statement |
Object |
visitForStatement(JForStatement self,
JStatement init,
JExpression cond,
JStatement incr,
JStatement body)
visits a for statement |
Object |
visitIfStatement(JIfStatement self,
JExpression cond,
JStatement thenClause,
JStatement elseClause)
prints a if statement |
Object |
visitMethodDeclaration(JMethodDeclaration self,
int modifiers,
CType returnType,
String ident,
JFormalParameter[] parameters,
CClassType[] exceptions,
JBlock body)
prints a method declaration |
void |
visitNode(FlatNode node)
The visitor must define this method that will be called once on each FlatNode that is down stream of the accepting node. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BlockFlattener()
Method Detail |
---|
public void visitNode(FlatNode node)
FlatVisitor
visitNode
in interface FlatVisitor
node
- the node that is being currently visited.public void flattenBlocks(SIROperator str)
public Object visitBlockStatement(JBlock self, JavaStyleComment[] comments)
ReplacingVisitor
visitBlockStatement
in interface AttributeVisitor<Object>
visitBlockStatement
in class ReplacingVisitor
public Object visitMethodDeclaration(JMethodDeclaration self, int modifiers, CType returnType, String ident, JFormalParameter[] parameters, CClassType[] exceptions, JBlock body)
visitMethodDeclaration
in interface AttributeVisitor<Object>
visitMethodDeclaration
in class EmptyAttributeVisitor
public Object visitForStatement(JForStatement self, JStatement init, JExpression cond, JStatement incr, JStatement body)
visitForStatement
in interface AttributeVisitor<Object>
visitForStatement
in class ReplacingVisitor
public Object visitIfStatement(JIfStatement self, JExpression cond, JStatement thenClause, JStatement elseClause)
visitIfStatement
in interface AttributeVisitor<Object>
visitIfStatement
in class ReplacingVisitor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |