|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--at.dms.util.Utils | +--at.dms.kjc.CContext | +--at.dms.kjc.CAbstractBodyContext
Abstract base class for different BodyContexts. It follows the control flow and maintains assignment information about local variables and fields, which uncaught exceptions can occur at each point in the block. It also verify that code is still reachable.
CContext
,
CCompilationUnitContext
,
CClassContext
,
CMethodContext
,
CConstructorContext
,
CInitializerContext
,
CBodyContext
,
CBlockContext
Field Summary | |
protected CVariableInfo |
fieldInfo
Field assignment information. |
static int |
FLOW_BREAKED
Control flow is breaked from this point on. |
static int |
FLOW_CONTINUED
Control flow is continued from this point on. |
static int |
FLOW_INLOOP
Control flow is inside a loop construct. |
static int |
FLOW_INSWITCH
Control flow is inside a switch construct. |
static int |
FLOW_UNREACHABLE
Code Unreachable at this point in control flow. |
protected int |
flowState
Control flow analysis info. |
protected java.util.Set |
throwables
Exceptions that can be thrown from this at a point in the source code. |
protected CVariableInfo |
variableInfo
Local variable assignment information. |
Fields inherited from class at.dms.kjc.CContext |
cunit, parent |
Fields inherited from class at.dms.util.Utils |
DBG_LEVEL_HIGH, DBG_LEVEL_LOW, DBG_LEVEL_NO |
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_BOOLEAN, TID_BYTE, TID_CHAR, TID_CLASS, TID_DOUBLE, TID_FLOAT, TID_INT, TID_LONG, TID_SHORT, TID_VOID |
Constructor Summary | |
protected |
CAbstractBodyContext(CAbstractBodyContext parent)
Construct a block context, it supports local variable allocation throw statement and return statement. |
protected |
CAbstractBodyContext(CMethodContext parent)
Construct a block context, it supports local variable allocation throw statement and return statement. |
Method Summary | |
void |
addBreak()
Makes code in this flow unreachable after this point, and marks the flow as "breaked". |
void |
addBreak(JStatement breakTo,
CBodyContext from)
Adds a break from within this context to the specified statement. |
void |
addContinue()
Makes code in this flow unreachable after this point, and marks the flow as "continued". |
void |
addContinue(JStatement continueTo,
CBodyContext from)
Adds a continue from within this context to the specified statement. |
void |
addFieldInfo(int index,
int info)
Adds new assignment info to existing assignment info. |
protected void |
addForwardedBreak(JStatement breakTo,
CBodyContext from)
Adds a break from within this context to the specified statement. |
protected void |
addForwardedContinue(JStatement continueTo,
CBodyContext from)
Adds a continue from within this context to the specified statement. |
void |
addReturn()
Makes code in this flow unreachable after this point. |
void |
addThrowable(CThrowableInfo throwable)
Adds one throwable to the set that can be thrown from this context. |
void |
addThrowables(java.util.Set newThrowables)
Adds throwables to the set that can be thrown from this context. |
void |
addVariableInfo(int index,
int info)
Adds new assignment info to existing assignment info. |
void |
close(TokenReference ref)
Verify everything is okay at the end of this context. |
int |
getFieldInfo(int index)
|
int |
getFlowState()
Return the current flow state. |
JLabeledStatement |
getLabeledStatement(java.lang.String label)
Returns the statement with the specified label. |
int |
getMaxLocalsPosition()
... |
JStatement |
getNearestBreakableStatement()
Returns the nearest breakable statement. |
JStatement |
getNearestContinuableStatement()
Returns the nearest continuable statement. |
java.util.Set |
getThrowables()
|
int |
getVariableInfo(int index)
|
void |
informParent()
Verify everything is okay at the end of this context. |
boolean |
isBreaked()
Returns true if current point in control flow is after a break statement. |
boolean |
isContinued()
Returns true if current point in control flow is after a continue statement. |
boolean |
isInLoop()
Returns true if current control flow is inside a loop construct. |
boolean |
isReachable()
Returns true if current point in control flow is ever reachable. |
CField |
lookupField(java.lang.String ident)
lookupField |
JLocalVariable |
lookupLocalVariable(java.lang.String ident)
lookupLocalVariable |
JExpression |
lookupOuterLocalVariable(TokenReference ref,
java.lang.String ident)
lookupOuterLocalVariable |
void |
setFieldInfo(int index,
int info)
Replaces old assignment info with new info. |
void |
setReachable(boolean reachable)
Returns true if current control flow is ever reachable. |
void |
setVariableInfo(int index,
int info)
Replaces old assignment info with new info. |
Methods inherited from class at.dms.kjc.CContext |
addSourceClass, check, check, check, fail, getBlockContext, getClassContext, getCompilationUnit, getCompiler, getMethodContext, getParentContext, lookupClass, lookupMethod, reportTrouble |
Methods inherited from class at.dms.util.Utils |
assert, assert, fail, fail, hasFlag, hasMoreThanOneFlag, hasOtherFlags, splitQualifiedName, splitQualifiedName, vectorToArray, vectorToIntArray |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final int FLOW_UNREACHABLE
public static final int FLOW_BREAKED
public static final int FLOW_CONTINUED
public static final int FLOW_INLOOP
public static final int FLOW_INSWITCH
FLOW_INLOOP
protected int flowState
protected CVariableInfo variableInfo
protected CVariableInfo fieldInfo
protected java.util.Set throwables
Constructor Detail |
protected CAbstractBodyContext(CAbstractBodyContext parent)
parent
- The parent context, it must be different than null except if called by
the top level.protected CAbstractBodyContext(CMethodContext parent)
parent
- The parent context, it must be different than null except if called by
the top level.Method Detail |
public void close(TokenReference ref)
public void informParent()
public final void addBreak(JStatement breakTo, CBodyContext from) throws PositionedError
public final void addContinue(JStatement continueTo, CBodyContext from) throws PositionedError
protected void addForwardedBreak(JStatement breakTo, CBodyContext from) throws PositionedError
protected void addForwardedContinue(JStatement continueTo, CBodyContext from) throws PositionedError
public boolean isInLoop()
public void setReachable(boolean reachable)
public void addReturn()
public void addBreak()
public void addContinue()
public boolean isReachable()
public boolean isBreaked()
public boolean isContinued()
public int getFlowState()
public int getMaxLocalsPosition()
public JLabeledStatement getLabeledStatement(java.lang.String label)
public JStatement getNearestBreakableStatement()
public JStatement getNearestContinuableStatement()
public void addVariableInfo(int index, int info)
index
- The variable position in method array of local vars.info
- The assignment information to set.
We make it a local copy of this information and at the end of this
context we will transfer it to the parent context according to
controlFlow.public void setVariableInfo(int index, int info)
index
- The variable position in method array of local vars.info
- The assignment information to set.
We make it a local copy of this information and at the end of this
context we will transfer it to the parent context according to
controlFlow.public int getVariableInfo(int index)
var
- the definition of a variablepublic void addFieldInfo(int index, int info)
addFieldInfo
in class CContext
index
- The field position.info
- The assignment information to add.
We make it a local copy of this information and at the end of this
context we will transfert it to the parent context according to
controlFlow.public void setFieldInfo(int index, int info)
index
- The field position.info
- The assignment information to set.
We make it a local copy of this information and at the end of this
context we will transfert it to the parent context according to
controlFlow.public int getFieldInfo(int index)
getFieldInfo
in class CContext
var
- the definition of a fieldpublic CField lookupField(java.lang.String ident) throws UnpositionedError
lookupField
in class CContext
ident
- the name of the fieldUnpositionedError
- this error will be positioned soonpublic JLocalVariable lookupLocalVariable(java.lang.String ident)
lookupLocalVariable
in class CContext
ident
- the name of the variablepublic JExpression lookupOuterLocalVariable(TokenReference ref, java.lang.String ident)
ident
- the name of the variablepublic void addThrowable(CThrowableInfo throwable)
throwable
- The type of the new throwable.public void addThrowables(java.util.Set newThrowables)
public java.util.Set getThrowables()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |