soot.JastAddJ.SuperConstructorAccess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of soot Show documentation
Show all versions of soot Show documentation
A Java Optimization Framework
/* 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 SuperConstructorAccess : {@link ConstructorAccess};
* @ast node
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/java.ast:22
*/
public class SuperConstructorAccess extends ConstructorAccess implements Cloneable {
/**
* @apilevel low-level
*/
public void flushCache() {
super.flushCache();
decls_computed = false;
decls_value = null;
}
/**
* @apilevel internal
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/**
* @apilevel internal
*/
@SuppressWarnings({"unchecked", "cast"})
public SuperConstructorAccess clone() throws CloneNotSupportedException {
SuperConstructorAccess node = (SuperConstructorAccess)super.clone();
node.decls_computed = false;
node.decls_value = null;
node.in$Circle(false);
node.is$Final(false);
return node;
}
/**
* @apilevel internal
*/
@SuppressWarnings({"unchecked", "cast"})
public SuperConstructorAccess copy() {
try {
SuperConstructorAccess node = (SuperConstructorAccess) 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 SuperConstructorAccess fullCopy() {
SuperConstructorAccess tree = (SuperConstructorAccess) 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 TypeHierarchyCheck
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:63
*/
public void nameCheck() {
super.nameCheck();
// 8.8.5.1
TypeDecl c = hostType();
TypeDecl s = c.isClassDecl() && ((ClassDecl)c).hasSuperclass() ? ((ClassDecl)c).superclass() : unknownType();
if(isQualified()) {
if(!s.isInnerType() || s.inStaticContext())
error("the super type " + s.typeName() + " of " + c.typeName() +
" is not an inner class");
else if(!qualifier().type().instanceOf(s.enclosingType()))
error("The type of this primary expression, " +
qualifier().type().typeName() + " is not enclosing the super type, " +
s.typeName() + ", of " + c.typeName());
}
if(!isQualified() && s.isInnerType()) {
if(!c.isInnerType()) {
error("no enclosing instance for " + s.typeName() + " when accessed in " + this);
}
}
if(s.isInnerType() && hostType().instanceOf(s.enclosingType()))
error("cannot reference this before supertype constructor has been called");
}
/**
* @ast method
* @aspect Transformations
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Backend/Transformations.jrag:149
*/
public void transformation() {
// this$val
addEnclosingVariables();
// touch accessorIndex to 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:239
*/
public void collectTypesToSignatures(Collection set) {
super.collectTypesToSignatures(set);
addDependencyIfNeeded(set, decl().erasedConstructor().hostType());
}
/**
* @ast method
*
*/
public SuperConstructorAccess() {
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 SuperConstructorAccess(String p0, List p1) {
setID(p0);
setChild(p1, 0);
}
/**
* @ast method
*
*/
public SuperConstructorAccess(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;
}
/**
* 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 GenericsCodegen
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/GenericsCodegen.jrag:255
*/
public soot.Value eval(Body b) {
ConstructorDecl c = decl().erasedConstructor();
// this
Local base = b.emitThis(hostType());
int index = 0;
ArrayList list = new ArrayList();
if(c.needsEnclosing()) {
if(hasPrevExpr() && !prevExpr().isTypeAccess()) {
list.add(asImmediate(b, prevExpr().eval(b)));
}
else {
if(hostType().needsSuperEnclosing()) {
soot.Type type = ((ClassDecl)hostType()).superclass().enclosingType().getSootType();
if(hostType().needsEnclosing())
list.add(asImmediate(b, b.newParameterRef(type, 1, this)));
else
list.add(asImmediate(b, b.newParameterRef(type, 0, this)));
}
else {
list.add(emitThis(b, superConstructorQualifier(c.hostType().enclosingType())));
}
}
}
// 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 isDAbefore(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 isDUbefore(v); }
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:77
*/
@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() {
Collection c = hasPrevExpr() && !prevExpr().isTypeAccess() ?
hostType().lookupSuperConstructor() : lookupSuperConstructor();
return chooseConstructor(c, getArgList());
}
/**
* @attribute syn
* @aspect Names
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/QualifiedNames.jrag:20
*/
public String name() {
ASTNode$State state = state();
try { return "super"; }
finally {
}
}
/**
* @attribute syn
* @aspect AccessTypes
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:49
*/
public boolean isSuperConstructorAccess() {
ASTNode$State state = state();
try { return true; }
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.EXPRESSION_NAME; }
finally {
}
}
/**
* @attribute inh
* @aspect ConstructScope
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupConstructor.jrag:19
*/
@SuppressWarnings({"unchecked", "cast"})
public Collection lookupSuperConstructor() {
ASTNode$State state = state();
Collection lookupSuperConstructor_value = getParent().Define_Collection_lookupSuperConstructor(this, null);
return lookupSuperConstructor_value;
}
/**
* @attribute inh
* @aspect TypeCheck
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/TypeCheck.jrag:503
*/
@SuppressWarnings({"unchecked", "cast"})
public TypeDecl enclosingInstance() {
ASTNode$State state = state();
TypeDecl enclosingInstance_value = getParent().Define_TypeDecl_enclosingInstance(this, null);
return enclosingInstance_value;
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupType.jrag:89
* @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 super.Define_boolean_hasPackage(caller, child, packageName);
}
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/LookupVariable.jrag:134
* @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 super.Define_SimpleSet_lookupVariable(caller, child, name);
}
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/TypeHierarchyCheck.jrag:131
* @apilevel internal
*/
public boolean Define_boolean_inExplicitConstructorInvocation(ASTNode caller, ASTNode child) {
if(caller == getArgListNoTransform()) {
int childIndex = caller.getIndexOfChild(child);
return true;
}
else { return super.Define_boolean_inExplicitConstructorInvocation(caller, child);
}
}
/**
* @apilevel internal
*/
public ASTNode rewriteTo() {
return super.rewriteTo();
}
}