private static String getTypeName(GenericType type) { int tp = type.type; if (tp <= CodeConstants.TYPE_BOOLEAN) { return typeNames[tp]; } else if (tp == CodeConstants.TYPE_VOID) { return "void"; } else if (tp == CodeConstants.TYPE_GENVAR) { return type.value; } else if (tp == CodeConstants.TYPE_OBJECT) { StringBuilder buffer = new StringBuilder(); appendClassName(type, buffer); return buffer.toString(); } throw new RuntimeException("Invalid type: " + type); }
private static void appendClassName(GenericType type, StringBuilder buffer) { List<GenericType> enclosingClasses = type.getEnclosingClasses(); if (enclosingClasses.isEmpty()) { String name = type.value.replace('/', '.'); buffer.append(DecompilerContext.getImportCollector().getShortName(name)); } else { for (GenericType tp : enclosingClasses) { if (buffer.length() == 0) { buffer.append(DecompilerContext.getImportCollector().getShortName(tp.value.replace('/', '.'))); } else { buffer.append(tp.value); } appendTypeArguments(tp, buffer); buffer.append('.'); } buffer.append(type.value); } appendTypeArguments(type, buffer); }
buffer.append(getGenericCastTypeName(genPar));
String signature = attr.getSignature(originalIndex, visibleOffset); if (signature != null) { GenericFieldDescriptor descriptor = GenericMain.parseFieldSignature(signature); if (descriptor != null) { buffer.append(GenericMain.getGenericCastTypeName(descriptor.type)); return;
StructGenericSignatureAttribute attr = mt.getAttribute(StructGeneralAttribute.ATTRIBUTE_SIGNATURE); if (attr != null) { descriptor = GenericMain.parseMethodSignature(attr.getSignature()); if (descriptor != null) { long actualParams = md.params.length; buffer.append(GenericMain.getGenericCastTypeName(descriptor.returnType)); parameterType = parameterType.decreaseArrayDim(); typeName = GenericMain.getGenericCastTypeName(parameterType); buffer.append(GenericMain.getGenericCastTypeName(type));
List<String> typeParameters = new ArrayList<>(); List<List<GenericType>> typeParameterBounds = new ArrayList<>(); signature = parseFormalParameters(signature, typeParameters, typeParameterBounds);
public static GenericClassDescriptor getGenericClassDescriptor(StructClass cl) { if (DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES)) { StructGenericSignatureAttribute attr = cl.getAttribute(StructGeneralAttribute.ATTRIBUTE_SIGNATURE); if (attr != null) { return GenericMain.parseClassSignature(attr.getSignature()); } } return null; }
public static String getGenericCastTypeName(GenericType type) { StringBuilder s = new StringBuilder(getTypeName(type)); TextUtil.append(s, "[]", type.arrayDim); return s.toString(); }
StructGenericSignatureAttribute attr = fd.getAttribute(StructGeneralAttribute.ATTRIBUTE_SIGNATURE); if (attr != null) { descriptor = GenericMain.parseFieldSignature(attr.getSignature()); buffer.append(GenericMain.getGenericCastTypeName(descriptor.type));
StructGenericSignatureAttribute attr = (StructGenericSignatureAttribute)mt.getAttribute("Signature"); if (attr != null) { descriptor = GenericMain.parseMethodSignature(attr.getSignature()); if (descriptor != null) { long actualParams = md.params.length; buffer.append(GenericMain.getGenericCastTypeName(descriptor.ret)); String typeName = GenericMain.getGenericCastTypeName(parameterType); if (ExprProcessor.UNDEFINED_TYPE_STRING.equals(typeName) && DecompilerContext.getOption(IFernflowerPreferences.UNDEFINED_PARAM_TYPE_OBJECT)) { buffer.append(GenericMain.getGenericCastTypeName(type));
public static GenericClassDescriptor parseClassSignature(String signature) { String original = signature; try { GenericClassDescriptor descriptor = new GenericClassDescriptor(); signature = parseFormalParameters(signature, descriptor.fparameters, descriptor.fbounds); String superCl = GenericType.getNextType(signature); descriptor.superclass = new GenericType(superCl); signature = signature.substring(superCl.length()); while (signature.length() > 0) { String superIf = GenericType.getNextType(signature); descriptor.superinterfaces.add(new GenericType(superIf)); signature = signature.substring(superIf.length()); } return descriptor; } catch (RuntimeException e) { DecompilerContext.getLogger().writeMessage("Invalid signature: " + original, IFernflowerLogger.Severity.WARN); return null; } }
public static GenericClassDescriptor getGenericClassDescriptor(StructClass cl) { if (DecompilerContext.getOption(IFernflowerPreferences.DECOMPILE_GENERIC_SIGNATURES)) { StructGenericSignatureAttribute attr = (StructGenericSignatureAttribute)cl.getAttribute("Signature"); if (attr != null) { return GenericMain.parseClassSignature(attr.getSignature()); } } return null; }
public static String getGenericCastTypeName(GenericType type) { String s = getTypeName(type); int dim = type.arrayDim; while (dim-- > 0) { s += "[]"; } return s; }
String signature = attr.getSignature(originalIndex, visibleOffset); if (signature != null) { GenericFieldDescriptor descriptor = GenericMain.parseFieldSignature(signature); if (descriptor != null) { buffer.append(GenericMain.getGenericCastTypeName(descriptor.type)); return;
public static void appendTypeParameters(TextBuffer buffer, List<String> parameters, List<? extends List<GenericType>> bounds) { buffer.append('<'); for (int i = 0; i < parameters.size(); i++) { if (i > 0) { buffer.append(", "); } buffer.append(parameters.get(i)); List<GenericType> parameterBounds = bounds.get(i); if (parameterBounds.size() > 1 || !"java/lang/Object".equals(parameterBounds.get(0).value)) { buffer.append(" extends "); buffer.append(GenericMain.getGenericCastTypeName(parameterBounds.get(0))); for (int j = 1; j < parameterBounds.size(); j++) { buffer.append(" & "); buffer.append(GenericMain.getGenericCastTypeName(parameterBounds.get(j))); } } } buffer.append('>'); } }
public static GenericMethodDescriptor parseMethodSignature(String signature) { String original = signature; try { GenericMethodDescriptor descriptor = new GenericMethodDescriptor(); signature = parseFormalParameters(signature, descriptor.fparameters, descriptor.fbounds); int to = signature.indexOf(")"); String pars = signature.substring(1, to); signature = signature.substring(to + 1); while (pars.length() > 0) { String par = GenericType.getNextType(pars); descriptor.params.add(new GenericType(par)); pars = pars.substring(par.length()); } String par = GenericType.getNextType(signature); descriptor.ret = new GenericType(par); signature = signature.substring(par.length()); if (signature.length() > 0) { String[] exceptions = signature.split("\\^"); for (int i = 1; i < exceptions.length; i++) { descriptor.exceptions.add(new GenericType(exceptions[i])); } } return descriptor; } catch (RuntimeException e) { DecompilerContext.getLogger().writeMessage("Invalid signature: " + original, IFernflowerLogger.Severity.WARN); return null; } }
private static String getTypeName(GenericType type) { int tp = type.type; if (tp <= CodeConstants.TYPE_BOOLEAN) { return typeNames[tp]; } else if (tp == CodeConstants.TYPE_VOID) { return "void"; } else if (tp == CodeConstants.TYPE_GENVAR) { return type.value; } else if (tp == CodeConstants.TYPE_OBJECT) { StringBuilder buffer = new StringBuilder(); appendClassName(type, buffer); return buffer.toString(); } throw new RuntimeException("Invalid type: " + type); }
private static void appendClassName(GenericType type, StringBuilder buffer) { List<GenericType> enclosingClasses = type.getEnclosingClasses(); if (enclosingClasses.isEmpty()) { String name = type.value.replace('/', '.'); buffer.append(DecompilerContext.getImportCollector().getShortName(name)); } else { for (GenericType tp : enclosingClasses) { if (buffer.length() == 0) { buffer.append(DecompilerContext.getImportCollector().getShortName(tp.value.replace('/', '.'))); } else { buffer.append(tp.value); } appendTypeArguments(tp, buffer); buffer.append('.'); } buffer.append(type.value); } appendTypeArguments(type, buffer); }
StructGenericSignatureAttribute attr = (StructGenericSignatureAttribute)fd.getAttribute("Signature"); if (attr != null) { descriptor = GenericMain.parseFieldSignature(attr.getSignature()); buffer.append(GenericMain.getGenericCastTypeName(descriptor.type));
if (descriptor != null) { if (descriptor.superinterfaces.isEmpty()) { buf.append(GenericMain.getGenericCastTypeName(descriptor.superclass)); IFernflowerLogger.Severity.WARN); buf.append(GenericMain.getGenericCastTypeName(descriptor.superinterfaces.get(0)));