All Downloads are FREE. Search and download functionalities are using the official Maven repository.

soot.JastAddJ.AnnotationDecl Maven / Gradle / Ivy

There is a newer version: 4.6.0
Show newest version
/* 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 AnnotationDecl : {@link InterfaceDecl} ::= SuperInterfaceId:{@link Access}*;
 * @ast node
 * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Annotations.ast:2
 */
public class AnnotationDecl extends InterfaceDecl implements Cloneable {
  /**
   * @apilevel low-level
   */
  public void flushCache() {
    super.flushCache();
    getSuperInterfaceIdList_computed = false;
    getSuperInterfaceIdList_value = null;
    containsElementOf_TypeDecl_values = null;
  }
  /**
   * @apilevel internal
   */
  public void flushCollectionCache() {
    super.flushCollectionCache();
  }
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public AnnotationDecl clone() throws CloneNotSupportedException {
    AnnotationDecl node = (AnnotationDecl)super.clone();
    node.getSuperInterfaceIdList_computed = false;
    node.getSuperInterfaceIdList_value = null;
    node.containsElementOf_TypeDecl_values = null;
    node.in$Circle(false);
    node.is$Final(false);
    return node;
  }
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public AnnotationDecl copy() {
    try {
      AnnotationDecl node = (AnnotationDecl) 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 AnnotationDecl fullCopy() {
    AnnotationDecl tree = (AnnotationDecl) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
          switch (i) {
          case 3:
            tree.children[i] = new List();
            continue;
          }
        ASTNode child = (ASTNode) children[i];
        if(child != null) {
          child = child.fullCopy();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /**
   * @ast method 
   * @aspect Annotations
   * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Annotations.jrag:103
   */
  public void typeCheck() {
    super.typeCheck();
    for(int i = 0; i < getNumBodyDecl(); i++) {
      if(getBodyDecl(i) instanceof MethodDecl) {
        MethodDecl m = (MethodDecl)getBodyDecl(i);
        if(!m.type().isValidAnnotationMethodReturnType())
          m.error("invalid type for annotation member");
        if(m.annotationMethodOverride())
          m.error("annotation method overrides " + m.signature());
      }
    }
    if(containsElementOf(this))
      error("cyclic annotation element type");
  }
  /**
   * @ast method 
   * @aspect Annotations
   * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Annotations.jrag:562
   */
  public void toString(StringBuffer s) {
    getModifiers().toString(s);
    s.append("@interface " + name());
    s.append(" {");
    for(int i=0; i < getNumBodyDecl(); i++) {
      getBodyDecl(i).toString(s);
    }
    s.append(indent() + "}");
  }
  /**
   * @ast method 
   * 
   */
  public AnnotationDecl() {
    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[3];
    setChild(new List(), 1);
    setChild(new List(), 2);
  }
  /**
   * @ast method 
   * 
   */
  public AnnotationDecl(Modifiers p0, String p1, List p2) {
    setChild(p0, 0);
    setID(p1);
    setChild(p2, 1);
  }
  /**
   * @ast method 
   * 
   */
  public AnnotationDecl(Modifiers p0, beaver.Symbol p1, List p2) {
    setChild(p0, 0);
    setID(p1);
    setChild(p2, 1);
  }
  /**
   * @apilevel low-level
   * @ast method 
   * 
   */
  protected int numChildren() {
    return 2;
  }
  /**
   * @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 BodyDecl list. * @param list The new list node to be used as the BodyDecl list. * @apilevel high-level * @ast method * */ public void setBodyDeclList(List list) { setChild(list, 1); } /** * Retrieves the number of children in the BodyDecl list. * @return Number of children in the BodyDecl list. * @apilevel high-level * @ast method * */ public int getNumBodyDecl() { return getBodyDeclList().getNumChild(); } /** * Retrieves the number of children in the BodyDecl list. * Calling this method will not trigger rewrites.. * @return Number of children in the BodyDecl list. * @apilevel low-level * @ast method * */ public int getNumBodyDeclNoTransform() { return getBodyDeclListNoTransform().getNumChildNoTransform(); } /** * Retrieves the element at index {@code i} in the BodyDecl list.. * @param i Index of the element to return. * @return The element at position {@code i} in the BodyDecl list. * @apilevel high-level * @ast method * */ @SuppressWarnings({"unchecked", "cast"}) public BodyDecl getBodyDecl(int i) { return (BodyDecl)getBodyDeclList().getChild(i); } /** * Append an element to the BodyDecl list. * @param node The element to append to the BodyDecl list. * @apilevel high-level * @ast method * */ public void addBodyDecl(BodyDecl node) { List list = (parent == null || state == null) ? getBodyDeclListNoTransform() : getBodyDeclList(); list.addChild(node); } /** * @apilevel low-level * @ast method * */ public void addBodyDeclNoTransform(BodyDecl node) { List list = getBodyDeclListNoTransform(); list.addChild(node); } /** * Replaces the BodyDecl 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 setBodyDecl(BodyDecl node, int i) { List list = getBodyDeclList(); list.setChild(node, i); } /** * Retrieves the BodyDecl list. * @return The node representing the BodyDecl list. * @apilevel high-level * @ast method * */ public List getBodyDecls() { return getBodyDeclList(); } /** * Retrieves the BodyDecl list. *

This method does not invoke AST transformations.

* @return The node representing the BodyDecl list. * @apilevel low-level * @ast method * */ public List getBodyDeclsNoTransform() { return getBodyDeclListNoTransform(); } /** * Retrieves the BodyDecl list. * @return The node representing the BodyDecl list. * @apilevel high-level * @ast method * */ @SuppressWarnings({"unchecked", "cast"}) public List getBodyDeclList() { List list = (List)getChild(1); list.getNumChild(); return list; } /** * Retrieves the BodyDecl list. *

This method does not invoke AST transformations.

* @return The node representing the BodyDecl list. * @apilevel low-level * @ast method * */ @SuppressWarnings({"unchecked", "cast"}) public List getBodyDeclListNoTransform() { return (List)getChildNoTransform(1); } /** * Replaces the SuperInterfaceId list. * @param list The new list node to be used as the SuperInterfaceId list. * @apilevel high-level * @ast method * */ public void setSuperInterfaceIdList(List list) { setChild(list, 2); } /** * Retrieves the number of children in the SuperInterfaceId list. * @return Number of children in the SuperInterfaceId list. * @apilevel high-level * @ast method * */ public int getNumSuperInterfaceId() { return getSuperInterfaceIdList().getNumChild(); } /** * Retrieves the number of children in the SuperInterfaceId list. * Calling this method will not trigger rewrites.. * @return Number of children in the SuperInterfaceId list. * @apilevel low-level * @ast method * */ public int getNumSuperInterfaceIdNoTransform() { return getSuperInterfaceIdListNoTransform().getNumChildNoTransform(); } /** * Retrieves the element at index {@code i} in the SuperInterfaceId list.. * @param i Index of the element to return. * @return The element at position {@code i} in the SuperInterfaceId list. * @apilevel high-level * @ast method * */ @SuppressWarnings({"unchecked", "cast"}) public Access getSuperInterfaceId(int i) { return (Access)getSuperInterfaceIdList().getChild(i); } /** * Append an element to the SuperInterfaceId list. * @param node The element to append to the SuperInterfaceId list. * @apilevel high-level * @ast method * */ public void addSuperInterfaceId(Access node) { List list = (parent == null || state == null) ? getSuperInterfaceIdListNoTransform() : getSuperInterfaceIdList(); list.addChild(node); } /** * @apilevel low-level * @ast method * */ public void addSuperInterfaceIdNoTransform(Access node) { List list = getSuperInterfaceIdListNoTransform(); list.addChild(node); } /** * Replaces the SuperInterfaceId 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 setSuperInterfaceId(Access node, int i) { List list = getSuperInterfaceIdList(); list.setChild(node, i); } /** * Retrieves the SuperInterfaceId list. * @return The node representing the SuperInterfaceId list. * @apilevel high-level * @ast method * */ public List getSuperInterfaceIds() { return getSuperInterfaceIdList(); } /** * Retrieves the SuperInterfaceId list. *

This method does not invoke AST transformations.

* @return The node representing the SuperInterfaceId list. * @apilevel low-level * @ast method * */ public List getSuperInterfaceIdsNoTransform() { return getSuperInterfaceIdListNoTransform(); } /** * Retrieves the SuperInterfaceId list. *

This method does not invoke AST transformations.

* @return The node representing the SuperInterfaceId list. * @apilevel low-level * @ast method * */ public List getSuperInterfaceIdListNoTransform() { return (List)getChildNoTransform(2); } /** * Retrieves the child position of the SuperInterfaceId list. * @return The the child position of the SuperInterfaceId list. * @apilevel low-level * @ast method * */ protected int getSuperInterfaceIdListChildPosition() { return 2; } /** * @apilevel internal */ protected boolean getSuperInterfaceIdList_computed = false; /** * @apilevel internal */ protected List getSuperInterfaceIdList_value; /* The direct superinterface of an annotation type is always annotation.Annotation.* @attribute syn nta * @aspect Annotations * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Annotations.jrag:99 */ @SuppressWarnings({"unchecked", "cast"}) public List getSuperInterfaceIdList() { if(getSuperInterfaceIdList_computed) { return (List) getChild(getSuperInterfaceIdListChildPosition()); } ASTNode$State state = state(); int num = state.boundariesCrossed; boolean isFinal = this.is$Final(); getSuperInterfaceIdList_value = getSuperInterfaceIdList_compute(); setSuperInterfaceIdList(getSuperInterfaceIdList_value); if(isFinal && num == state().boundariesCrossed) getSuperInterfaceIdList_computed = true; return (List) getChild(getSuperInterfaceIdListChildPosition()); } /** * @apilevel internal */ private List getSuperInterfaceIdList_compute() { return new List().add(new TypeAccess("java.lang.annotation", "Annotation")); } /* It is a compile-time error if the return type of a method declared in an annotation type is any type other than one of the following: one of the primitive types, String, Class and any invocation of Class, an enum type (\ufffd8.9), an annotation type, or an array (\ufffd10) of one of the preceding types.* @attribute syn * @aspect Annotations * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Annotations.jrag:121 */ public boolean isValidAnnotationMethodReturnType() { ASTNode$State state = state(); try { return true; } finally { } } protected java.util.Map containsElementOf_TypeDecl_values; /* It is a compile-time error if an annotation type T contains an element of type T, either directly or indirectly.* @attribute syn * @aspect Annotations * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Annotations.jrag:144 */ @SuppressWarnings({"unchecked", "cast"}) public boolean containsElementOf(TypeDecl typeDecl) { Object _parameters = typeDecl; if(containsElementOf_TypeDecl_values == null) containsElementOf_TypeDecl_values = new java.util.HashMap(4); ASTNode$State.CircularValue _value; if(containsElementOf_TypeDecl_values.containsKey(_parameters)) { Object _o = containsElementOf_TypeDecl_values.get(_parameters); if(!(_o instanceof ASTNode$State.CircularValue)) { return ((Boolean)_o).booleanValue(); } else _value = (ASTNode$State.CircularValue)_o; } else { _value = new ASTNode$State.CircularValue(); containsElementOf_TypeDecl_values.put(_parameters, _value); _value.value = Boolean.valueOf(false); } ASTNode$State state = state(); if (!state.IN_CIRCLE) { state.IN_CIRCLE = true; int num = state.boundariesCrossed; boolean isFinal = this.is$Final(); boolean new_containsElementOf_TypeDecl_value; do { _value.visited = new Integer(state.CIRCLE_INDEX); state.CHANGE = false; new_containsElementOf_TypeDecl_value = containsElementOf_compute(typeDecl); if (new_containsElementOf_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { state.CHANGE = true; _value.value = Boolean.valueOf(new_containsElementOf_TypeDecl_value); } state.CIRCLE_INDEX++; } while (state.CHANGE); if(isFinal && num == state().boundariesCrossed) { containsElementOf_TypeDecl_values.put(_parameters, new_containsElementOf_TypeDecl_value); } else { containsElementOf_TypeDecl_values.remove(_parameters); state.RESET_CYCLE = true; containsElementOf_compute(typeDecl); state.RESET_CYCLE = false; } state.IN_CIRCLE = false; return new_containsElementOf_TypeDecl_value; } if(!new Integer(state.CIRCLE_INDEX).equals(_value.visited)) { _value.visited = new Integer(state.CIRCLE_INDEX); boolean new_containsElementOf_TypeDecl_value = containsElementOf_compute(typeDecl); if (state.RESET_CYCLE) { containsElementOf_TypeDecl_values.remove(_parameters); } else if (new_containsElementOf_TypeDecl_value!=((Boolean)_value.value).booleanValue()) { state.CHANGE = true; _value.value = new_containsElementOf_TypeDecl_value; } return new_containsElementOf_TypeDecl_value; } return ((Boolean)_value.value).booleanValue(); } /** * @apilevel internal */ private boolean containsElementOf_compute(TypeDecl typeDecl) { for(int i = 0; i < getNumBodyDecl(); i++) { if(getBodyDecl(i) instanceof MethodDecl) { MethodDecl m = (MethodDecl)getBodyDecl(i); if(m.type() == typeDecl) return true; if(m.type() instanceof AnnotationDecl && ((AnnotationDecl)m.type()).containsElementOf(typeDecl)) return true; } } return false; } /** * @attribute syn * @aspect Annotations * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Annotations.jrag:545 */ public boolean isAnnotationDecl() { ASTNode$State state = state(); try { return true; } finally { } } /** * @attribute syn * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:90 */ public int sootTypeModifiers() { ASTNode$State state = state(); try { return super.sootTypeModifiers() | Modifiers.ACC_ANNOTATION; } finally { } } /** * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.5Frontend/Annotations.jrag:77 * @apilevel internal */ public boolean Define_boolean_mayUseAnnotationTarget(ASTNode caller, ASTNode child, String name) { if(caller == getModifiersNoTransform()) { return name.equals("ANNOTATION_TYPE") || name.equals("TYPE"); } else { return super.Define_boolean_mayUseAnnotationTarget(caller, child, name); } } /** * @apilevel internal */ public ASTNode rewriteTo() { return super.rewriteTo(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy