|
||||||||||
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 | +--at.dms.kjc.CBlockContext
This class represents a local context during checkBody. It follows the control flow and maintain informations about variable (initialized, used, allocated), exceptions (thrown, catched). It also verify that context is still reachable There is a set of utilities method to access fields, methods and class with the name by clamping the parsing tree.
CCompilationUnitContext
,
CClassContext
,
CMethodContext
,
CContext
Fields inherited from class at.dms.kjc.CAbstractBodyContext |
fieldInfo, FLOW_BREAKED, FLOW_CONTINUED, FLOW_INLOOP, FLOW_INSWITCH, FLOW_UNREACHABLE, flowState, throwables, variableInfo |
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 | |
|
CBlockContext(CBodyContext parent)
Construct a block context, it supports local variable allocation throw statement and return statement. |
|
CBlockContext(CBodyContext parent,
int predictedVars)
Construct a block context, it supports local variable allocation throw statement and return statement. |
(package private) |
CBlockContext(CMethodContext parent,
int localVars)
Construct a block context, it supports local variable allocation throw statement and return statement. |
Method Summary | |
void |
addClass(CClass clazz)
addLocalClass |
void |
addOuterThisVariable()
addOuterThisVariable: make room for outerThis variable in a constructor. |
void |
addThisVariable()
addThisVariable: make room for this variable. |
void |
addVariable(JLocalVariable var)
addLocal variable. |
void |
addVariableInfo(int index,
int info)
Adds new assignment info to existing assignment info. |
CBodyContext |
cloneContext()
|
void |
close(TokenReference ref)
Verify everything is okay at the end of this context |
CBodyContext |
createBodyContext()
Creates a new body context with this block context as its parent. |
void |
dereferenceVariable(JLocalVariable var)
Dereference a variable that is not used after (exit block) |
CBlockContext |
getBlockContext()
Returns the nearest block context. |
int |
getMaxLocalsIndex()
The maximum local index for the method in which this is a block. |
int |
getMaxLocalsPosition()
The maximum locals position in the local variables of the bytecode for the method in which this is a block. |
int |
getVariableInfo(int index)
|
CClassType |
lookupClass(java.lang.String name)
lookupClass search for a class with the provided type parameters |
CClass |
lookupLocalClass(java.lang.String ident)
lookupLocalClass |
JLocalVariable |
lookupLocalVariable(java.lang.String ident)
lookupLocalVariable |
void |
shiftLocalsPositions(int shift)
Shifts the positions of the locals in this block. |
Methods inherited from class at.dms.kjc.CContext |
addSourceClass, check, check, check, fail, getClassContext, getCompilationUnit, getCompiler, getMethodContext, getParentContext, 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 |
|
Constructor Detail |
CBlockContext(CMethodContext parent, int localVars)
parent
- The parent context, it must be different than null except if called
by the top level.public CBlockContext(CBodyContext parent)
parent
- The parent context, it must be different than null except if called
by the top level.public CBlockContext(CBodyContext parent, int predictedVars)
parent
- The parent context, it must be different than null except if called
by the top level.Method Detail |
public CBodyContext createBodyContext()
public void close(TokenReference ref)
close
in class CAbstractBodyContext
public CBodyContext cloneContext()
public int getVariableInfo(int index)
getVariableInfo
in class CAbstractBodyContext
var
- the definition of a variablepublic void addVariableInfo(int index, int info)
CAbstractBodyContext
addVariableInfo
in class CAbstractBodyContext
index
- The variable position in method array of local varsinfo
- The 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 addVariable(JLocalVariable var) throws UnpositionedError
var
- the name of the variableinitialized
- is the varaible already initializedUnpositionedError
- this error will be positioned soonpublic void shiftLocalsPositions(int shift)
public JLocalVariable lookupLocalVariable(java.lang.String ident)
lookupLocalVariable
in class CAbstractBodyContext
ident
- the name of the variablepublic void dereferenceVariable(JLocalVariable var)
public void addThisVariable()
public void addOuterThisVariable()
public int getMaxLocalsPosition()
getMaxLocalsPosition
in class CAbstractBodyContext
public int getMaxLocalsIndex()
public CBlockContext getBlockContext()
CContext
getBlockContext
in class CContext
public void addClass(CClass clazz) throws UnpositionedError
clazz
- the clazz to addUnpositionedError
- this error will be positioned soonpublic CClass lookupLocalClass(java.lang.String ident)
ident
- the name of the classpublic CClassType lookupClass(java.lang.String name) throws UnpositionedError
lookupClass
in class CContext
name
- method nameUnpositionedError
- this error will be positioned soon
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |