use of com.sun.tools.classfile.Type in project ceylon-compiler by ceylon.
the class Signature method getParameterTypes.
@Override
public String getParameterTypes(ConstantPool constant_pool) throws ConstantPoolException {
MethodType m = (MethodType) getType(constant_pool);
StringBuilder sb = new StringBuilder();
sb.append("(");
String sep = "";
for (Type paramType : m.paramTypes) {
sb.append(sep);
sb.append(paramType);
sep = ", ";
}
sb.append(")");
return sb.toString();
}
use of com.sun.tools.classfile.Type in project ceylon-compiler by ceylon.
the class Signature method parse.
private Type parse(String sig) {
this.sig = sig;
sigp = 0;
List<TypeParamType> typeParamTypes = null;
if (sig.charAt(sigp) == '<')
typeParamTypes = parseTypeParamTypes();
if (sig.charAt(sigp) == '(') {
List<Type> paramTypes = parseTypeSignatures(')');
Type returnType = parseTypeSignature();
List<Type> throwsTypes = null;
while (sigp < sig.length() && sig.charAt(sigp) == '^') {
sigp++;
if (throwsTypes == null)
throwsTypes = new ArrayList<Type>();
throwsTypes.add(parseTypeSignature());
}
return new MethodType(typeParamTypes, paramTypes, returnType, throwsTypes);
} else {
Type t = parseTypeSignature();
if (typeParamTypes == null && sigp == sig.length())
return t;
Type superclass = t;
List<Type> superinterfaces = null;
while (sigp < sig.length()) {
if (superinterfaces == null)
superinterfaces = new ArrayList<Type>();
superinterfaces.add(parseTypeSignature());
}
return new ClassSigType(typeParamTypes, superclass, superinterfaces);
}
}
use of com.sun.tools.classfile.Type in project ceylon-compiler by ceylon.
the class Signature method parseTypeParamType.
private TypeParamType parseTypeParamType() {
int sep = sig.indexOf(":", sigp);
String name = sig.substring(sigp, sep);
Type classBound = null;
List<Type> interfaceBounds = null;
sigp = sep + 1;
if (sig.charAt(sigp) != ':')
classBound = parseTypeSignature();
while (sig.charAt(sigp) == ':') {
sigp++;
if (interfaceBounds == null)
interfaceBounds = new ArrayList<Type>();
interfaceBounds.add(parseTypeSignature());
}
return new TypeParamType(name, classBound, interfaceBounds);
}
use of com.sun.tools.classfile.Type in project ceylon-compiler by ceylon.
the class Signature method parseTypeVariableSignature.
private Type parseTypeVariableSignature() {
sigp++;
int sep = sig.indexOf(';', sigp);
Type t = new SimpleType(sig.substring(sigp, sep));
sigp = sep + 1;
return t;
}
use of com.sun.tools.classfile.Type in project ceylon-compiler by ceylon.
the class ClassWriter method writeField.
protected void writeField(Field f) {
if (!options.checkAccess(f.access_flags))
return;
AccessFlags flags = f.access_flags;
writeModifiers(flags.getFieldModifiers());
Signature_attribute sigAttr = getSignature(f.attributes);
if (sigAttr == null)
print(getJavaFieldType(f.descriptor));
else {
try {
Type t = sigAttr.getParsedSignature().getType(constant_pool);
print(getJavaName(t.toString()));
} catch (ConstantPoolException e) {
// report error?
// fall back on non-generic descriptor
print(getJavaFieldType(f.descriptor));
}
}
print(" ");
print(getFieldName(f));
if (options.showConstants && !options.compat) {
// BUG 4111861 print static final field contents
Attribute a = f.attributes.get(Attribute.ConstantValue);
if (a instanceof ConstantValue_attribute) {
print(" = ");
ConstantValue_attribute cv = (ConstantValue_attribute) a;
print(getConstantValue(f.descriptor, cv.constantvalue_index));
}
}
print(";");
println();
indent(+1);
if (options.showInternalSignatures)
println("Signature: " + getValue(f.descriptor));
if (options.verbose && !options.compat)
writeList("flags: ", flags.getFieldFlags(), NEWLINE);
if (options.showAllAttrs) {
for (Attribute attr : f.attributes) attrWriter.write(f, attr, constant_pool);
println();
}
indent(-1);
if (options.showDisassembled || options.showLineAndLocalVariableTables)
println();
}
Aggregations