package soot.JastAddJ; import java.util.HashSet;import java.util.LinkedHashSet;import java.io.File;import java.util.*;import beaver.*;import java.util.ArrayList;import java.util.zip.*;import java.io.*;import java.io.FileNotFoundException;import java.util.Collection;import soot.*;import soot.util.*;import soot.jimple.*;import soot.coffi.ClassFile;import soot.coffi.method_info;import soot.coffi.CONSTANT_Utf8_info;import soot.tagkit.SourceFileTag;import soot.coffi.CoffiMethodSource; public class ConstructorAccess extends Access implements Cloneable { public void flushCache() { super.flushCache(); decls_computed = false; decls_value = null; decl_computed = false; decl_value = null; type_computed = false; type_value = null; } public void flushCollectionCache() { super.flushCollectionCache(); } @SuppressWarnings({"unchecked", "cast"}) public ConstructorAccess clone() throws CloneNotSupportedException { ConstructorAccess node = (ConstructorAccess)super.clone(); node.decls_computed = false; node.decls_value = null; node.decl_computed = false; node.decl_value = null; node.type_computed = false; node.type_value = null; node.in$Circle(false); node.is$Final(false); return node; } @SuppressWarnings({"unchecked", "cast"}) public ConstructorAccess copy() { try { ConstructorAccess node = (ConstructorAccess)clone(); if(children != null) node.children = (ASTNode[])children.clone(); return node; } catch (CloneNotSupportedException e) { } System.err.println("Error: Could not clone node of type " + getClass().getName() + "!"); return null; } @SuppressWarnings({"unchecked", "cast"}) public ConstructorAccess fullCopy() { ConstructorAccess res = (ConstructorAccess)copy(); for(int i = 0; i < getNumChildNoTransform(); i++) { ASTNode node = getChildNoTransform(i); if(node != null) node = node.fullCopy(); res.setChild(node, i); } return res; } // Declared in ExceptionHandling.jrag at line 97 public void exceptionHandling() { for(int i = 0; i < decl().getNumException(); i++) { TypeDecl exceptionType = decl().getException(i).type(); if(!handlesException(exceptionType)) error("" + this + " may throw uncaught exception " + exceptionType.fullName()); } } // Declared in ExceptionHandling.jrag at line 244 // 8.8.4 (8.4.4) protected boolean reachedException(TypeDecl catchType) { for(int i = 0; i < decl().getNumException(); i++) { TypeDecl exceptionType = decl().getException(i).type(); if(catchType.mayCatch(exceptionType)) return true; } return super.reachedException(catchType); } // Declared in NameCheck.jrag at line 112 public void nameCheck() { super.nameCheck(); if(decls().isEmpty()) error("no constructor named " + this); if(decls().size() > 1 && validArgs()) { error("several most specific constructors for " + this); for(Iterator iter = decls().iterator(); iter.hasNext(); ) { error(" " + ((ConstructorDecl)iter.next()).signature()); } } } // Declared in PrettyPrint.jadd at line 469 public void toString(StringBuffer s) { s.append(name()); s.append("("); if(getNumArg() > 0) { getArg(0).toString(s); for(int i = 1; i < getNumArg(); i++) { s.append(", "); getArg(i).toString(s); } } s.append(")"); } // Declared in Annotations.jrag at line 355 public void checkModifiers() { if(decl().isDeprecated() && !withinDeprecatedAnnotation() && hostType().topLevelType() != decl().hostType().topLevelType() && !withinSuppressWarnings("deprecation")) warning(decl().signature() + " in " + decl().hostType().typeName() + " has been deprecated"); } // Declared in Enums.jrag at line 156 // applied to both ConstructorAccess and SuperConstructorAccess protected void transformEnumConstructors() { super.transformEnumConstructors(); getArgList().insertChild(new VarAccess("@p0"),0); getArgList().insertChild(new VarAccess("@p1"),1); } // Declared in InnerClasses.jrag at line 457 // add val$name as arguments to the constructor protected boolean addEnclosingVariables = true; // Declared in InnerClasses.jrag at line 458 public void addEnclosingVariables() { if(!addEnclosingVariables) return; addEnclosingVariables = false; decl().addEnclosingVariables(); for(Iterator iter = decl().hostType().enclosingVariables().iterator(); iter.hasNext(); ) { Variable v = (Variable)iter.next(); getArgList().add(new VarAccess("val$" + v.name())); } } // Declared in Transformations.jrag at line 138 // remote collection / demand driven creation of accessor public void refined_Transformations_ConstructorAccess_transformation() { // this$val addEnclosingVariables(); // touch accessorIndex go force creation of private constructorAccessor if(decl().isPrivate() && decl().hostType() != hostType()) { decl().createAccessor(); } super.transformation(); } // Declared in EmitJimpleRefinements.jrag at line 235 public void collectTypesToSignatures(Collection<Type> set) { super.collectTypesToSignatures(set); addDependencyIfNeeded(set, decl().erasedConstructor().hostType()); } // Declared in java.ast at line 3 // Declared in java.ast line 18 public ConstructorAccess() { super(); setChild(new List(), 0); } // Declared in java.ast at line 11 // Declared in java.ast line 18 public ConstructorAccess(String p0, List<Expr> p1) { setID(p0); setChild(p1, 0); } // Declared in java.ast at line 17 // Declared in java.ast line 18 public ConstructorAccess(beaver.Symbol p0, List<Expr> p1) { setID(p0); setChild(p1, 0); } // Declared in java.ast at line 22 protected int numChildren() { return 1; } // Declared in java.ast at line 25 public boolean mayHaveRewrite() { return false; } // Declared in java.ast at line 2 // Declared in java.ast line 18 protected String tokenString_ID; // Declared in java.ast at line 3 public void setID(String value) { tokenString_ID = value; } // Declared in java.ast at line 6 public int IDstart; // Declared in java.ast at line 7 public int IDend; // Declared in java.ast at line 8 public void setID(beaver.Symbol symbol) { if(symbol.value != null && !(symbol.value instanceof String)) throw new UnsupportedOperationException("setID is only valid for String lexemes"); tokenString_ID = (String)symbol.value; IDstart = symbol.getStart(); IDend = symbol.getEnd(); } // Declared in java.ast at line 15 public String getID() { return tokenString_ID != null ? tokenString_ID : ""; } // Declared in java.ast at line 2 // Declared in java.ast line 18 public void setArgList(List<Expr> list) { setChild(list, 0); } // Declared in java.ast at line 6 public int getNumArg() { return getArgList().getNumChild(); } // Declared in java.ast at line 10 @SuppressWarnings({"unchecked", "cast"}) public Expr getArg(int i) { return (Expr)getArgList().getChild(i); } // Declared in java.ast at line 14 public void addArg(Expr node) { List<Expr> list = (parent == null || state == null) ? getArgListNoTransform() : getArgList(); list.addChild(node); } // Declared in java.ast at line 19 public void addArgNoTransform(Expr node) { List<Expr> list = getArgListNoTransform(); list.addChild(node); } // Declared in java.ast at line 24 public void setArg(Expr node, int i) { List<Expr> list = getArgList(); list.setChild(node, i); } // Declared in java.ast at line 28 public List<Expr> getArgs() { return getArgList(); } // Declared in java.ast at line 31 public List<Expr> getArgsNoTransform() { return getArgListNoTransform(); } // Declared in java.ast at line 35 @SuppressWarnings({"unchecked", "cast"}) public List<Expr> getArgList() { List<Expr> list = (List<Expr>)getChild(0); list.getNumChild(); return list; } // Declared in java.ast at line 41 @SuppressWarnings({"unchecked", "cast"}) public List<Expr> getArgListNoTransform() { return (List<Expr>)getChildNoTransform(0); } // Declared in VariableArityParametersCodegen.jrag at line 57 public void transformation() { if(decl().isVariableArity() && !invokesVariableArityAsArray()) { // arguments to normal parameters List list = new List(); for(int i = 0; i < decl().getNumParameter() - 1; i++) list.add(getArg(i).fullCopy()); // arguments to variable arity parameters List last = new List(); for(int i = decl().getNumParameter() - 1; i < getNumArg(); i++) last.add(getArg(i).fullCopy()); // build an array holding arguments Access typeAccess = decl().lastParameter().type().elementType().createQualifiedAccess(); for(int i = 0; i < decl().lastParameter().type().dimension(); i++) typeAccess = new ArrayTypeAccess(typeAccess); list.add(new ArrayCreationExpr(typeAccess, new Opt(new ArrayInit(last)))); // replace argument list with augemented argument list setArgList(list); } refined_Transformations_ConstructorAccess_transformation(); } // Declared in GenericsCodegen.jrag at line 216 public soot.Value eval(Body b) { b.setLine(this); ConstructorDecl c = decl().erasedConstructor(); // this Local base = b.emitThis(hostType()); int index = 0; ArrayList list = new ArrayList(); // this$0 if(c.needsEnclosing()) list.add(asImmediate(b, b.newParameterRef(hostType().enclosingType().getSootType(), index++, this) )); if(c.needsSuperEnclosing()) { TypeDecl superClass = ((ClassDecl)hostType()).superclass(); list.add(asImmediate(b, b.newParameterRef(superClass.enclosingType().getSootType(), index++, this) )); } // args for(int i = 0; i < getNumArg(); i++) list.add(asImmediate(b, getArg(i).type().emitCastTo(b, getArg(i), c.getParameter(i).type()))); // MethodInvocationConversion if(decl().isPrivate() && decl().hostType() != hostType()) { list.add(asImmediate(b, soot.jimple.NullConstant.v())); b.add( b.newInvokeStmt( b.newSpecialInvokeExpr(base, decl().erasedConstructor().createAccessor().sootRef(), list, this), this ) ); return base; } else { return b.newSpecialInvokeExpr(base, c.sootRef(), list, this); } } // Declared in DefiniteAssignment.jrag at line 298 @SuppressWarnings({"unchecked", "cast"}) public boolean isDAafter(Variable v) { ASTNode$State state = state(); boolean isDAafter_Variable_value = isDAafter_compute(v); return isDAafter_Variable_value; } private boolean isDAafter_compute(Variable v) { return decl().isDAafter(v); } // Declared in DefiniteAssignment.jrag at line 754 @SuppressWarnings({"unchecked", "cast"}) public boolean isDUafter(Variable v) { ASTNode$State state = state(); boolean isDUafter_Variable_value = isDUafter_compute(v); return isDUafter_Variable_value; } private boolean isDUafter_compute(Variable v) { return decl().isDUafter(v); } // Declared in LookupConstructor.jrag at line 51 @SuppressWarnings({"unchecked", "cast"}) public boolean applicableAndAccessible(ConstructorDecl decl) { ASTNode$State state = state(); boolean applicableAndAccessible_ConstructorDecl_value = applicableAndAccessible_compute(decl); return applicableAndAccessible_ConstructorDecl_value; } private boolean applicableAndAccessible_compute(ConstructorDecl decl) { return decl.applicable(getArgList()) && decl.accessibleFrom(hostType()); } protected boolean decls_computed = false; protected SimpleSet decls_value; // Declared in MethodSignature.jrag at line 59 @SuppressWarnings({"unchecked", "cast"}) public SimpleSet decls() { if(decls_computed) { return decls_value; } ASTNode$State state = state(); int num = state.boundariesCrossed; boolean isFinal = this.is$Final(); decls_value = decls_compute(); if(isFinal && num == state().boundariesCrossed) decls_computed = true; return decls_value; } private SimpleSet decls_compute() { return chooseConstructor(lookupConstructor(), getArgList()); } protected boolean decl_computed = false; protected ConstructorDecl decl_value; // Declared in LookupConstructor.jrag at line 65 @SuppressWarnings({"unchecked", "cast"}) public ConstructorDecl decl() { if(decl_computed) { return decl_value; } ASTNode$State state = state(); int num = state.boundariesCrossed; boolean isFinal = this.is$Final(); decl_value = decl_compute(); if(isFinal && num == state().boundariesCrossed) decl_computed = true; return decl_value; } private ConstructorDecl decl_compute() { SimpleSet decls = decls(); if(decls.size() == 1) return (ConstructorDecl)decls.iterator().next(); return unknownConstructor(); } // Declared in NameCheck.jrag at line 124 @SuppressWarnings({"unchecked", "cast"}) public boolean validArgs() { ASTNode$State state = state(); boolean validArgs_value = validArgs_compute(); return validArgs_value; } private boolean validArgs_compute() { for(int i = 0; i < getNumArg(); i++) if(getArg(i).type().isUnknown()) return false; return true; } // Declared in QualifiedNames.jrag at line 19 @SuppressWarnings({"unchecked", "cast"}) public String name() { ASTNode$State state = state(); String name_value = name_compute(); return name_value; } private String name_compute() { return "this"; } // Declared in SyntacticClassification.jrag at line 129 @SuppressWarnings({"unchecked", "cast"}) public NameType predNameType() { ASTNode$State state = state(); NameType predNameType_value = predNameType_compute(); return predNameType_value; } private NameType predNameType_compute() { return NameType.AMBIGUOUS_NAME; } // Declared in TypeAnalysis.jrag at line 285 @SuppressWarnings({"unchecked", "cast"}) public TypeDecl type() { if(type_computed) { return type_value; } ASTNode$State state = state(); int num = state.boundariesCrossed; boolean isFinal = this.is$Final(); type_value = type_compute(); if(isFinal && num == state().boundariesCrossed) type_computed = true; return type_value; } private TypeDecl type_compute() { return decl().type(); } // Declared in MethodSignature.jrag at line 311 @SuppressWarnings({"unchecked", "cast"}) public int arity() { ASTNode$State state = state(); int arity_value = arity_compute(); return arity_value; } private int arity_compute() { return getNumArg(); } // Declared in VariableArityParameters.jrag at line 47 @SuppressWarnings({"unchecked", "cast"}) public boolean invokesVariableArityAsArray() { ASTNode$State state = state(); boolean invokesVariableArityAsArray_value = invokesVariableArityAsArray_compute(); return invokesVariableArityAsArray_value; } private boolean invokesVariableArityAsArray_compute() { if(!decl().isVariableArity()) return false; if(arity() != decl().arity()) return false; return getArg(getNumArg()-1).type().methodInvocationConversionTo(decl().lastParameter().type()); } // Declared in ExceptionHandling.jrag at line 30 @SuppressWarnings({"unchecked", "cast"}) public boolean handlesException(TypeDecl exceptionType) { ASTNode$State state = state(); boolean handlesException_TypeDecl_value = getParent().Define_boolean_handlesException(this, null, exceptionType); return handlesException_TypeDecl_value; } // Declared in LookupConstructor.jrag at line 14 @SuppressWarnings({"unchecked", "cast"}) public Collection lookupConstructor() { ASTNode$State state = state(); Collection lookupConstructor_value = getParent().Define_Collection_lookupConstructor(this, null); return lookupConstructor_value; } // Declared in LookupConstructor.jrag at line 71 @SuppressWarnings({"unchecked", "cast"}) public ConstructorDecl unknownConstructor() { ASTNode$State state = state(); ConstructorDecl unknownConstructor_value = getParent().Define_ConstructorDecl_unknownConstructor(this, null); return unknownConstructor_value; } // Declared in LookupMethod.jrag at line 29 public Collection Define_Collection_lookupMethod(ASTNode caller, ASTNode child, String name) { if(caller == getArgListNoTransform()) { int childIndex = caller.getIndexOfChild(child); return unqualifiedScope().lookupMethod(name); } return getParent().Define_Collection_lookupMethod(this, caller, name); } // Declared in LookupType.jrag at line 88 public boolean Define_boolean_hasPackage(ASTNode caller, ASTNode child, String packageName) { if(caller == getArgListNoTransform()) { int childIndex = caller.getIndexOfChild(child); return unqualifiedScope().hasPackage(packageName); } return getParent().Define_boolean_hasPackage(this, caller, packageName); } // Declared in LookupType.jrag at line 166 public SimpleSet Define_SimpleSet_lookupType(ASTNode caller, ASTNode child, String name) { if(caller == getArgListNoTransform()) { int childIndex = caller.getIndexOfChild(child); return unqualifiedScope().lookupType(name); } return getParent().Define_SimpleSet_lookupType(this, caller, name); } // Declared in LookupVariable.jrag at line 131 public SimpleSet Define_SimpleSet_lookupVariable(ASTNode caller, ASTNode child, String name) { if(caller == getArgListNoTransform()) { int childIndex = caller.getIndexOfChild(child); return unqualifiedScope().lookupVariable(name); } return getParent().Define_SimpleSet_lookupVariable(this, caller, name); } // Declared in SyntacticClassification.jrag at line 121 public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) { if(caller == getArgListNoTransform()) { int childIndex = caller.getIndexOfChild(child); return NameType.EXPRESSION_NAME; } return getParent().Define_NameType_nameType(this, caller); } // Declared in TypeHierarchyCheck.jrag at line 18 public String Define_String_methodHost(ASTNode caller, ASTNode child) { if(true) { int childIndex = this.getIndexOfChild(caller); return unqualifiedScope().methodHost(); } return getParent().Define_String_methodHost(this, caller); } // Declared in TypeHierarchyCheck.jrag at line 130 public boolean Define_boolean_inExplicitConstructorInvocation(ASTNode caller, ASTNode child) { if(caller == getArgListNoTransform()) { int childIndex = caller.getIndexOfChild(child); return true; } return getParent().Define_boolean_inExplicitConstructorInvocation(this, caller); } public ASTNode rewriteTo() { return super.rewriteTo(); } }