/** * Get astubx style method signature. {FullyQualifiedEnclosingType}: {UnqualifiedMethodReturnType} * {methodName} ([{UnqualifiedArgumentType}*]) * * @param mtd Method reference. * @return String Method signature. */ // TODO: handle generics and inner classes private static String getSignature(IMethod mtd) { String classType = mtd.getDeclaringClass().getName().toString().replaceAll("/", "\\.").substring(1); classType = classType.replaceAll("\\$", "\\."); // handle inner class String returnType = mtd.isInit() ? null : getSimpleTypeName(mtd.getReturnType()); String strArgTypes = ""; int argi = mtd.isStatic() ? 0 : 1; // Skip 'this' parameter for (; argi < mtd.getNumberOfParameters(); argi++) { strArgTypes += getSimpleTypeName(mtd.getParameterType(argi)); if (argi < mtd.getNumberOfParameters() - 1) strArgTypes += ", "; } return classType + ":" + (returnType == null ? "void " : returnType + " ") + mtd.getName().toString() + "(" + strArgTypes + ")"; } /**
/** * Find or create an atom. * * @param str atom value, as string literal whose characters are unicode * @return atom */ public static Atom findOrCreateUnicodeAtom(String str) { byte[] utf8 = UTF8Convert.toUTF8(str); return findOrCreate(utf8); }
public static final TypeName[] parseForParameterNames(Language l, String descriptor) throws IllegalArgumentException { return parseForParameterNames(l, ImmutableByteArray.make(descriptor)); }
@Override public Atom getName() { return Atom.findOrCreateUnicodeAtom("c" + yuck); } @Override
public MicroModel(final IClassHierarchy cha, final AnalysisOptions options, final IAnalysisCacheView cache, Atom target) { super(cha, options, cache); this.target = target; this.name = Atom.concat(Atom.findOrCreateAsciiAtom("start"), target.right(target.rIndex((byte)'/') - 1)); }
@Override public GlobalObjectKey getGlobalObject(Atom language) { assert language.equals(JavaScriptTypes.jsName); return globalObject; }
public static final TypeName parseForReturnTypeName(String desc) throws IllegalArgumentException { return parseForReturnTypeName(Language.JAVA, ImmutableByteArray.make(desc)); }
/** * Is "this" atom a method descriptor? */ public final boolean isMethodDescriptor() throws IllegalArgumentException { if (length() == 0) { return false; } return val[0] == '('; }
/** * New Atom containing last count bytes */ public final Atom right(int count) { return findOrCreate(val, val.length - count, count); }
public static final TypeName parseForReturnTypeName(Language l, String desc) throws IllegalArgumentException { return parseForReturnTypeName(l, ImmutableByteArray.make(desc)); }
public static final TypeName[] parseForParameterNames(String descriptor) throws IllegalArgumentException { return parseForParameterNames(Language.JAVA, ImmutableByteArray.make(descriptor)); }
/** * Find or create an atom. * * @param str atom value, as string literal whose characters are unicode * @return atom */ public static Atom findOrCreateUnicodeAtom(String str) { byte[] utf8 = UTF8Convert.toUTF8(str); return findOrCreate(utf8); }
/** * Is "this" atom a reserved member name? Note: Sun has reserved all member names starting with '<' for future use. At present, * only <init> and <clinit> are used. */ public final boolean isReservedMemberName() { if (length() == 0) { return false; } return val[0] == '<'; }
/** * Special method that is called by Java deserialization process. Any HashCons'ed object should implement it, in order to make * sure that all equal objects are consolidated. */ private Object readResolve() { return findOrCreate(this.val); }
public static final TypeName parseForReturnTypeName(String desc) throws IllegalArgumentException { return parseForReturnTypeName(Language.JAVA, ImmutableByteArray.make(desc)); }
/** * Is "this" atom a class descriptor? */ public final boolean isClassDescriptor() { if (length() == 0) { return false; } return val[0] == 'L'; }
/** * Is "this" atom a class descriptor? */ public final boolean isClassDescriptor() { if (length() == 0) { return false; } return val[0] == 'L'; }
/** * Is "this" atom an array descriptor? */ public final boolean isArrayDescriptor() { if (length() == 0) { return false; } return val[0] == '['; }