soot.JastAddJ.ConstructorAccess Maven / Gradle / Ivy
/* This file was generated with JastAdd2 (http://jastadd.org) version R20130212 (r1031) */
package soot.JastAddJ;
import java.util.HashSet;
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;
/**
* @production ConstructorAccess : {@link Access} ::= <ID:String> Arg:{@link Expr}*;
* @ast node
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/java.ast:21
*/
public class ConstructorAccess extends Access implements Cloneable {
/**
* @apilevel low-level
*/
public void flushCache() {
super.flushCache();
decls_computed = false;
decls_value = null;
decl_computed = false;
decl_value = null;
type_computed = false;
type_value = null;
}
/**
* @apilevel internal
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/**
* @apilevel internal
*/
@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;
}
/**
* @apilevel internal
*/
@SuppressWarnings({"unchecked", "cast"})
public ConstructorAccess copy() {
try {
ConstructorAccess node = (ConstructorAccess) clone();
node.parent = null;
if(children != null)
node.children = (ASTNode[]) children.clone();
return node;
} catch (CloneNotSupportedException e) {
throw new Error("Error: clone not supported for " +
getClass().getName());
}
}
/**
* Create a deep copy of the AST subtree at this node.
* The copy is dangling, i.e. has no parent.
* @return dangling copy of the subtree at this node
* @apilevel low-level
*/
@SuppressWarnings({"unchecked", "cast"})
public ConstructorAccess fullCopy() {
ConstructorAccess tree = (ConstructorAccess) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
ASTNode child = (ASTNode) children[i];
if(child != null) {
child = child.fullCopy();
tree.setChild(child, i);
}
}
}
return tree;
}
/**
* @ast method
* @aspect ExceptionHandling
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/ExceptionHandling.jrag:111
*/
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());
}
}
/**
* @ast method
* @aspect ExceptionHandling
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/ExceptionHandling.jrag:272
*/
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);
}
/**
* @ast method
* @aspect NameCheck
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/NameCheck.jrag:117
*/
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());
}
}
}
/**
* @ast method
* @aspect PrettyPrint
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:470
*/
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(")");
}
/**
* @ast method
* @aspect Annotations
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Annotations.jrag: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");
}
/**
* @ast method
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:171
*/
protected void transformEnumConstructors() {
super.transformEnumConstructors();
getArgList().insertChild(new VarAccess("@p0"),0);
getArgList().insertChild(new VarAccess("@p1"),1);
}
/**
* @ast method
* @aspect InnerClasses
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Backend/InnerClasses.jrag:469
*/
// add val$name as arguments to the constructor
protected boolean addEnclosingVariables = true;
/**
* @ast method
* @aspect InnerClasses
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Backend/InnerClasses.jrag:470
*/
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()));
}
}
/**
* @ast method
* @aspect Transformations
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Backend/Transformations.jrag:138
*/
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();
}
/**
* @ast method
* @aspect EmitJimpleRefinements
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/SootJastAddJ/EmitJimpleRefinements.jrag:235
*/
public void collectTypesToSignatures(Collection set) {
super.collectTypesToSignatures(set);
addDependencyIfNeeded(set, decl().erasedConstructor().hostType());
}
/**
* @ast method
*
*/
public ConstructorAccess() {
super();
}
/**
* Initializes the child array to the correct size.
* Initializes List and Opt nta children.
* @apilevel internal
* @ast method
* @ast method
*
*/
public void init$Children() {
children = new ASTNode[1];
setChild(new List(), 0);
}
/**
* @ast method
*
*/
public ConstructorAccess(String p0, List p1) {
setID(p0);
setChild(p1, 0);
}
/**
* @ast method
*
*/
public ConstructorAccess(beaver.Symbol p0, List p1) {
setID(p0);
setChild(p1, 0);
}
/**
* @apilevel low-level
* @ast method
*
*/
protected int numChildren() {
return 1;
}
/**
* @apilevel internal
* @ast method
*
*/
public boolean mayHaveRewrite() {
return false;
}
/**
* Replaces the lexeme ID.
* @param value The new value for the lexeme ID.
* @apilevel high-level
* @ast method
*
*/
public void setID(String value) {
tokenString_ID = value;
}
/**
* @apilevel internal
* @ast method
*
*/
/**
* @apilevel internal
*/
protected String tokenString_ID;
/**
* @ast method
*
*/
public int IDstart;
/**
* @ast method
*
*/
public int IDend;
/**
* JastAdd-internal setter for lexeme ID using the Beaver parser.
* @apilevel internal
* @ast method
*
*/
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();
}
/**
* Retrieves the value for the lexeme ID.
* @return The value for the lexeme ID.
* @apilevel high-level
* @ast method
*
*/
public String getID() {
return tokenString_ID != null ? tokenString_ID : "";
}
/**
* Replaces the Arg list.
* @param list The new list node to be used as the Arg list.
* @apilevel high-level
* @ast method
*
*/
public void setArgList(List list) {
setChild(list, 0);
}
/**
* Retrieves the number of children in the Arg list.
* @return Number of children in the Arg list.
* @apilevel high-level
* @ast method
*
*/
public int getNumArg() {
return getArgList().getNumChild();
}
/**
* Retrieves the number of children in the Arg list.
* Calling this method will not trigger rewrites..
* @return Number of children in the Arg list.
* @apilevel low-level
* @ast method
*
*/
public int getNumArgNoTransform() {
return getArgListNoTransform().getNumChildNoTransform();
}
/**
* Retrieves the element at index {@code i} in the Arg list..
* @param i Index of the element to return.
* @return The element at position {@code i} in the Arg list.
* @apilevel high-level
* @ast method
*
*/
@SuppressWarnings({"unchecked", "cast"})
public Expr getArg(int i) {
return (Expr)getArgList().getChild(i);
}
/**
* Append an element to the Arg list.
* @param node The element to append to the Arg list.
* @apilevel high-level
* @ast method
*
*/
public void addArg(Expr node) {
List list = (parent == null || state == null) ? getArgListNoTransform() : getArgList();
list.addChild(node);
}
/**
* @apilevel low-level
* @ast method
*
*/
public void addArgNoTransform(Expr node) {
List list = getArgListNoTransform();
list.addChild(node);
}
/**
* Replaces the Arg list element at index {@code i} with the new node {@code node}.
* @param node The new node to replace the old list element.
* @param i The list index of the node to be replaced.
* @apilevel high-level
* @ast method
*
*/
public void setArg(Expr node, int i) {
List list = getArgList();
list.setChild(node, i);
}
/**
* Retrieves the Arg list.
* @return The node representing the Arg list.
* @apilevel high-level
* @ast method
*
*/
public List getArgs() {
return getArgList();
}
/**
* Retrieves the Arg list.
* This method does not invoke AST transformations.
* @return The node representing the Arg list.
* @apilevel low-level
* @ast method
*
*/
public List getArgsNoTransform() {
return getArgListNoTransform();
}
/**
* Retrieves the Arg list.
* @return The node representing the Arg list.
* @apilevel high-level
* @ast method
*
*/
@SuppressWarnings({"unchecked", "cast"})
public List getArgList() {
List list = (List)getChild(0);
list.getNumChild();
return list;
}
/**
* Retrieves the Arg list.
* This method does not invoke AST transformations.
* @return The node representing the Arg list.
* @apilevel low-level
* @ast method
*
*/
@SuppressWarnings({"unchecked", "cast"})
public List getArgListNoTransform() {
return (List)getChildNoTransform(0);
}
/**
* @ast method
* @aspect VariableArityParametersCodegen
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/VariableArityParametersCodegen.jrag: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();
}
/**
* @ast method
* @aspect GenericsCodegen
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/GenericsCodegen.jrag: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);
}
}
/**
* @attribute syn
* @aspect DA
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:235
*/
public boolean isDAafter(Variable v) {
ASTNode$State state = state();
try { return decl().isDAafter(v); }
finally {
}
}
/**
* @attribute syn
* @aspect DU
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/DefiniteAssignment.jrag:694
*/
public boolean isDUafter(Variable v) {
ASTNode$State state = state();
try { return decl().isDUafter(v); }
finally {
}
}
/**
* @attribute syn
* @aspect ConstructScope
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupConstructor.jrag:50
*/
public boolean applicableAndAccessible(ConstructorDecl decl) {
ASTNode$State state = state();
try { return decl.applicable(getArgList()) && decl.accessibleFrom(hostType()); }
finally {
}
}
/**
* @apilevel internal
*/
protected boolean decls_computed = false;
/**
* @apilevel internal
*/
protected SimpleSet decls_value;
/**
* @attribute syn
* @aspect MethodSignature15
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/MethodSignature.jrag:74
*/
@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;
}
/**
* @apilevel internal
*/
private SimpleSet decls_compute() {
return chooseConstructor(lookupConstructor(), getArgList());
}
/**
* @apilevel internal
*/
protected boolean decl_computed = false;
/**
* @apilevel internal
*/
protected ConstructorDecl decl_value;
/**
* @attribute syn
* @aspect ConstructScope
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupConstructor.jrag: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;
}
/**
* @apilevel internal
*/
private ConstructorDecl decl_compute() {
SimpleSet decls = decls();
if(decls.size() == 1)
return (ConstructorDecl)decls.iterator().next();
return unknownConstructor();
}
/**
* @attribute syn
* @aspect NameCheck
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/NameCheck.jrag:129
*/
public boolean validArgs() {
ASTNode$State state = state();
try {
for(int i = 0; i < getNumArg(); i++)
if(getArg(i).type().isUnknown())
return false;
return true;
}
finally {
}
}
/**
* @attribute syn
* @aspect Names
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/QualifiedNames.jrag:19
*/
public String name() {
ASTNode$State state = state();
try { return "this"; }
finally {
}
}
/**
* @attribute syn
* @aspect SyntacticClassification
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:56
*/
public NameType predNameType() {
ASTNode$State state = state();
try { return NameType.AMBIGUOUS_NAME; }
finally {
}
}
/**
* @apilevel internal
*/
protected boolean type_computed = false;
/**
* @apilevel internal
*/
protected TypeDecl type_value;
/**
* @attribute syn
* @aspect TypeAnalysis
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag: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;
}
/**
* @apilevel internal
*/
private TypeDecl type_compute() { return decl().type(); }
/**
* @attribute syn
* @aspect MethodSignature15
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/MethodSignature.jrag:326
*/
public int arity() {
ASTNode$State state = state();
try { return getNumArg(); }
finally {
}
}
/**
* @attribute syn
* @aspect VariableArityParameters
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/VariableArityParameters.jrag:47
*/
public boolean invokesVariableArityAsArray() {
ASTNode$State state = state();
try {
if(!decl().isVariableArity())
return false;
if(arity() != decl().arity())
return false;
return getArg(getNumArg()-1).type().methodInvocationConversionTo(decl().lastParameter().type());
}
finally {
}
}
/**
* @attribute inh
* @aspect ExceptionHandling
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/ExceptionHandling.jrag:44
*/
@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;
}
/**
* @attribute inh
* @aspect ConstructScope
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupConstructor.jrag:14
*/
@SuppressWarnings({"unchecked", "cast"})
public Collection lookupConstructor() {
ASTNode$State state = state();
Collection lookupConstructor_value = getParent().Define_Collection_lookupConstructor(this, null);
return lookupConstructor_value;
}
/**
* @attribute inh
* @aspect ConstructScope
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupConstructor.jrag:71
*/
@SuppressWarnings({"unchecked", "cast"})
public ConstructorDecl unknownConstructor() {
ASTNode$State state = state();
ConstructorDecl unknownConstructor_value = getParent().Define_ConstructorDecl_unknownConstructor(this, null);
return unknownConstructor_value;
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupMethod.jrag:29
* @apilevel internal
*/
public Collection Define_Collection_lookupMethod(ASTNode caller, ASTNode child, String name) {
if(caller == getArgListNoTransform()) {
int childIndex = caller.getIndexOfChild(child);
return unqualifiedScope().lookupMethod(name);
}
else { return getParent().Define_Collection_lookupMethod(this, caller, name);
}
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupType.jrag:88
* @apilevel internal
*/
public boolean Define_boolean_hasPackage(ASTNode caller, ASTNode child, String packageName) {
if(caller == getArgListNoTransform()) {
int childIndex = caller.getIndexOfChild(child);
return unqualifiedScope().hasPackage(packageName);
}
else { return getParent().Define_boolean_hasPackage(this, caller, packageName);
}
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupType.jrag:254
* @apilevel internal
*/
public SimpleSet Define_SimpleSet_lookupType(ASTNode caller, ASTNode child, String name) {
if(caller == getArgListNoTransform()) {
int childIndex = caller.getIndexOfChild(child);
return unqualifiedScope().lookupType(name);
}
else { return getParent().Define_SimpleSet_lookupType(this, caller, name);
}
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupVariable.jrag:133
* @apilevel internal
*/
public SimpleSet Define_SimpleSet_lookupVariable(ASTNode caller, ASTNode child, String name) {
if(caller == getArgListNoTransform()) {
int childIndex = caller.getIndexOfChild(child);
return unqualifiedScope().lookupVariable(name);
}
else { return getParent().Define_SimpleSet_lookupVariable(this, caller, name);
}
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:121
* @apilevel internal
*/
public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) {
if(caller == getArgListNoTransform()) {
int childIndex = caller.getIndexOfChild(child);
return NameType.EXPRESSION_NAME;
}
else { return getParent().Define_NameType_nameType(this, caller);
}
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:18
* @apilevel internal
*/
public String Define_String_methodHost(ASTNode caller, ASTNode child) {
{
int childIndex = this.getIndexOfChild(caller);
return unqualifiedScope().methodHost();
}
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:130
* @apilevel internal
*/
public boolean Define_boolean_inExplicitConstructorInvocation(ASTNode caller, ASTNode child) {
if(caller == getArgListNoTransform()) {
int childIndex = caller.getIndexOfChild(child);
return true;
}
else { return getParent().Define_boolean_inExplicitConstructorInvocation(this, caller);
}
}
/**
* @apilevel internal
*/
public ASTNode rewriteTo() {
return super.rewriteTo();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy