soot.JastAddJ.EnumConstant 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 EnumConstant : {@link FieldDeclaration} ::= {@link Modifiers} <ID:String> Arg:{@link Expr}* [Init:{@link Expr}] TypeAccess:{@link Access};
* @ast node
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.ast:3
*/
public class EnumConstant extends FieldDeclaration implements Cloneable {
/**
* @apilevel low-level
*/
public void flushCache() {
super.flushCache();
getTypeAccess_computed = false;
getTypeAccess_value = null;
localMethodsSignatureMap_computed = false;
localMethodsSignatureMap_value = null;
}
/**
* @apilevel internal
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/**
* @apilevel internal
*/
@SuppressWarnings({"unchecked", "cast"})
public EnumConstant clone() throws CloneNotSupportedException {
EnumConstant node = (EnumConstant)super.clone();
node.getTypeAccess_computed = false;
node.getTypeAccess_value = null;
node.localMethodsSignatureMap_computed = false;
node.localMethodsSignatureMap_value = null;
node.in$Circle(false);
node.is$Final(false);
return node;
}
/**
* @apilevel internal
*/
@SuppressWarnings({"unchecked", "cast"})
public EnumConstant copy() {
try {
EnumConstant node = (EnumConstant) 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 EnumConstant fullCopy() {
EnumConstant tree = (EnumConstant) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
switch (i) {
case 4:
tree.children[i] = null;
continue;
}
ASTNode child = (ASTNode) children[i];
if(child != null) {
child = child.fullCopy();
tree.setChild(child, i);
}
}
}
return tree;
}
/**
* @ast method
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:197
*/
public EnumConstant(Modifiers mods, String name, List args, List bds) {
this(mods, name, args, new Opt(new EnumInstanceExpr(createOptAnonymousDecl(bds))));
}
/**
* @ast method
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:236
*/
private static Opt createOptAnonymousDecl(List bds) {
if(bds.getNumChildNoTransform() == 0)
return new Opt();
return new Opt(
new AnonymousDecl(
new Modifiers(),
"Anonymous",
bds
)
);
}
/**
* @ast method
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:249
*/
public int getNumBodyDecl() {
int cnt = 0;
ClassInstanceExpr init = (ClassInstanceExpr)getInit();
if(!init.hasTypeDecl())
return 0;
for(BodyDecl bd : init.getTypeDecl().getBodyDecls())
if(!(bd instanceof ConstructorDecl))
++cnt;
return cnt;
}
/**
* @ast method
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:260
*/
public BodyDecl getBodyDecl(int i) {
ClassInstanceExpr init = (ClassInstanceExpr)getInit();
if(init.hasTypeDecl())
for(BodyDecl bd : init.getTypeDecl().getBodyDecls())
if(!(bd instanceof ConstructorDecl))
if(i-- == 0)
return bd;
throw new ArrayIndexOutOfBoundsException(i);
}
/**
* @ast method
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:592
*/
public void toString(StringBuffer s) {
s.append(indent());
getModifiers().toString(s);
s.append(getID());
s.append("(");
if(getNumArg() > 0) {
getArg(0).toString(s);
for(int i = 1; i < getNumArg(); i++) {
s.append(", ");
getArg(i).toString(s);
}
}
s.append(")");
if(getNumBodyDecl() > 0) {
s.append(" {");
for(int i=0; i < getNumBodyDecl(); i++) {
BodyDecl d = getBodyDecl(i);
d.toString(s);
}
s.append(indent() + "}");
}
s.append(",\n");
}
/**
* @ast method
*
*/
public EnumConstant() {
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[4];
setChild(new List(), 1);
setChild(new Opt(), 2);
}
/**
* @ast method
*
*/
public EnumConstant(Modifiers p0, String p1, List p2, Opt p3) {
setChild(p0, 0);
setID(p1);
setChild(p2, 1);
setChild(p3, 2);
}
/**
* @ast method
*
*/
public EnumConstant(Modifiers p0, beaver.Symbol p1, List p2, Opt p3) {
setChild(p0, 0);
setID(p1);
setChild(p2, 1);
setChild(p3, 2);
}
/**
* @apilevel low-level
* @ast method
*
*/
protected int numChildren() {
return 3;
}
/**
* @apilevel internal
* @ast method
*
*/
public boolean mayHaveRewrite() {
return false;
}
/**
* Replaces the Modifiers child.
* @param node The new node to replace the Modifiers child.
* @apilevel high-level
* @ast method
*
*/
public void setModifiers(Modifiers node) {
setChild(node, 0);
}
/**
* Retrieves the Modifiers child.
* @return The current node used as the Modifiers child.
* @apilevel high-level
* @ast method
*
*/
public Modifiers getModifiers() {
return (Modifiers)getChild(0);
}
/**
* Retrieves the Modifiers child.
* This method does not invoke AST transformations.
* @return The current node used as the Modifiers child.
* @apilevel low-level
* @ast method
*
*/
public Modifiers getModifiersNoTransform() {
return (Modifiers)getChildNoTransform(0);
}
/**
* 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, 1);
}
/**
* 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(1);
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(1);
}
/**
* Replaces the optional node for the Init child. This is the {@code Opt} node containing the child Init, not the actual child!
* @param opt The new node to be used as the optional node for the Init child.
* @apilevel low-level
* @ast method
*
*/
public void setInitOpt(Opt opt) {
setChild(opt, 2);
}
/**
* Check whether the optional Init child exists.
* @return {@code true} if the optional Init child exists, {@code false} if it does not.
* @apilevel high-level
* @ast method
*
*/
public boolean hasInit() {
return getInitOpt().getNumChild() != 0;
}
/**
* Retrieves the (optional) Init child.
* @return The Init child, if it exists. Returns {@code null} otherwise.
* @apilevel low-level
* @ast method
*
*/
@SuppressWarnings({"unchecked", "cast"})
public Expr getInit() {
return (Expr)getInitOpt().getChild(0);
}
/**
* Replaces the (optional) Init child.
* @param node The new node to be used as the Init child.
* @apilevel high-level
* @ast method
*
*/
public void setInit(Expr node) {
getInitOpt().setChild(node, 0);
}
/**
* @apilevel low-level
* @ast method
*
*/
@SuppressWarnings({"unchecked", "cast"})
public Opt getInitOpt() {
return (Opt)getChild(2);
}
/**
* Retrieves the optional node for child Init. This is the {@code Opt} node containing the child Init, not the actual child!
* This method does not invoke AST transformations.
* @return The optional node for child Init.
* @apilevel low-level
* @ast method
*
*/
@SuppressWarnings({"unchecked", "cast"})
public Opt getInitOptNoTransform() {
return (Opt)getChildNoTransform(2);
}
/**
* Replaces the TypeAccess child.
* @param node The new node to replace the TypeAccess child.
* @apilevel high-level
* @ast method
*
*/
public void setTypeAccess(Access node) {
setChild(node, 3);
}
/**
* Retrieves the TypeAccess child.
* This method does not invoke AST transformations.
* @return The current node used as the TypeAccess child.
* @apilevel low-level
* @ast method
*
*/
public Access getTypeAccessNoTransform() {
return (Access)getChildNoTransform(3);
}
/**
* Retrieves the child position of the optional child TypeAccess.
* @return The the child position of the optional child TypeAccess.
* @apilevel low-level
* @ast method
*
*/
protected int getTypeAccessChildPosition() {
return 3;
}
/**
* @attribute syn
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:26
*/
public boolean isEnumConstant() {
ASTNode$State state = state();
try { return true; }
finally {
}
}
/**
* @attribute syn
* @aspect Modifiers
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/Modifiers.jrag:239
*/
public boolean isPublic() {
ASTNode$State state = state();
try { return true; }
finally {
}
}
/**
* @attribute syn
* @aspect Modifiers
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/Modifiers.jrag:242
*/
public boolean isStatic() {
ASTNode$State state = state();
try { return true; }
finally {
}
}
/**
* @attribute syn
* @aspect Modifiers
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Frontend/Modifiers.jrag:244
*/
public boolean isFinal() {
ASTNode$State state = state();
try { return true; }
finally {
}
}
/**
* @apilevel internal
*/
protected boolean getTypeAccess_computed = false;
/**
* @apilevel internal
*/
protected Access getTypeAccess_value;
/**
* @attribute syn nta
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:193
*/
@SuppressWarnings({"unchecked", "cast"})
public Access getTypeAccess() {
if(getTypeAccess_computed) {
return (Access) getChild(getTypeAccessChildPosition());
}
ASTNode$State state = state();
int num = state.boundariesCrossed;
boolean isFinal = this.is$Final();
getTypeAccess_value = getTypeAccess_compute();
setTypeAccess(getTypeAccess_value);
if(isFinal && num == state().boundariesCrossed) getTypeAccess_computed = true;
return (Access) getChild(getTypeAccessChildPosition());
}
/**
* @apilevel internal
*/
private Access getTypeAccess_compute() {
return hostType().createQualifiedAccess();
}
/**
* @attribute syn
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:689
*/
public SimpleSet localMethodsSignature(String signature) {
ASTNode$State state = state();
try {
SimpleSet set = (SimpleSet)localMethodsSignatureMap().get(signature);
if(set != null) return set;
return SimpleSet.emptySet;
}
finally {
}
}
/**
* @apilevel internal
*/
protected boolean localMethodsSignatureMap_computed = false;
/**
* @apilevel internal
*/
protected HashMap localMethodsSignatureMap_value;
/**
* @attribute syn
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:696
*/
@SuppressWarnings({"unchecked", "cast"})
public HashMap localMethodsSignatureMap() {
if(localMethodsSignatureMap_computed) {
return localMethodsSignatureMap_value;
}
ASTNode$State state = state();
int num = state.boundariesCrossed;
boolean isFinal = this.is$Final();
localMethodsSignatureMap_value = localMethodsSignatureMap_compute();
if(isFinal && num == state().boundariesCrossed) localMethodsSignatureMap_computed = true;
return localMethodsSignatureMap_value;
}
/**
* @apilevel internal
*/
private HashMap localMethodsSignatureMap_compute() {
HashMap map = new HashMap(getNumBodyDecl());
for(int i = 0; i < getNumBodyDecl(); i++) {
if(getBodyDecl(i) instanceof MethodDecl) {
MethodDecl decl = (MethodDecl)getBodyDecl(i);
map.put(decl.signature(), decl);
}
}
return map;
}
/**
* @attribute syn
* @aspect Enums
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:707
*/
public boolean implementsMethod(MethodDecl method) {
ASTNode$State state = state();
try {
SimpleSet set = (SimpleSet)localMethodsSignature(method.signature());
if (set.size() == 1) {
MethodDecl n = (MethodDecl)set.iterator().next();
if (!n.isAbstract())
return true;
}
return false;
}
finally {
}
}
/**
* @attribute syn
* @aspect EmitJimple
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:127
*/
public int sootTypeModifiers() {
ASTNode$State state = state();
try { return super.sootTypeModifiers() | Modifiers.ACC_ENUM; }
finally {
}
}
/**
* @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Enums.jrag:489
* @apilevel internal
*/
public NameType Define_NameType_nameType(ASTNode caller, ASTNode child) {
if(caller == getTypeAccessNoTransform()) {
return NameType.TYPE_NAME;
}
else { return super.Define_NameType_nameType(caller, child);
}
}
/**
* @apilevel internal
*/
public ASTNode rewriteTo() {
return super.rewriteTo();
}
}