private VariableManager(VarInfo varInfo, String condition, String className) throws ParseException { this.varInfo = varInfo; name = varInfo.name(); compilableName = compilableName(varInfo, className); fieldName = fieldName(varInfo, className); varName = varName(varInfo, className); type = makeIndexIfNeeded(getVarType(varInfo), compilableName, varInfo, condition); }
/** * Calculates the base name of a variable. The base name of a variable is the part of the variable * with prefixes "this." and className removed, and "orig()" replaced by "orig_". For example * orig(this.x) goes to orig_x. If className is "Class" then "Class.x" would yield "x" and * "someOtherClass.x" would yield "someOtherClass_x". Finally, Java Reserved words are replaced * with appropriate substitutes. * * @param varInfo the VarInfo for the variable whose base name is desired. * @return the base name of the variable represented by varInfo. */ private static String getBaseName(VarInfo varInfo, String className) { String name = varInfo.name(); name = replaceReservedWords(name); if (name.length() > 5 && name.substring(0, 5).equals("orig(") && name.endsWith(")")) { name = name.substring(5, name.length() - 1); name = fixPrefixes(name, className); name = "orig_" + name; } else { name = fixPrefixes(name, className); } name = name.replace('.', '_'); name = remove(name, ']'); name = remove(name, '['); return name; }
/** * Determines if the variable represented by varInfo is a "size" variable. * * @param varInfo the VarInfo of the variable being tested. * @return true iff varInfo is a "size" variable. */ private static boolean isSizeVar(VarInfo varInfo) { return varInfo.is_size(); }
/** Determines if the variable represented by varInfo is a "this" variable. */ private static boolean isThisVar(VarInfo varInfo) { return varInfo.isThis(); }
/** * Determines if the variable represented by varInfo is a ".getClass()" variable. * * @param varInfo the VarInfo of the variable being tested. * @return true iff varInfo is a ".getClass()" variable. */ private static boolean isTypeOfVar(VarInfo varInfo) { return varInfo.has_typeof(); }