|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.dms.util.Utils
at.dms.kjc.CContext
public abstract class CContext
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
CContext
,
CCompilationUnitContext
,
CClassContext
,
CMethodContext
,
CBodyContext
,
CBlockContext
,
Serialized FormField Summary | |
---|---|
protected CContext |
parent
|
Fields inherited from class at.dms.util.Utils |
---|
EMPTY_LIST, getForLoopCallers |
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 | |
---|---|
protected |
CContext()
|
protected |
CContext(CContext parent)
Construct a block context, it supports local variable allocation throw statement and return statement |
Method Summary | |
---|---|
void |
addSourceClass(CSourceClass clazz)
Adds a class to generate. |
void |
check(boolean assertion,
MessageDescription description)
Verifies an assertion. |
void |
check(boolean assertion,
MessageDescription description,
Object parameter1)
Verifies an assertion. |
void |
check(boolean assertion,
MessageDescription description,
Object[] parameters)
Verifies an assertion. |
void |
check(boolean assertion,
MessageDescription description,
Object parameter1,
Object parameter2)
Verifies an assertion. |
Object |
deepClone()
Returns a deep clone of this object. |
protected void |
deepCloneInto(CContext other)
Clones all fields of this into |
void |
dumpContext(int level)
Dumps this context to standard error stream. |
void |
dumpContext(String text)
Dumps this context to standard error stream. |
void |
dumpIndent(int level)
|
void |
fail(MessageDescription description,
Object[] parameters)
Throws a semantic error detected during analysis. |
void |
fail(MessageDescription description,
Object parameter1,
Object parameter2)
Signals a semantic error detected during analysis. |
CBlockContext |
getBlockContext()
Returns the nearest block context (Where yuo can define some local vars) |
CClassContext |
getClassContext()
getClassContext |
CCompilationUnitContext |
getCompilationUnitContext()
|
CVariableInfo |
getFieldInfo()
Returns the field definition state. |
int |
getFieldInfo(int index)
|
CMethodContext |
getMethodContext()
getMethod |
CContext |
getParentContext()
getParentContext |
boolean |
isStaticContext()
JLS 8.1.2: A statement or expression occurs in a static context if and only if the innermost method, constructor, instance initializer, static initializer, field initializer, or explicit constructor statement enclosing the statement or expression is a static method, a static initializer, the variable initializer of a static variable, or an explicit constructor invocation statement |
CClassType |
lookupClass(CClass caller,
String name)
lookupClass search for a class with the provided type parameters |
CField |
lookupField(CClass caller,
String ident)
Searches the class or interface to locate declarations of fields that are accessible. |
JLocalVariable |
lookupLocalVariable(String ident)
lookupLocalVariable |
CMethod |
lookupMethod(CClass caller,
String ident,
CType[] actuals)
JLS 15.12.2 : Searches the class or interface to locate method declarations that are both applicable and accessible, that is, declarations that can be correctly invoked on the given arguments. |
void |
reportTrouble(PositionedError trouble)
Reports a semantic error detected during analysis. |
void |
setFieldInfo(int index,
int info)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected CContext parent
Constructor Detail |
---|
protected CContext()
protected CContext(CContext parent)
parent
- the parent context, it must be different
than null except if called by the top levelMethod Detail |
---|
public CClassType lookupClass(CClass caller, String name) throws UnpositionedError
caller
- the class of the callername
- method name
UnpositionedError
- this error will be positioned soonpublic CMethod lookupMethod(CClass caller, String ident, CType[] actuals) throws UnpositionedError
caller
- the class of the callerident
- method nameactuals
- method parameters
UnpositionedError
- this error will be positioned soonpublic CField lookupField(CClass caller, String ident) throws UnpositionedError
caller
- the class of the callerident
- the simple name of the field
UnpositionedError
- this error will be positioned soonpublic JLocalVariable lookupLocalVariable(String ident)
ident
- the name of the local variable
public boolean isStaticContext()
public CVariableInfo getFieldInfo()
public int getFieldInfo(int index)
index
- the definition of a field
public void setFieldInfo(int index, int info)
index
- the definition of a fieldinfo
- public CContext getParentContext()
public CCompilationUnitContext getCompilationUnitContext()
public CClassContext getClassContext()
public CMethodContext getMethodContext()
public CBlockContext getBlockContext()
public void addSourceClass(CSourceClass clazz)
public void reportTrouble(PositionedError trouble)
trouble
- the error to reportpublic void fail(MessageDescription description, Object[] parameters) throws UnpositionedError
description
- the message descriptionparameters
- the array of parameters
UnpositionedError
- this error will be positioned soonpublic void fail(MessageDescription description, Object parameter1, Object parameter2) throws UnpositionedError
description
- the message descriptionparameter1
- the first parameterparameter2
- the second parameter
UnpositionedError
- this error will be positioned soonpublic void check(boolean assertion, MessageDescription description, Object[] parameters) throws UnpositionedError
assertion
- the assertion to verifydescription
- the message descriptionparameters
- the array of parameters
UnpositionedError
- this error will be positioned soonpublic void check(boolean assertion, MessageDescription description) throws UnpositionedError
assertion
- the assertion to verifydescription
- the message description
UnpositionedError
- this error will be positioned soonpublic void check(boolean assertion, MessageDescription description, Object parameter1) throws UnpositionedError
assertion
- the assertion to verifydescription
- the message descriptionparameter1
- the first parameter
UnpositionedError
- this error will be positioned soonpublic void check(boolean assertion, MessageDescription description, Object parameter1, Object parameter2) throws UnpositionedError
assertion
- the assertion to verifydescription
- the message descriptionparameter1
- the first parameterparameter2
- the second parameter
UnpositionedError
- this error will be positioned soonpublic void dumpContext(String text)
public void dumpContext(int level)
public void dumpIndent(int level)
public Object deepClone()
deepClone
in interface DeepCloneable
deepClone
in class Utils
protected void deepCloneInto(CContext other)
other
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |