Java源码示例:sun.tools.java.CompilerError
示例1
protected boolean initParents(ContextStack stack) {
stack.setNewContextCode(ContextStack.EXTENDS);
BatchEnvironment env = stack.getEnv();
// Init parent...
boolean result = true;
try {
ClassDeclaration parentDecl = getClassDefinition().getSuperClass(env);
if (parentDecl != null) {
ClassDefinition parentDef = parentDecl.getClassDefinition(env);
parent = (ClassType) makeType(parentDef.getType(),parentDef,stack);
if (parent == null) {
result = false;
}
}
} catch (ClassNotFound e) {
classNotFound(stack,e);
throw new CompilerError("ClassType constructor");
}
return result;
}
示例2
/**
* IDL_Naming
* Create an PrimitiveType instance for the given class.
*/
private PrimitiveType(ContextStack stack, int typeCode) {
super(stack,typeCode | TM_PRIMITIVE);
// Validate type and set names...
String idlName = IDLNames.getTypeName(typeCode,false);
Identifier id = null;
switch (typeCode) {
case TYPE_VOID: id = idVoid; break;
case TYPE_BOOLEAN: id = idBoolean; break;
case TYPE_BYTE: id = idByte; break;
case TYPE_CHAR: id = idChar; break;
case TYPE_SHORT: id = idShort; break;
case TYPE_INT: id = idInt; break;
case TYPE_LONG: id = idLong; break;
case TYPE_FLOAT: id = idFloat; break;
case TYPE_DOUBLE: id = idDouble; break;
default: throw new CompilerError("Not a primitive type");
}
setNames(id,null,idlName);
setRepositoryID();
}
示例3
protected boolean initParents(ContextStack stack) {
stack.setNewContextCode(ContextStack.EXTENDS);
BatchEnvironment env = stack.getEnv();
// Init parent...
boolean result = true;
try {
ClassDeclaration parentDecl = getClassDefinition().getSuperClass(env);
if (parentDecl != null) {
ClassDefinition parentDef = parentDecl.getClassDefinition(env);
parent = (ClassType) makeType(parentDef.getType(),parentDef,stack);
if (parent == null) {
result = false;
}
}
} catch (ClassNotFound e) {
classNotFound(stack,e);
throw new CompilerError("ClassType constructor");
}
return result;
}
示例4
protected boolean initParents(ContextStack stack) {
stack.setNewContextCode(ContextStack.EXTENDS);
BatchEnvironment env = stack.getEnv();
// Init parent...
boolean result = true;
try {
ClassDeclaration parentDecl = getClassDefinition().getSuperClass(env);
if (parentDecl != null) {
ClassDefinition parentDef = parentDecl.getClassDefinition(env);
parent = (ClassType) makeType(parentDef.getType(),parentDef,stack);
if (parent == null) {
result = false;
}
}
} catch (ClassNotFound e) {
classNotFound(stack,e);
throw new CompilerError("ClassType constructor");
}
return result;
}
示例5
/**
* IDL_Naming
* Create an PrimitiveType instance for the given class.
*/
private PrimitiveType(ContextStack stack, int typeCode) {
super(stack,typeCode | TM_PRIMITIVE);
// Validate type and set names...
String idlName = IDLNames.getTypeName(typeCode,false);
Identifier id = null;
switch (typeCode) {
case TYPE_VOID: id = idVoid; break;
case TYPE_BOOLEAN: id = idBoolean; break;
case TYPE_BYTE: id = idByte; break;
case TYPE_CHAR: id = idChar; break;
case TYPE_SHORT: id = idShort; break;
case TYPE_INT: id = idInt; break;
case TYPE_LONG: id = idLong; break;
case TYPE_FLOAT: id = idFloat; break;
case TYPE_DOUBLE: id = idDouble; break;
default: throw new CompilerError("Not a primitive type");
}
setNames(id,null,idlName);
setRepositoryID();
}
示例6
protected boolean initParents(ContextStack stack) {
stack.setNewContextCode(ContextStack.EXTENDS);
BatchEnvironment env = stack.getEnv();
// Init parent...
boolean result = true;
try {
ClassDeclaration parentDecl = getClassDefinition().getSuperClass(env);
if (parentDecl != null) {
ClassDefinition parentDef = parentDecl.getClassDefinition(env);
parent = (ClassType) makeType(parentDef.getType(),parentDef,stack);
if (parent == null) {
result = false;
}
}
} catch (ClassNotFound e) {
classNotFound(stack,e);
throw new CompilerError("ClassType constructor");
}
return result;
}
示例7
/**
* IDL_Naming
* Create an PrimitiveType instance for the given class.
*/
private PrimitiveType(ContextStack stack, int typeCode) {
super(stack,typeCode | TM_PRIMITIVE);
// Validate type and set names...
String idlName = IDLNames.getTypeName(typeCode,false);
Identifier id = null;
switch (typeCode) {
case TYPE_VOID: id = idVoid; break;
case TYPE_BOOLEAN: id = idBoolean; break;
case TYPE_BYTE: id = idByte; break;
case TYPE_CHAR: id = idChar; break;
case TYPE_SHORT: id = idShort; break;
case TYPE_INT: id = idInt; break;
case TYPE_LONG: id = idLong; break;
case TYPE_FLOAT: id = idFloat; break;
case TYPE_DOUBLE: id = idDouble; break;
default: throw new CompilerError("Not a primitive type");
}
setNames(id,null,idlName);
setRepositoryID();
}
示例8
/**
* IDL_Naming
* Create an PrimitiveType instance for the given class.
*/
private PrimitiveType(ContextStack stack, int typeCode) {
super(stack,typeCode | TM_PRIMITIVE);
// Validate type and set names...
String idlName = IDLNames.getTypeName(typeCode,false);
Identifier id = null;
switch (typeCode) {
case TYPE_VOID: id = idVoid; break;
case TYPE_BOOLEAN: id = idBoolean; break;
case TYPE_BYTE: id = idByte; break;
case TYPE_CHAR: id = idChar; break;
case TYPE_SHORT: id = idShort; break;
case TYPE_INT: id = idInt; break;
case TYPE_LONG: id = idLong; break;
case TYPE_FLOAT: id = idFloat; break;
case TYPE_DOUBLE: id = idDouble; break;
default: throw new CompilerError("Not a primitive type");
}
setNames(id,null,idlName);
setRepositoryID();
}
示例9
protected Class loadClass() {
switch (getTypeCode()) {
case TYPE_VOID: return Null.class;
case TYPE_BOOLEAN: return boolean.class;
case TYPE_BYTE: return byte.class;
case TYPE_CHAR: return char.class;
case TYPE_SHORT: return short.class;
case TYPE_INT: return int.class;
case TYPE_LONG: return long.class;
case TYPE_FLOAT: return float.class;
case TYPE_DOUBLE: return double.class;
default: throw new CompilerError("Not a primitive type");
}
}
示例10
/**
* Create a ClassType instance for the given class. NOTE: This constructor
* is ONLY for ImplementationType. It does not walk the parent chain.
*/
protected ClassType(int typeCode, ClassDefinition classDef,ContextStack stack) {
super(stack,classDef,typeCode);
if ((typeCode & TM_CLASS) == 0 && classDef.isInterface()) {
throw new CompilerError("Not a class");
}
parent = null;
}
示例11
/**
* Create an ClassType instance for the given class. The resulting
* object is not yet completely initialized. Subclasses must call
* initialize(directInterfaces,directInterfaces,directConstants);
*/
protected ClassType(ContextStack stack,
ClassDefinition classDef,
int typeCode) {
super(stack,classDef,typeCode);
if ((typeCode & TM_CLASS) == 0 && classDef.isInterface()) {
throw new CompilerError("Not a class");
}
parent = null;
}
示例12
/**
* Pop an element from the stack.
* @return the new current element or null if top.
*/
public TypeContext pop (boolean wasValid) {
if (currentIndex < 0) {
throw new CompilerError("Nothing on stack!");
}
newCode = stack[currentIndex].getCode();
traceln(toResultString(stack[currentIndex],wasValid,false));
Type last = stack[currentIndex].getCandidateType();
if (last != null) {
// Set status...
if (wasValid) {
last.setStatus(Constants.STATUS_VALID);
} else {
last.setStatus(Constants.STATUS_INVALID);
}
}
currentIndex--;
if (currentIndex < 0) {
// Done parsing, so update the invalid types
// if this type was valid...
if (wasValid) {
Type.updateAllInvalidTypes(this);
}
return null;
} else {
return stack[currentIndex];
}
}
示例13
/**
* Create a InterfaceType instance for the given class. NOTE: This constructor
* is ONLY for SpecialInterfaceType.
*/
protected InterfaceType(ContextStack stack, int typeCode, ClassDefinition classDef) {
super(stack,typeCode,classDef); // Call special parent constructor.
if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
throw new CompilerError("Not an interface");
}
}
示例14
/**
* Create a InterfaceType instance for the given class. The resulting
* object is not yet completely initialized. Subclasses must call
* initialize(directInterfaces,directInterfaces,directConstants);
*/
protected InterfaceType(ContextStack stack,
ClassDefinition classDef,
int typeCode) {
super(stack,classDef,typeCode);
if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
throw new CompilerError("Not an interface");
}
}
示例15
/**
* Create a InterfaceType instance for the given class. The resulting
* object is not yet completely initialized. Subclasses must call
* initialize(directInterfaces,directInterfaces,directConstants);
*/
protected InterfaceType(ContextStack stack,
ClassDefinition classDef,
int typeCode) {
super(stack,classDef,typeCode);
if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
throw new CompilerError("Not an interface");
}
}
示例16
/**
* Create a ClassType instance for the given class. NOTE: This constructor
* is ONLY for SpecialClassType.
*/
protected ClassType(ContextStack stack, int typeCode, ClassDefinition classDef) {
super(stack,typeCode,classDef); // Call special parent constructor.
if ((typeCode & TM_CLASS) == 0 && classDef.isInterface()) {
throw new CompilerError("Not a class");
}
parent = null;
}
示例17
/**
* Pop an element from the stack.
* @return the new current element or null if top.
*/
public TypeContext pop (boolean wasValid) {
if (currentIndex < 0) {
throw new CompilerError("Nothing on stack!");
}
newCode = stack[currentIndex].getCode();
traceln(toResultString(stack[currentIndex],wasValid,false));
Type last = stack[currentIndex].getCandidateType();
if (last != null) {
// Set status...
if (wasValid) {
last.setStatus(Constants.STATUS_VALID);
} else {
last.setStatus(Constants.STATUS_INVALID);
}
}
currentIndex--;
if (currentIndex < 0) {
// Done parsing, so update the invalid types
// if this type was valid...
if (wasValid) {
Type.updateAllInvalidTypes(this);
}
return null;
} else {
return stack[currentIndex];
}
}
示例18
/**
* Create a InterfaceType instance for the given class. NOTE: This constructor
* is ONLY for SpecialInterfaceType.
*/
protected InterfaceType(ContextStack stack, int typeCode, ClassDefinition classDef) {
super(stack,typeCode,classDef); // Call special parent constructor.
if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
throw new CompilerError("Not an interface");
}
}
示例19
/**
* Create a InterfaceType instance for the given class. The resulting
* object is not yet completely initialized. Subclasses must call
* initialize(directInterfaces,directInterfaces,directConstants);
*/
protected InterfaceType(ContextStack stack,
ClassDefinition classDef,
int typeCode) {
super(stack,classDef,typeCode);
if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
throw new CompilerError("Not an interface");
}
}
示例20
protected Class loadClass() {
switch (getTypeCode()) {
case TYPE_VOID: return Null.class;
case TYPE_BOOLEAN: return boolean.class;
case TYPE_BYTE: return byte.class;
case TYPE_CHAR: return char.class;
case TYPE_SHORT: return short.class;
case TYPE_INT: return int.class;
case TYPE_LONG: return long.class;
case TYPE_FLOAT: return float.class;
case TYPE_DOUBLE: return double.class;
default: throw new CompilerError("Not a primitive type");
}
}
示例21
/**
* Create an NCInterfaceType for the given class.
*
* If the class is not a properly formed or if some other error occurs, the
* return value will be null, and errors will have been reported to the
* supplied BatchEnvironment.
*/
public static NCInterfaceType forNCInterface( ClassDefinition classDef,
ContextStack stack) {
if (stack.anyErrors()) return null;
boolean doPop = false;
try {
// Do we already have it?
sun.tools.java.Type theType = classDef.getType();
Type existing = getType(theType,stack);
if (existing != null) {
if (!(existing instanceof NCInterfaceType)) return null; // False hit.
// Yep, so return it...
return (NCInterfaceType) existing;
}
NCInterfaceType it = new NCInterfaceType(stack, classDef);
putType(theType,it,stack);
stack.push(it);
doPop = true;
if (it.initialize(stack)) {
stack.pop(true);
return it;
} else {
removeType(theType,stack);
stack.pop(false);
return null;
}
} catch (CompilerError e) {
if (doPop) stack.pop(false);
return null;
}
}
示例22
/**
* Create a ClassType instance for the given class. NOTE: This constructor
* is ONLY for ImplementationType. It does not walk the parent chain.
*/
protected ClassType(int typeCode, ClassDefinition classDef,ContextStack stack) {
super(stack,classDef,typeCode);
if ((typeCode & TM_CLASS) == 0 && classDef.isInterface()) {
throw new CompilerError("Not a class");
}
parent = null;
}
示例23
/**
* Create an ClassType instance for the given class. The resulting
* object is not yet completely initialized. Subclasses must call
* initialize(directInterfaces,directInterfaces,directConstants);
*/
protected ClassType(ContextStack stack,
ClassDefinition classDef,
int typeCode) {
super(stack,classDef,typeCode);
if ((typeCode & TM_CLASS) == 0 && classDef.isInterface()) {
throw new CompilerError("Not a class");
}
parent = null;
}
示例24
/**
* Create a ClassType instance for the given class. NOTE: This constructor
* is ONLY for SpecialClassType.
*/
protected ClassType(ContextStack stack, int typeCode, ClassDefinition classDef) {
super(stack,typeCode,classDef); // Call special parent constructor.
if ((typeCode & TM_CLASS) == 0 && classDef.isInterface()) {
throw new CompilerError("Not a class");
}
parent = null;
}
示例25
/**
* Create an NCInterfaceType for the given class.
*
* If the class is not a properly formed or if some other error occurs, the
* return value will be null, and errors will have been reported to the
* supplied BatchEnvironment.
*/
public static NCInterfaceType forNCInterface( ClassDefinition classDef,
ContextStack stack) {
if (stack.anyErrors()) return null;
boolean doPop = false;
try {
// Do we already have it?
sun.tools.java.Type theType = classDef.getType();
Type existing = getType(theType,stack);
if (existing != null) {
if (!(existing instanceof NCInterfaceType)) return null; // False hit.
// Yep, so return it...
return (NCInterfaceType) existing;
}
NCInterfaceType it = new NCInterfaceType(stack, classDef);
putType(theType,it,stack);
stack.push(it);
doPop = true;
if (it.initialize(stack)) {
stack.pop(true);
return it;
} else {
removeType(theType,stack);
stack.pop(false);
return null;
}
} catch (CompilerError e) {
if (doPop) stack.pop(false);
return null;
}
}
示例26
/**
* Pop an element from the stack.
* @return the new current element or null if top.
*/
public TypeContext pop (boolean wasValid) {
if (currentIndex < 0) {
throw new CompilerError("Nothing on stack!");
}
newCode = stack[currentIndex].getCode();
traceln(toResultString(stack[currentIndex],wasValid,false));
Type last = stack[currentIndex].getCandidateType();
if (last != null) {
// Set status...
if (wasValid) {
last.setStatus(Constants.STATUS_VALID);
} else {
last.setStatus(Constants.STATUS_INVALID);
}
}
currentIndex--;
if (currentIndex < 0) {
// Done parsing, so update the invalid types
// if this type was valid...
if (wasValid) {
Type.updateAllInvalidTypes(this);
}
return null;
} else {
return stack[currentIndex];
}
}
示例27
/**
* Pop an element from the stack.
* @return the new current element or null if top.
*/
public TypeContext pop (boolean wasValid) {
if (currentIndex < 0) {
throw new CompilerError("Nothing on stack!");
}
newCode = stack[currentIndex].getCode();
traceln(toResultString(stack[currentIndex],wasValid,false));
Type last = stack[currentIndex].getCandidateType();
if (last != null) {
// Set status...
if (wasValid) {
last.setStatus(Constants.STATUS_VALID);
} else {
last.setStatus(Constants.STATUS_INVALID);
}
}
currentIndex--;
if (currentIndex < 0) {
// Done parsing, so update the invalid types
// if this type was valid...
if (wasValid) {
Type.updateAllInvalidTypes(this);
}
return null;
} else {
return stack[currentIndex];
}
}
示例28
/**
* Create a InterfaceType instance for the given class. The resulting
* object is not yet completely initialized. Subclasses must call
* initialize(directInterfaces,directInterfaces,directConstants);
*/
protected InterfaceType(ContextStack stack,
ClassDefinition classDef,
int typeCode) {
super(stack,classDef,typeCode);
if ((typeCode & TM_INTERFACE) == 0 || ! classDef.isInterface()) {
throw new CompilerError("Not an interface");
}
}
示例29
protected Class loadClass() {
switch (getTypeCode()) {
case TYPE_VOID: return Null.class;
case TYPE_BOOLEAN: return boolean.class;
case TYPE_BYTE: return byte.class;
case TYPE_CHAR: return char.class;
case TYPE_SHORT: return short.class;
case TYPE_INT: return int.class;
case TYPE_LONG: return long.class;
case TYPE_FLOAT: return float.class;
case TYPE_DOUBLE: return double.class;
default: throw new CompilerError("Not a primitive type");
}
}
示例30
/**
* Create an NCInterfaceType for the given class.
*
* If the class is not a properly formed or if some other error occurs, the
* return value will be null, and errors will have been reported to the
* supplied BatchEnvironment.
*/
public static NCInterfaceType forNCInterface( ClassDefinition classDef,
ContextStack stack) {
if (stack.anyErrors()) return null;
boolean doPop = false;
try {
// Do we already have it?
sun.tools.java.Type theType = classDef.getType();
Type existing = getType(theType,stack);
if (existing != null) {
if (!(existing instanceof NCInterfaceType)) return null; // False hit.
// Yep, so return it...
return (NCInterfaceType) existing;
}
NCInterfaceType it = new NCInterfaceType(stack, classDef);
putType(theType,it,stack);
stack.push(it);
doPop = true;
if (it.initialize(stack)) {
stack.pop(true);
return it;
} else {
removeType(theType,stack);
stack.pop(false);
return null;
}
} catch (CompilerError e) {
if (doPop) stack.pop(false);
return null;
}
}