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

org.extendj.ast.ClassInstanceExpr Maven / Gradle / Ivy

The newest version!
/* This file was generated with JastAdd2 (http://jastadd.org) version 2.3.0 */
package org.extendj.ast;
import java.util.ArrayList;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.util.Set;
import beaver.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.LinkedHashSet;
import java.util.*;
import org.jastadd.util.PrettyPrintable;
import org.jastadd.util.PrettyPrinter;
import java.util.zip.*;
import java.io.*;
import org.jastadd.util.*;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
/**
 * @ast node
 * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:137
 * @astdecl ClassInstanceExpr : Access ::= Access Arg:Expr* [TypeDecl];
 * @production ClassInstanceExpr : {@link Access} ::= {@link Access} Arg:{@link Expr}* [{@link TypeDecl}];

 */
public class ClassInstanceExpr extends Access implements Cloneable {
  /**
   * @aspect Java4PrettyPrint
   * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:185
   */
  public void prettyPrint(PrettyPrinter out) {
    out.print("new ");
    out.print(getAccess());
    out.print("(");
    out.join(getArgList(), new PrettyPrinter.Joiner() {
      @Override
      public void printSeparator(PrettyPrinter out) {
        out.print(", ");
      }
    });
    out.print(")");
    if (hasTypeDecl()) {
      if (hasPrintableBodyDecl()) {
        out.print(" {");
        out.println();
        out.indent(1);
        out.join(bodyDecls(), new PrettyPrinter.Joiner() {
          @Override
          public void printSeparator(PrettyPrinter out) {
            out.println();
          }
        });
        out.print("}");
      } else {
        out.print(" { }");
      }
    }
  }
  /**
   * @aspect TypeScopePropagation
   * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:598
   */
  public SimpleSet keepInnerClasses(SimpleSet types) {
    SimpleSet result = emptySet();
    for (TypeDecl type : types) {
      if (type.isInnerType() && type.isClassDecl()) {
        result = result.add(type); // Note: fixed potential error found by type checking.
      }
    }
    return result;
  }
  /**
   * @aspect NodeConstructors
   * @declaredat /home/jesper/git/extendj/java4/frontend/NodeConstructors.jrag:88
   */
  public ClassInstanceExpr(Access type, List args) {
    this(type, args, new Opt());
  }
  /**
   * @aspect ExceptionHandling
   * @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:366
   */
  protected boolean reachedException(TypeDecl catchType) {
    ConstructorDecl decl = decl();
    for (Access exception : decl().getExceptionList()) {
      TypeDecl exceptionType = exception.type();
      if (catchType.mayCatch(exceptionType)) {
        return true;
      }
    }
    for (int i = 0; i < getNumArg(); i++) {
      if (getArg(i).reachedException(catchType)) {
        return true;
      }
    }
    return false;
  }
  /**
   * @aspect TypeCheck
   * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:606
   */
  public void typeCheckEnclosingInstance(Collection problems) {
    TypeDecl C = type();
    if (!C.isInnerClass()) {
      return;
    }

    TypeDecl enclosing = null;
    if (C.isAnonymous()) {
      if (noEnclosingInstance()) {
        enclosing = null;
      } else {
        enclosing = hostType();
      }
    } else if (C.isLocalClass()) {
      if (C.inStaticContext()) {
        enclosing = null;
      } else if (noEnclosingInstance()) {
        enclosing = unknownType();
      } else {
        TypeDecl nest = hostType();
        while (nest != null && !nest.instanceOf(C.enclosingType())) {
          nest = nest.enclosingType();
        }
        enclosing = nest;
      }
    } else if (C.isMemberType()) {
      if (!isQualified()) {
        if (noEnclosingInstance()) {
          problems.add(errorf("No enclosing instance to initialize %s with", C.typeName()));
          enclosing = unknownType();
        } else {
          TypeDecl nest = hostType();
          while (nest != null && !nest.instanceOf(C.enclosingType())) {
            if (nest.isStatic()) {
              problems.add(errorf("No enclosing instance to initialize %s with", C.typeName()));
              nest = unknownType();
              break;
            }
            nest = nest.enclosingType();
          }
          enclosing = nest == null ? unknownType() : nest;
        }
      } else {
        enclosing = enclosingInstance();
      }
    }
    if (enclosing != null) {
      if (enclosing.isUnknown()) {
        problems.add(errorf("No enclosing instance to initialize %s with", C.typeName()));
      } else if (!enclosing.instanceOf(C.enclosingType())) {
        problems.add(errorf("*** Can not instantiate %s with the enclosing instance %s due to "
            + "incorrect enclosing instance",
            C.typeName(), enclosing.typeName()));
      } else if (!isQualified() && C.isMemberType()
          && inExplicitConstructorInvocation() && enclosing == hostType()) {
        problems.add(errorf("*** The innermost enclosing instance of type %s is this which is "
            + "not yet initialized here.",
            enclosing.typeName()));
      }
    }
  }
  /**
   * @aspect TypeCheck
   * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:698
   */
  public void typeCheckAnonymousSuperclassEnclosingInstance(
      Collection problems) {
    if (type().isAnonymous() && ((ClassDecl) type()).superclass().isInnerType()) {
      TypeDecl S = ((ClassDecl) type()).superclass();
      if (S.isLocalClass()) {
        if (S.inStaticContext()) {
        } else if (noEnclosingInstance()) {
          problems.add(errorf("*** No enclosing instance to class %s due to static context",
              type().typeName()));
        } else if (inExplicitConstructorInvocation()) {
          problems.add(errorf("*** No enclosing instance to superclass %s of %s since this is "
              + "not initialized yet",
              S.typeName(), type().typeName()));
        }
      } else if (S.isMemberType()) {
        if (!isQualified()) {
          // 15.9.2 2nd paragraph
          if (noEnclosingInstance()) {
            problems.add(errorf("*** No enclosing instance to class %s due to static context",
                type().typeName()));
          } else {
            TypeDecl nest = hostType();
            while (nest != null && !nest.instanceOf(S.enclosingType())) {
              nest = nest.enclosingType();
            }
            if (nest == null) {
              problems.add(errorf("*** No enclosing instance to superclass %s of %s",
                  S.typeName(), type().typeName()));
            } else if (inExplicitConstructorInvocation()) {
              problems.add(errorf("*** No enclosing instance to superclass %s of %s since this is "
                  + "not initialized yet",
                  S.typeName(), type().typeName()));
            }
          }
        }
      }
    }
  }
  /**
   * @aspect CreateBCode
   * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:861
   */
  private void emitLocalEnclosing(CodeGeneration gen, TypeDecl localClass) {
    if (!localClass.inStaticContext()) {
      emitThis(gen, localClass.enclosingType());
    }
  }
  /**
   * @aspect CreateBCode
   * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:867
   */
  private void emitInnerMemberEnclosing(CodeGeneration gen, TypeDecl innerClass) {
    if (hasPrevExpr()) {
      prevExpr().createBCode(gen);
      gen.DUP();
      int index = gen.constantPool()
          .addMethodref("java/lang/Object", "getClass", "()Ljava/lang/Class;");
      gen.INVOKEVIRTUAL(index, 1, lookupType("java.lang", "Class"));
      gen.POP();
    } else {
      TypeDecl enclosing = hostType();
      while (enclosing != null && !enclosing.hasType(innerClass.name())) {
        enclosing = enclosing.enclosingType();
      }
      if (enclosing == null) {
        throw new Error(errorPrefix() + "Could not find enclosing for " + this);
      } else {
        emitThis(gen, enclosing);
      }
    }
  }
  /**
   * @aspect CreateBCode
   * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:888
   */
  public void createBCode(CodeGeneration gen) {
    if (transformed() != this) {
      // Ensure bytecode is generated for the transformed access.
      transformed().createBCode(gen);
      return;
    }

    gen.NEW(type());
    gen.DUP(type());

    // 15.9.2 first part
    if (type().isAnonymous()) {
      if (isAnonymousInNonStaticContext()) {
        if (type().inExplicitConstructorInvocation()) {
          gen.ALOAD(1, type().enclosing());
        } else {
          gen.ALOAD(0, type());
        }
      }
      // 15.9.2 second part
      ClassDecl C = (ClassDecl) type();
      TypeDecl S = C.superclass();
      if (S.isLocalClass()) {
        if (!type().inStaticContext()) {
          emitLocalEnclosing(gen, S);
        }
      } else if (S.isInnerType()) {
        emitInnerMemberEnclosing(gen, S);
      }
    } else if (type().isLocalClass()) {
      if (!type().inStaticContext()) {
        emitLocalEnclosing(gen, type());
      }
    } else if (type().isInnerType()) {
      emitInnerMemberEnclosing(gen, type());
    }

    ConstructorDecl decl = decl().bytecodeTarget();

    // Push formal arguments.
    for (int i = 0; i < getNumArg(); ++i) {
      getArg(i).createBCode(gen);
      // Method invocation conversion:
      getArg(i).emitCastTo(gen, decl.paramType(i));
    }
    // Push enclosing variable arguments.
    for (Variable var : decl.hostType().enclosingVariables()) {
      var.emitLoadVariable(gen, this);
    }

    if (decl.isPrivate() && type() != hostType()) {
      gen.ACONST_NULL();
      decl.createAccessor().emitInvokeConstructor(gen);
    } else {
      decl.emitInvokeConstructor(gen);
    }
    // Mark the top stack reference as initialized.
    gen.initializedRef(type());
  }
  /**
   * @declaredat ASTNode:1
   */
  public ClassInstanceExpr() {
    super();
  }
  /**
   * Initializes the child array to the correct size.
   * Initializes List and Opt nta children.
   * @apilevel internal
   * @ast method
   * @declaredat ASTNode:10
   */
  public void init$Children() {
    children = new ASTNode[3];
    setChild(new List(), 1);
    setChild(new Opt(), 2);
  }
  /**
   * @declaredat ASTNode:15
   */
  @ASTNodeAnnotation.Constructor(
    name = {"Access", "Arg", "TypeDecl"},
    type = {"Access", "List", "Opt"},
    kind = {"Child", "List", "Opt"}
  )
  public ClassInstanceExpr(Access p0, List p1, Opt p2) {
    setChild(p0, 0);
    setChild(p1, 1);
    setChild(p2, 2);
  }
  /** @apilevel low-level 
   * @declaredat ASTNode:26
   */
  protected int numChildren() {
    return 3;
  }
  /**
   * @apilevel internal
   * @declaredat ASTNode:32
   */
  public boolean mayHaveRewrite() {
    return false;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:36
   */
  public void flushAttrCache() {
    super.flushAttrCache();
    decls_reset();
    decl_reset();
    localLookupType_String_reset();
    type_reset();
    assignedAfterInstance_Variable_reset();
    computeDAbefore_int_Variable_reset();
    unassignedAfterInstance_Variable_reset();
    unassignedAfter_Variable_reset();
    computeDUbefore_int_Variable_reset();
    transformedVariableArity_reset();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:50
   */
  public void flushCollectionCache() {
    super.flushCollectionCache();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:54
   */
  public ClassInstanceExpr clone() throws CloneNotSupportedException {
    ClassInstanceExpr node = (ClassInstanceExpr) super.clone();
    return node;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:59
   */
  public ClassInstanceExpr copy() {
    try {
      ClassInstanceExpr node = (ClassInstanceExpr) 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
   * @deprecated Please use treeCopy or treeCopyNoTransform instead
   * @declaredat ASTNode:78
   */
  @Deprecated
  public ClassInstanceExpr fullCopy() {
    return treeCopyNoTransform();
  }
  /**
   * 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
   * @declaredat ASTNode:88
   */
  public ClassInstanceExpr treeCopyNoTransform() {
    ClassInstanceExpr tree = (ClassInstanceExpr) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) children[i];
        if (child != null) {
          child = child.treeCopyNoTransform();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The subtree of this node is traversed to trigger rewrites before copy.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @declaredat ASTNode:108
   */
  public ClassInstanceExpr treeCopy() {
    ClassInstanceExpr tree = (ClassInstanceExpr) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) getChild(i);
        if (child != null) {
          child = child.treeCopy();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:122
   */
  protected boolean is$Equal(ASTNode node) {
    return super.is$Equal(node);    
  }
  /**
   * Replaces the Access child.
   * @param node The new node to replace the Access child.
   * @apilevel high-level
   */
  public void setAccess(Access node) {
    setChild(node, 0);
  }
  /**
   * Retrieves the Access child.
   * @return The current node used as the Access child.
   * @apilevel high-level
   */
  @ASTNodeAnnotation.Child(name="Access")
  public Access getAccess() {
    return (Access) getChild(0);
  }
  /**
   * Retrieves the Access child.
   * 

This method does not invoke AST transformations.

* @return The current node used as the Access child. * @apilevel low-level */ public Access getAccessNoTransform() { return (Access) getChildNoTransform(0); } /** * Replaces the Arg list. * @param list The new list node to be used as the Arg list. * @apilevel high-level */ 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 */ 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 */ 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 */ public Expr getArg(int i) { return (Expr) getArgList().getChild(i); } /** * Check whether the Arg list has any children. * @return {@code true} if it has at least one child, {@code false} otherwise. * @apilevel high-level */ public boolean hasArg() { return getArgList().getNumChild() != 0; } /** * Append an element to the Arg list. * @param node The element to append to the Arg list. * @apilevel high-level */ public void addArg(Expr node) { List list = (parent == null) ? getArgListNoTransform() : getArgList(); list.addChild(node); } /** @apilevel low-level */ 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 */ 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 */ @ASTNodeAnnotation.ListChild(name="Arg") public List getArgList() { List list = (List) getChild(1); return list; } /** * Retrieves the Arg list. *

This method does not invoke AST transformations.

* @return The node representing the Arg list. * @apilevel low-level */ public List getArgListNoTransform() { return (List) getChildNoTransform(1); } /** * @return the element at index {@code i} in the Arg list without * triggering rewrites. */ public Expr getArgNoTransform(int i) { return (Expr) getArgListNoTransform().getChildNoTransform(i); } /** * Retrieves the Arg list. * @return The node representing the Arg list. * @apilevel high-level */ 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 */ public List getArgsNoTransform() { return getArgListNoTransform(); } /** * Replaces the optional node for the TypeDecl child. This is the Opt * node containing the child TypeDecl, not the actual child! * @param opt The new node to be used as the optional node for the TypeDecl child. * @apilevel low-level */ public void setTypeDeclOpt(Opt opt) { setChild(opt, 2); } /** * Replaces the (optional) TypeDecl child. * @param node The new node to be used as the TypeDecl child. * @apilevel high-level */ public void setTypeDecl(TypeDecl node) { getTypeDeclOpt().setChild(node, 0); } /** * Check whether the optional TypeDecl child exists. * @return {@code true} if the optional TypeDecl child exists, {@code false} if it does not. * @apilevel high-level */ public boolean hasTypeDecl() { return getTypeDeclOpt().getNumChild() != 0; } /** * Retrieves the (optional) TypeDecl child. * @return The TypeDecl child, if it exists. Returns {@code null} otherwise. * @apilevel low-level */ public TypeDecl getTypeDecl() { return (TypeDecl) getTypeDeclOpt().getChild(0); } /** * Retrieves the optional node for the TypeDecl child. This is the Opt node containing the child TypeDecl, not the actual child! * @return The optional node for child the TypeDecl child. * @apilevel low-level */ @ASTNodeAnnotation.OptChild(name="TypeDecl") public Opt getTypeDeclOpt() { return (Opt) getChild(2); } /** * Retrieves the optional node for child TypeDecl. This is the Opt node containing the child TypeDecl, not the actual child! *

This method does not invoke AST transformations.

* @return The optional node for child TypeDecl. * @apilevel low-level */ public Opt getTypeDeclOptNoTransform() { return (Opt) getChildNoTransform(2); } /** * @aspect NameCheck * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:211 */ private Collection refined_NameCheck_ClassInstanceExpr_nameProblems() { Collection problems = new LinkedList(); if (decls().isEmpty()) { problems.add(errorf("can not instantiate %s no matching constructor found in %s", type().typeName(), type().typeName())); } else if (decls().size() > 1 && validArgs()) { problems.add(error("several most specific constructors found")); for (ConstructorDecl cons : decls()) { problems.add(errorf(" %s", cons.signature())); } } else if (!hasTypeDecl()) { // Check if the constructor is accessible (stricter when not in a class // instance expression) if constructor is private it can not be accessed // outside the host class or a subtype of it. ConstructorDecl decl = decl(); if (decl.isProtected() && !hostPackage().equals(decl.hostPackage()) && !hostType().instanceOf(decl.hostType())) { problems.add(errorf("can not access the constructor %s", this.prettyPrint())); } } return problems; } /** * @aspect Transformations * @declaredat /home/jesper/git/extendj/java4/backend/Transformations.jrag:88 */ private ClassInstanceExpr refined_Transformations_ClassInstanceExpr_transformed() { return this; } /** * @attribute syn * @aspect AccessControl * @declaredat /home/jesper/git/extendj/java4/frontend/AccessControl.jrag:174 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="AccessControl", declaredAt="/home/jesper/git/extendj/java4/frontend/AccessControl.jrag:174") public Collection accessControlProblems() { { Collection problems = new LinkedList(); if (type().isAbstract()) { problems.add(errorf("Can not instantiate abstract class %s", type().fullName())); } if (!decl().accessibleFrom(hostType())) { problems.add(errorf("constructor %s is not accessible", decl().signature())); } return problems; } } /** * Defines the expected kind of name for the left hand side in a qualified * expression. * @attribute syn * @aspect SyntacticClassification * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:60 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="SyntacticClassification", declaredAt="/home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:60") public NameType predNameType() { NameType predNameType_value = NameType.EXPRESSION_NAME; return predNameType_value; } /** * Test if an expression contains an unresolved parse name. * @attribute syn * @aspect NameResolution * @declaredat /home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:555 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="NameResolution", declaredAt="/home/jesper/git/extendj/java4/frontend/ResolveAmbiguousNames.jrag:555") public boolean containsParseName() { boolean containsParseName_value = getAccess().containsParseName(); return containsParseName_value; } /** * @attribute syn * @aspect ConstructScope * @declaredat /home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:85 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="ConstructScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:85") public boolean applicableAndAccessible(ConstructorDecl decl) { boolean applicableAndAccessible_ConstructorDecl_value = decl.applicable(getArgList()) && decl.accessibleFrom(hostType()) && (!decl.isProtected() || hasTypeDecl() || decl.hostPackage().equals(hostPackage())); return applicableAndAccessible_ConstructorDecl_value; } /** @apilevel internal */ private void decls_reset() { decls_computed = null; decls_value = null; } /** @apilevel internal */ protected ASTState.Cycle decls_computed = null; /** @apilevel internal */ protected SimpleSet decls_value; /** * @attribute syn * @aspect ConstructScope * @declaredat /home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:112 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="ConstructScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:112") public SimpleSet decls() { ASTState state = state(); if (decls_computed == ASTState.NON_CYCLE || decls_computed == state().cycle()) { return decls_value; } decls_value = decls_compute(); if (state().inCircle()) { decls_computed = state().cycle(); } else { decls_computed = ASTState.NON_CYCLE; } return decls_value; } /** @apilevel internal */ private SimpleSet decls_compute() { TypeDecl typeDecl = hasTypeDecl() ? getTypeDecl() : getAccess().type(); return chooseConstructor(typeDecl.constructors(), getArgList()); } /** @apilevel internal */ private void decl_reset() { decl_computed = null; decl_value = null; } /** @apilevel internal */ protected ASTState.Cycle decl_computed = null; /** @apilevel internal */ protected ConstructorDecl decl_value; /** * @attribute syn * @aspect ConstructScope * @declaredat /home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:117 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="ConstructScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:117") public ConstructorDecl decl() { ASTState state = state(); if (decl_computed == ASTState.NON_CYCLE || decl_computed == state().cycle()) { return decl_value; } decl_value = decl_compute(); if (state().inCircle()) { decl_computed = state().cycle(); } else { decl_computed = ASTState.NON_CYCLE; } return decl_value; } /** @apilevel internal */ private ConstructorDecl decl_compute() { SimpleSet decls = decls(); if (decls.isSingleton()) { return decls.singletonValue(); } else { return unknownConstructor(); } } /** * @return true if there is any printable body decl * @attribute syn * @aspect PrettyPrintUtil * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:303 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="PrettyPrintUtil", declaredAt="/home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:303") public boolean hasPrintableBodyDecl() { { TypeDecl decl = getTypeDecl(); for (int i = 0; i < decl.getNumBodyDecl(); ++i) { if (decl.getBodyDecl(i) instanceof ConstructorDecl) { ConstructorDecl cd = (ConstructorDecl) decl.getBodyDecl(i); if (!cd.isImplicitConstructor()) { return true; } } else { return true; } } return false; } } /** * @attribute syn * @aspect PrettyPrintUtil * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:318 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="PrettyPrintUtil", declaredAt="/home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:318") public List bodyDecls() { List bodyDecls_value = getTypeDecl().getBodyDeclList(); return bodyDecls_value; } /** * @attribute syn * @aspect TypeScopePropagation * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:612 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="TypeScopePropagation", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:612") public SimpleSet qualifiedLookupType(String name) { { SimpleSet result = keepAccessibleTypes(type().memberTypes(name)); if (!result.isEmpty()) { return result; } if (type().name().equals(name)) { return type(); } return emptySet(); } } /** @apilevel internal */ private void localLookupType_String_reset() { localLookupType_String_computed = null; localLookupType_String_values = null; } /** @apilevel internal */ protected java.util.Map localLookupType_String_values; /** @apilevel internal */ protected java.util.Map localLookupType_String_computed; /** * @attribute syn * @aspect TypeScopePropagation * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:651 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="TypeScopePropagation", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:651") public SimpleSet localLookupType(String name) { Object _parameters = name; if (localLookupType_String_computed == null) localLookupType_String_computed = new java.util.HashMap(4); if (localLookupType_String_values == null) localLookupType_String_values = new java.util.HashMap(4); ASTState state = state(); if (localLookupType_String_values.containsKey(_parameters) && localLookupType_String_computed.containsKey(_parameters) && (localLookupType_String_computed.get(_parameters) == ASTState.NON_CYCLE || localLookupType_String_computed.get(_parameters) == state().cycle())) { return (SimpleSet) localLookupType_String_values.get(_parameters); } SimpleSet localLookupType_String_value = hasTypeDecl() && getTypeDecl().name().equals(name) ? getTypeDecl() : ASTNode.emptySet(); if (state().inCircle()) { localLookupType_String_values.put(_parameters, localLookupType_String_value); localLookupType_String_computed.put(_parameters, state().cycle()); } else { localLookupType_String_values.put(_parameters, localLookupType_String_value); localLookupType_String_computed.put(_parameters, ASTState.NON_CYCLE); } return localLookupType_String_value; } /** @apilevel internal */ private void type_reset() { type_computed = null; type_value = null; } /** @apilevel internal */ protected ASTState.Cycle type_computed = null; /** @apilevel internal */ protected TypeDecl type_value; /** * @attribute syn * @aspect TypeAnalysis * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:295 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="TypeAnalysis", declaredAt="/home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:295") public TypeDecl type() { ASTState state = state(); if (type_computed == ASTState.NON_CYCLE || type_computed == state().cycle()) { return type_value; } type_value = hasTypeDecl() ? getTypeDecl() : getAccess().type(); if (state().inCircle()) { type_computed = state().cycle(); } else { type_computed = ASTState.NON_CYCLE; } return type_value; } /** @apilevel internal */ private void assignedAfterInstance_Variable_reset() { assignedAfterInstance_Variable_values = null; } protected java.util.Map assignedAfterInstance_Variable_values; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true) @ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:522") public boolean assignedAfterInstance(Variable v) { Object _parameters = v; if (assignedAfterInstance_Variable_values == null) assignedAfterInstance_Variable_values = new java.util.HashMap(4); ASTState.CircularValue _value; if (assignedAfterInstance_Variable_values.containsKey(_parameters)) { Object _cache = assignedAfterInstance_Variable_values.get(_parameters); if (!(_cache instanceof ASTState.CircularValue)) { return (Boolean) _cache; } else { _value = (ASTState.CircularValue) _cache; } } else { _value = new ASTState.CircularValue(); assignedAfterInstance_Variable_values.put(_parameters, _value); _value.value = true; } ASTState state = state(); if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); boolean new_assignedAfterInstance_Variable_value; do { _value.cycle = state.nextCycle(); new_assignedAfterInstance_Variable_value = assignedAfterInstance_compute(v); if (((Boolean)_value.value) != new_assignedAfterInstance_Variable_value) { state.setChangeInCycle(); _value.value = new_assignedAfterInstance_Variable_value; } } while (state.testAndClearChangeInCycle()); assignedAfterInstance_Variable_values.put(_parameters, new_assignedAfterInstance_Variable_value); state.leaveCircle(); return new_assignedAfterInstance_Variable_value; } else if (_value.cycle != state.cycle()) { _value.cycle = state.cycle(); boolean new_assignedAfterInstance_Variable_value = assignedAfterInstance_compute(v); if (((Boolean)_value.value) != new_assignedAfterInstance_Variable_value) { state.setChangeInCycle(); _value.value = new_assignedAfterInstance_Variable_value; } return new_assignedAfterInstance_Variable_value; } else { return (Boolean) _value.value; } } /** @apilevel internal */ private boolean assignedAfterInstance_compute(Variable v) { if (getNumArg() == 0) { return assignedBefore(v); } return getArg(getNumArg()-1).assignedAfter(v); } /** * @attribute syn * @aspect DefiniteAssignment * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:268 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:268") public boolean assignedAfter(Variable v) { boolean assignedAfter_Variable_value = assignedAfterInstance(v); return assignedAfter_Variable_value; } /** @apilevel internal */ private void computeDAbefore_int_Variable_reset() { computeDAbefore_int_Variable_values = null; } protected java.util.Map computeDAbefore_int_Variable_values; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true) @ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:533") public boolean computeDAbefore(int i, Variable v) { java.util.List _parameters = new java.util.ArrayList(2); _parameters.add(i); _parameters.add(v); if (computeDAbefore_int_Variable_values == null) computeDAbefore_int_Variable_values = new java.util.HashMap(4); ASTState.CircularValue _value; if (computeDAbefore_int_Variable_values.containsKey(_parameters)) { Object _cache = computeDAbefore_int_Variable_values.get(_parameters); if (!(_cache instanceof ASTState.CircularValue)) { return (Boolean) _cache; } else { _value = (ASTState.CircularValue) _cache; } } else { _value = new ASTState.CircularValue(); computeDAbefore_int_Variable_values.put(_parameters, _value); _value.value = true; } ASTState state = state(); if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); boolean new_computeDAbefore_int_Variable_value; do { _value.cycle = state.nextCycle(); new_computeDAbefore_int_Variable_value = i == 0 ? assignedBefore(v) : getArg(i-1).assignedAfter(v); if (((Boolean)_value.value) != new_computeDAbefore_int_Variable_value) { state.setChangeInCycle(); _value.value = new_computeDAbefore_int_Variable_value; } } while (state.testAndClearChangeInCycle()); computeDAbefore_int_Variable_values.put(_parameters, new_computeDAbefore_int_Variable_value); state.leaveCircle(); return new_computeDAbefore_int_Variable_value; } else if (_value.cycle != state.cycle()) { _value.cycle = state.cycle(); boolean new_computeDAbefore_int_Variable_value = i == 0 ? assignedBefore(v) : getArg(i-1).assignedAfter(v); if (((Boolean)_value.value) != new_computeDAbefore_int_Variable_value) { state.setChangeInCycle(); _value.value = new_computeDAbefore_int_Variable_value; } return new_computeDAbefore_int_Variable_value; } else { return (Boolean) _value.value; } } /** @apilevel internal */ private void unassignedAfterInstance_Variable_reset() { unassignedAfterInstance_Variable_values = null; } protected java.util.Map unassignedAfterInstance_Variable_values; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true) @ASTNodeAnnotation.Source(aspect="DefiniteUnassignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1132") public boolean unassignedAfterInstance(Variable v) { Object _parameters = v; if (unassignedAfterInstance_Variable_values == null) unassignedAfterInstance_Variable_values = new java.util.HashMap(4); ASTState.CircularValue _value; if (unassignedAfterInstance_Variable_values.containsKey(_parameters)) { Object _cache = unassignedAfterInstance_Variable_values.get(_parameters); if (!(_cache instanceof ASTState.CircularValue)) { return (Boolean) _cache; } else { _value = (ASTState.CircularValue) _cache; } } else { _value = new ASTState.CircularValue(); unassignedAfterInstance_Variable_values.put(_parameters, _value); _value.value = true; } ASTState state = state(); if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); boolean new_unassignedAfterInstance_Variable_value; do { _value.cycle = state.nextCycle(); new_unassignedAfterInstance_Variable_value = unassignedAfterInstance_compute(v); if (((Boolean)_value.value) != new_unassignedAfterInstance_Variable_value) { state.setChangeInCycle(); _value.value = new_unassignedAfterInstance_Variable_value; } } while (state.testAndClearChangeInCycle()); unassignedAfterInstance_Variable_values.put(_parameters, new_unassignedAfterInstance_Variable_value); state.leaveCircle(); return new_unassignedAfterInstance_Variable_value; } else if (_value.cycle != state.cycle()) { _value.cycle = state.cycle(); boolean new_unassignedAfterInstance_Variable_value = unassignedAfterInstance_compute(v); if (((Boolean)_value.value) != new_unassignedAfterInstance_Variable_value) { state.setChangeInCycle(); _value.value = new_unassignedAfterInstance_Variable_value; } return new_unassignedAfterInstance_Variable_value; } else { return (Boolean) _value.value; } } /** @apilevel internal */ private boolean unassignedAfterInstance_compute(Variable v) { if (getNumArg() == 0) { return unassignedBefore(v); } else { return getArg(getNumArg()-1).unassignedAfter(v); } } /** @apilevel internal */ private void unassignedAfter_Variable_reset() { unassignedAfter_Variable_values = null; } protected java.util.Map unassignedAfter_Variable_values; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true) @ASTNodeAnnotation.Source(aspect="DefiniteUnassignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:899") public boolean unassignedAfter(Variable v) { Object _parameters = v; if (unassignedAfter_Variable_values == null) unassignedAfter_Variable_values = new java.util.HashMap(4); ASTState.CircularValue _value; if (unassignedAfter_Variable_values.containsKey(_parameters)) { Object _cache = unassignedAfter_Variable_values.get(_parameters); if (!(_cache instanceof ASTState.CircularValue)) { return (Boolean) _cache; } else { _value = (ASTState.CircularValue) _cache; } } else { _value = new ASTState.CircularValue(); unassignedAfter_Variable_values.put(_parameters, _value); _value.value = true; } ASTState state = state(); if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); boolean new_unassignedAfter_Variable_value; do { _value.cycle = state.nextCycle(); new_unassignedAfter_Variable_value = unassignedAfterInstance(v); if (((Boolean)_value.value) != new_unassignedAfter_Variable_value) { state.setChangeInCycle(); _value.value = new_unassignedAfter_Variable_value; } } while (state.testAndClearChangeInCycle()); unassignedAfter_Variable_values.put(_parameters, new_unassignedAfter_Variable_value); state.leaveCircle(); return new_unassignedAfter_Variable_value; } else if (_value.cycle != state.cycle()) { _value.cycle = state.cycle(); boolean new_unassignedAfter_Variable_value = unassignedAfterInstance(v); if (((Boolean)_value.value) != new_unassignedAfter_Variable_value) { state.setChangeInCycle(); _value.value = new_unassignedAfter_Variable_value; } return new_unassignedAfter_Variable_value; } else { return (Boolean) _value.value; } } /** @apilevel internal */ private void computeDUbefore_int_Variable_reset() { computeDUbefore_int_Variable_values = null; } protected java.util.Map computeDUbefore_int_Variable_values; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true) @ASTNodeAnnotation.Source(aspect="DefiniteUnassignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1144") public boolean computeDUbefore(int i, Variable v) { java.util.List _parameters = new java.util.ArrayList(2); _parameters.add(i); _parameters.add(v); if (computeDUbefore_int_Variable_values == null) computeDUbefore_int_Variable_values = new java.util.HashMap(4); ASTState.CircularValue _value; if (computeDUbefore_int_Variable_values.containsKey(_parameters)) { Object _cache = computeDUbefore_int_Variable_values.get(_parameters); if (!(_cache instanceof ASTState.CircularValue)) { return (Boolean) _cache; } else { _value = (ASTState.CircularValue) _cache; } } else { _value = new ASTState.CircularValue(); computeDUbefore_int_Variable_values.put(_parameters, _value); _value.value = true; } ASTState state = state(); if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); boolean new_computeDUbefore_int_Variable_value; do { _value.cycle = state.nextCycle(); new_computeDUbefore_int_Variable_value = i == 0 ? unassignedBefore(v) : getArg(i-1).unassignedAfter(v); if (((Boolean)_value.value) != new_computeDUbefore_int_Variable_value) { state.setChangeInCycle(); _value.value = new_computeDUbefore_int_Variable_value; } } while (state.testAndClearChangeInCycle()); computeDUbefore_int_Variable_values.put(_parameters, new_computeDUbefore_int_Variable_value); state.leaveCircle(); return new_computeDUbefore_int_Variable_value; } else if (_value.cycle != state.cycle()) { _value.cycle = state.cycle(); boolean new_computeDUbefore_int_Variable_value = i == 0 ? unassignedBefore(v) : getArg(i-1).unassignedAfter(v); if (((Boolean)_value.value) != new_computeDUbefore_int_Variable_value) { state.setChangeInCycle(); _value.value = new_computeDUbefore_int_Variable_value; } return new_computeDUbefore_int_Variable_value; } else { return (Boolean) _value.value; } } /** * @attribute syn * @aspect NameCheck * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:200 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="NameCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/NameCheck.jrag:200") public boolean validArgs() { { for (int i = 0; i < getNumArg(); i++) { if (getArg(i).type().isUnknown()) { return false; } } return true; } } /** * @attribute syn * @aspect NameCheck * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:211 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="NameCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/NameCheck.jrag:211") public Collection nameProblems() { { if (getAccess().type().isEnumDecl() && !enclosingBodyDecl().isEnumConstant()) { return Collections.singletonList(error("enum types may not be instantiated explicitly")); } else { return refined_NameCheck_ClassInstanceExpr_nameProblems(); } } } /** * @attribute syn * @aspect ExceptionHandling * @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:166 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="ExceptionHandling", declaredAt="/home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:166") public Collection exceptionHandlingProblems() { { Collection problems = new LinkedList(); for (Access exception : decl().getExceptionList()) { TypeDecl exceptionType = exception.type(); if (exceptionType.isCheckedException() && !handlesException(exceptionType)) { problems.add(errorf( "%s may throw uncaught exception %s; it must be caught or declared as being thrown", this.prettyPrint(), exceptionType.fullName())); } } return problems; } } /** * @attribute syn * @aspect TypeCheck * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:586 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="TypeCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:586") public Collection typeProblems() { { Collection problems = new LinkedList(); if (isQualified() && qualifier().isTypeAccess() && !qualifier().type().isUnknown()) { problems.add(error( "*** The expression in a qualified class instance expr must not be a type name")); } // 15.9 if (isQualified() && !type().isInnerClass() && !((ClassDecl) type()).superclass().isInnerClass() && !type().isUnknown()) { problems.add(error("*** Qualified class instance creation can only instantiate inner " + "classes and their anonymous subclasses")); } if (!type().isClassDecl()) { problems.add(errorf("*** Can only instantiate classes, which %s is not", type().typeName())); } typeCheckEnclosingInstance(problems); typeCheckAnonymousSuperclassEnclosingInstance(problems); return problems; } } /** * @attribute syn * @aspect TypeCheck * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:695 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="TypeCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:695") public boolean noEnclosingInstance() { boolean noEnclosingInstance_value = isQualified() ? qualifier().staticContextQualifier() : inStaticContext(); return noEnclosingInstance_value; } /** * @attribute syn * @aspect VariableArityParameters * @declaredat /home/jesper/git/extendj/java5/frontend/VariableArityParameters.jrag:85 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="VariableArityParameters", declaredAt="/home/jesper/git/extendj/java5/frontend/VariableArityParameters.jrag:85") public boolean invokesVariableArityAsArray() { { if (!decl().isVariableArity()) { return false; } if (arity() != decl().arity()) { return false; } return getArg(getNumArg()-1).type().methodInvocationConversionTo(decl().lastParameter().type()); } } /** * @attribute syn * @aspect MethodSignature15 * @declaredat /home/jesper/git/extendj/java5/frontend/MethodSignature.jrag:682 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="MethodSignature15", declaredAt="/home/jesper/git/extendj/java5/frontend/MethodSignature.jrag:682") public int arity() { int arity_value = getNumArg(); return arity_value; } /** * @attribute syn * @aspect Transformations * @declaredat /home/jesper/git/extendj/java4/backend/Transformations.jrag:88 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="Transformations", declaredAt="/home/jesper/git/extendj/java4/backend/Transformations.jrag:88") public ClassInstanceExpr transformed() { { if (decl().isVariableArity() && !invokesVariableArityAsArray()) { return transformedVariableArity(); } else { return refined_Transformations_ClassInstanceExpr_transformed(); } } } /** * @attribute syn * @aspect InnerClasses * @declaredat /home/jesper/git/extendj/java4/backend/InnerClasses.jrag:425 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="InnerClasses", declaredAt="/home/jesper/git/extendj/java4/backend/InnerClasses.jrag:425") public boolean isAnonymousInNonStaticContext() { { return !unqualifiedScope().inStaticContext() && (!inExplicitConstructorInvocation() || enclosingBodyDecl().hostType().isInnerType()); } } /** @apilevel internal */ private void transformedVariableArity_reset() { transformedVariableArity_computed = false; transformedVariableArity_value = null; } /** @apilevel internal */ protected boolean transformedVariableArity_computed = false; /** @apilevel internal */ protected ClassInstanceExpr transformedVariableArity_value; /** * @attribute syn * @aspect VariableArityParametersCodegen * @declaredat /home/jesper/git/extendj/java5/backend/VariableArityParametersCodegen.jrag:93 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isNTA=true) @ASTNodeAnnotation.Source(aspect="VariableArityParametersCodegen", declaredAt="/home/jesper/git/extendj/java5/backend/VariableArityParametersCodegen.jrag:93") public ClassInstanceExpr transformedVariableArity() { ASTState state = state(); if (transformedVariableArity_computed) { return transformedVariableArity_value; } state().enterLazyAttribute(); transformedVariableArity_value = transformedVariableArity_compute(); transformedVariableArity_value.setParent(this); transformedVariableArity_computed = true; state().leaveLazyAttribute(); return transformedVariableArity_value; } /** @apilevel internal */ private ClassInstanceExpr transformedVariableArity_compute() { ConstructorDecl decl = decl(); // Arguments to normal parameters. List args = new List(); for (int i = 0; i < decl.getNumParameter() - 1; i++) { args.add(getArg(i).treeCopyNoTransform()); } // Arguments to variable arity parameters. List last = new List(); for (int i = decl.getNumParameter() - 1; i < getNumArg(); i++) { last.add(getArg(i).treeCopyNoTransform()); } // 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); } args.add(new ArrayCreationExpr(typeAccess, new Opt(new ArrayInit(last)))); // Replace argument list with augemented argument list. return new ClassInstanceExpr(getAccess().treeCopyNoTransform(), args, getTypeDeclOpt().treeCopyNoTransform()); } /** * @attribute inh * @aspect ConstructScope * @declaredat /home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:58 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH) @ASTNodeAnnotation.Source(aspect="ConstructScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:58") public TypeDecl typeObject() { TypeDecl typeObject_value = getParent().Define_typeObject(this, null); return typeObject_value; } /** * @attribute inh * @aspect ConstructScope * @declaredat /home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:126 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH) @ASTNodeAnnotation.Source(aspect="ConstructScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupConstructor.jrag:126") public ConstructorDecl unknownConstructor() { ConstructorDecl unknownConstructor_value = getParent().Define_unknownConstructor(this, null); return unknownConstructor_value; } /** * @attribute inh * @aspect TypeHierarchyCheck * @declaredat /home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:203 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH) @ASTNodeAnnotation.Source(aspect="TypeHierarchyCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:203") public boolean inExplicitConstructorInvocation() { boolean inExplicitConstructorInvocation_value = getParent().Define_inExplicitConstructorInvocation(this, null); return inExplicitConstructorInvocation_value; } /** * @attribute inh * @aspect ExceptionHandling * @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:96 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH) @ASTNodeAnnotation.Source(aspect="ExceptionHandling", declaredAt="/home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:96") public boolean handlesException(TypeDecl exceptionType) { boolean handlesException_TypeDecl_value = getParent().Define_handlesException(this, null, exceptionType); return handlesException_TypeDecl_value; } /** * @attribute inh * @aspect TypeCheck * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:670 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH) @ASTNodeAnnotation.Source(aspect="TypeCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:670") public TypeDecl enclosingInstance() { TypeDecl enclosingInstance_value = getParent().Define_enclosingInstance(this, null); return enclosingInstance_value; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 * @apilevel internal */ public NameType Define_nameType(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getArgListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:146 int childIndex = _callerNode.getIndexOfChild(_childNode); return NameType.EXPRESSION_NAME; } else if (_callerNode == getTypeDeclOptNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:145 return NameType.TYPE_NAME; } else if (getAccessNoTransform() != null && _callerNode == getAccess()) { // @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:144 return NameType.TYPE_NAME; } else { return getParent().Define_nameType(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute nameType */ protected boolean canDefine_nameType(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/AnonymousClasses.jrag:33 * @apilevel internal */ public TypeDecl Define_superType(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getTypeDeclOptNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/AnonymousClasses.jrag:35 return getAccess().type(); } else { return getParent().Define_superType(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/AnonymousClasses.jrag:33 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute superType */ protected boolean canDefine_superType(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/AnonymousClasses.jrag:39 * @apilevel internal */ public ConstructorDecl Define_constructorDecl(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getTypeDeclOptNoTransform()) { // @declaredat /home/jesper/git/extendj/java5/frontend/MethodSignature.jrag:103 { Collection c = getAccess().type().constructors(); SimpleSet maxSpecific = chooseConstructor(c, getArgList()); if (maxSpecific.isSingleton()) { return maxSpecific.singletonValue(); } return unknownConstructor(); } } else { return getParent().Define_constructorDecl(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/AnonymousClasses.jrag:39 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute constructorDecl */ protected boolean canDefine_constructorDecl(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:113 * @apilevel internal */ public boolean Define_hasPackage(ASTNode _callerNode, ASTNode _childNode, String packageName) { if (_callerNode == getArgListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:124 int childIndex = _callerNode.getIndexOfChild(_childNode); return unqualifiedScope().hasPackage(packageName); } else { return getParent().Define_hasPackage(this, _callerNode, packageName); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:113 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute hasPackage */ protected boolean canDefine_hasPackage(ASTNode _callerNode, ASTNode _childNode, String packageName) { return true; } /** * @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethods.jrag:231 * @apilevel internal */ public SimpleSet Define_lookupType(ASTNode _callerNode, ASTNode _childNode, String name) { if (_callerNode == getTypeDeclOptNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:586 { SimpleSet result = localLookupType(name); if (!result.isEmpty()) { return result; } result = lookupType(name); if (!result.isEmpty()) { return result; } return unqualifiedScope().lookupType(name); } } else if (getAccessNoTransform() != null && _callerNode == getAccess()) { // @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:578 { SimpleSet result = lookupType(name); if (result.isSingleton() && isQualified()) { result = keepInnerClasses(result); } return result; } } else if (_callerNode == getArgListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:394 int childIndex = _callerNode.getIndexOfChild(_childNode); return unqualifiedScope().lookupType(name); } else { return getParent().Define_lookupType(this, _callerNode, name); } } /** * @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethods.jrag:231 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute lookupType */ protected boolean canDefine_lookupType(ASTNode _callerNode, ASTNode _childNode, String name) { return true; } /** * @declaredat /home/jesper/git/extendj/java5/frontend/EnhancedFor.jrag:138 * @apilevel internal */ public SimpleSet Define_lookupVariable(ASTNode _callerNode, ASTNode _childNode, String name) { if (_callerNode == getArgListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:254 int childIndex = _callerNode.getIndexOfChild(_childNode); return unqualifiedScope().lookupVariable(name); } else { return getParent().Define_lookupVariable(this, _callerNode, name); } } /** * @declaredat /home/jesper/git/extendj/java5/frontend/EnhancedFor.jrag:138 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute lookupVariable */ protected boolean canDefine_lookupVariable(ASTNode _callerNode, ASTNode _childNode, String name) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:231 * @apilevel internal */ public boolean Define_isAnonymous(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getTypeDeclOptNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:232 return true; } else { return getParent().Define_isAnonymous(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:231 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute isAnonymous */ protected boolean canDefine_isAnonymous(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:584 * @apilevel internal */ public boolean Define_isMemberType(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getTypeDeclOptNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:588 return false; } else { return getParent().Define_isMemberType(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:584 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute isMemberType */ protected boolean canDefine_isMemberType(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java5/backend/AnnotationsCodegen.jrag:332 * @apilevel internal */ public TypeDecl Define_hostType(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getTypeDeclOptNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:643 return hostType(); } else { return getParent().Define_hostType(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java5/backend/AnnotationsCodegen.jrag:332 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute hostType */ protected boolean canDefine_hostType(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:223 * @apilevel internal */ public boolean Define_inStaticContext(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getTypeDeclOptNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:237 return isQualified() ? qualifier().staticContextQualifier() : inStaticContext(); } else { return getParent().Define_inStaticContext(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:223 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute inStaticContext */ protected boolean canDefine_inStaticContext(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:256 * @apilevel internal */ public boolean Define_assignedBefore(ASTNode _callerNode, ASTNode _childNode, Variable v) { if (_callerNode == getTypeDeclOptNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:536 return assignedAfterInstance(v); } else if (_callerNode == getArgListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:531 int i = _callerNode.getIndexOfChild(_childNode); return computeDAbefore(i, v); } else { return getParent().Define_assignedBefore(this, _callerNode, v); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:256 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute assignedBefore */ protected boolean canDefine_assignedBefore(ASTNode _callerNode, ASTNode _childNode, Variable v) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:887 * @apilevel internal */ public boolean Define_unassignedBefore(ASTNode _callerNode, ASTNode _childNode, Variable v) { if (_callerNode == getArgListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1142 int i = _callerNode.getIndexOfChild(_childNode); return computeDUbefore(i, v); } else { return getParent().Define_unassignedBefore(this, _callerNode, v); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:887 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute unassignedBefore */ protected boolean canDefine_unassignedBefore(ASTNode _callerNode, ASTNode _childNode, Variable v) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/backend/InnerClasses.jrag:435 * @apilevel internal */ public ClassInstanceExpr Define_classInstanceExpression(ASTNode _callerNode, ASTNode _childNode) { int childIndex = this.getIndexOfChild(_callerNode); return this; } /** * @declaredat /home/jesper/git/extendj/java4/backend/InnerClasses.jrag:435 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute classInstanceExpression */ protected boolean canDefine_classInstanceExpression(ASTNode _callerNode, ASTNode _childNode) { return true; } /** @apilevel internal */ public ASTNode rewriteTo() { return super.rewriteTo(); } /** @apilevel internal */ public boolean canRewrite() { return false; } /** @apilevel internal */ protected void collect_contributors_CompilationUnit_problems(CompilationUnit _root, java.util.Map> _map) { // @declaredat /home/jesper/git/extendj/java4/frontend/AccessControl.jrag:172 { java.util.Set contributors = _map.get(_root); if (contributors == null) { contributors = new java.util.LinkedHashSet(); _map.put((ASTNode) _root, contributors); } contributors.add(this); } // @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:209 { java.util.Set contributors = _map.get(_root); if (contributors == null) { contributors = new java.util.LinkedHashSet(); _map.put((ASTNode) _root, contributors); } contributors.add(this); } // @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:164 { java.util.Set contributors = _map.get(_root); if (contributors == null) { contributors = new java.util.LinkedHashSet(); _map.put((ASTNode) _root, contributors); } contributors.add(this); } // @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:584 { java.util.Set contributors = _map.get(_root); if (contributors == null) { contributors = new java.util.LinkedHashSet(); _map.put((ASTNode) _root, contributors); } contributors.add(this); } // @declaredat /home/jesper/git/extendj/java5/frontend/Annotations.jrag:521 if (decl().isDeprecated() && !withinDeprecatedAnnotation() && hostType().topLevelType() != decl().hostType().topLevelType() && !withinSuppressWarnings("deprecation")) { { java.util.Set contributors = _map.get(_root); if (contributors == null) { contributors = new java.util.LinkedHashSet(); _map.put((ASTNode) _root, contributors); } contributors.add(this); } } super.collect_contributors_CompilationUnit_problems(_root, _map); } /** @apilevel internal */ protected void collect_contributors_TypeDecl_accessors(CompilationUnit _root, java.util.Map> _map) { // @declaredat /home/jesper/git/extendj/java4/backend/GenerateClassfile.jrag:392 if (decl().isPrivate() && type() != hostType()) { { TypeDecl target = (TypeDecl) (decl().createAccessor().hostType()); java.util.Set contributors = _map.get(target); if (contributors == null) { contributors = new java.util.LinkedHashSet(); _map.put((ASTNode) target, contributors); } contributors.add(this); } } super.collect_contributors_TypeDecl_accessors(_root, _map); } /** @apilevel internal */ protected void collect_contributors_TypeDecl_nestedTypes(CompilationUnit _root, java.util.Map> _map) { { if (transformed() != this) { transformed().collect_contributors_TypeDecl_nestedTypes(_root, _map); } else { super.collect_contributors_TypeDecl_nestedTypes(_root, _map); } } } /** @apilevel internal */ protected void contributeTo_CompilationUnit_problems(LinkedList collection) { super.contributeTo_CompilationUnit_problems(collection); for (Problem value : accessControlProblems()) { collection.add(value); } for (Problem value : nameProblems()) { collection.add(value); } for (Problem value : exceptionHandlingProblems()) { collection.add(value); } for (Problem value : typeProblems()) { collection.add(value); } if (decl().isDeprecated() && !withinDeprecatedAnnotation() && hostType().topLevelType() != decl().hostType().topLevelType() && !withinSuppressWarnings("deprecation")) { collection.add(warning(decl().signature() + " in " + decl().hostType().typeName() + " has been deprecated")); } } /** @apilevel internal */ protected void contributeTo_TypeDecl_accessors(HashSet collection) { super.contributeTo_TypeDecl_accessors(collection); if (decl().isPrivate() && type() != hostType()) { collection.add(decl().createAccessor()); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy