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

org.extendj.ast.Block 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;
/**
 * A statement block. Contains a list of statements.
 * @ast node
 * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:325
 * @astdecl Block : Stmt ::= Stmt*;
 * @production Block : {@link Stmt} ::= {@link Stmt}*;

 */
public class Block extends Stmt implements Cloneable, VariableScope {
  /**
   * @aspect Java4PrettyPrint
   * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:101
   */
  public void prettyPrint(PrettyPrinter out) {
    out.print("{");
    out.println();
    out.indent(1);
    out.join(getStmtList(), new PrettyPrinter.Joiner() {
      @Override
      public void printSeparator(PrettyPrinter out) {
        out.println();
      }
    });
    if (!out.isNewLine()) {
      out.println();
    }
    out.print("}");
  }
  /**
   * @aspect CreateBCode
   * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1517
   */
  public void createBCode(CodeGeneration gen) {
    for (Stmt stmt : getStmtList()) {
      try {
        stmt.createBCode(gen);
      } catch (Exception e) {
        e.printStackTrace();
        System.err.println(dumpTree());
        throw new Error("Error generating code for " + errorPrefix() + " " + stmt);
      }
    }
    gen.addVariableScopeLabel(variableScopeEndLabel(gen));
  }
  /**
   * @declaredat ASTNode:1
   */
  public Block() {
    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[1];
    setChild(new List(), 0);
  }
  /**
   * @declaredat ASTNode:14
   */
  @ASTNodeAnnotation.Constructor(
    name = {"Stmt"},
    type = {"List"},
    kind = {"List"}
  )
  public Block(List p0) {
    setChild(p0, 0);
  }
  /** @apilevel low-level 
   * @declaredat ASTNode:23
   */
  protected int numChildren() {
    return 1;
  }
  /**
   * @apilevel internal
   * @declaredat ASTNode:29
   */
  public boolean mayHaveRewrite() {
    return false;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:33
   */
  public void flushAttrCache() {
    super.flushAttrCache();
    canCompleteNormally_reset();
    localVariableDeclaration_String_reset();
    assignedAfterReturn_Variable_reset();
    assignedAfter_Variable_reset();
    unassignedAfterReturn_Variable_reset();
    unassignedAfter_Variable_reset();
    variableScopeEndLabel_CodeGeneration_reset();
    lookupType_String_reset();
    lookupVariable_String_reset();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:46
   */
  public void flushCollectionCache() {
    super.flushCollectionCache();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:50
   */
  public Block clone() throws CloneNotSupportedException {
    Block node = (Block) super.clone();
    return node;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:55
   */
  public Block copy() {
    try {
      Block node = (Block) 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:74
   */
  @Deprecated
  public Block 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:84
   */
  public Block treeCopyNoTransform() {
    Block tree = (Block) 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:104
   */
  public Block treeCopy() {
    Block tree = (Block) 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:118
   */
  protected boolean is$Equal(ASTNode node) {
    return super.is$Equal(node);    
  }
  /**
   * Replaces the Stmt list.
   * @param list The new list node to be used as the Stmt list.
   * @apilevel high-level
   */
  public void setStmtList(List list) {
    setChild(list, 0);
  }
  /**
   * Retrieves the number of children in the Stmt list.
   * @return Number of children in the Stmt list.
   * @apilevel high-level
   */
  public int getNumStmt() {
    return getStmtList().getNumChild();
  }
  /**
   * Retrieves the number of children in the Stmt list.
   * Calling this method will not trigger rewrites.
   * @return Number of children in the Stmt list.
   * @apilevel low-level
   */
  public int getNumStmtNoTransform() {
    return getStmtListNoTransform().getNumChildNoTransform();
  }
  /**
   * Retrieves the element at index {@code i} in the Stmt list.
   * @param i Index of the element to return.
   * @return The element at position {@code i} in the Stmt list.
   * @apilevel high-level
   */
  public Stmt getStmt(int i) {
    return (Stmt) getStmtList().getChild(i);
  }
  /**
   * Check whether the Stmt list has any children.
   * @return {@code true} if it has at least one child, {@code false} otherwise.
   * @apilevel high-level
   */
  public boolean hasStmt() {
    return getStmtList().getNumChild() != 0;
  }
  /**
   * Append an element to the Stmt list.
   * @param node The element to append to the Stmt list.
   * @apilevel high-level
   */
  public void addStmt(Stmt node) {
    List list = (parent == null) ? getStmtListNoTransform() : getStmtList();
    list.addChild(node);
  }
  /** @apilevel low-level 
   */
  public void addStmtNoTransform(Stmt node) {
    List list = getStmtListNoTransform();
    list.addChild(node);
  }
  /**
   * Replaces the Stmt 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 setStmt(Stmt node, int i) {
    List list = getStmtList();
    list.setChild(node, i);
  }
  /**
   * Retrieves the Stmt list.
   * @return The node representing the Stmt list.
   * @apilevel high-level
   */
  @ASTNodeAnnotation.ListChild(name="Stmt")
  public List getStmtList() {
    List list = (List) getChild(0);
    return list;
  }
  /**
   * Retrieves the Stmt list.
   * 

This method does not invoke AST transformations.

* @return The node representing the Stmt list. * @apilevel low-level */ public List getStmtListNoTransform() { return (List) getChildNoTransform(0); } /** * @return the element at index {@code i} in the Stmt list without * triggering rewrites. */ public Stmt getStmtNoTransform(int i) { return (Stmt) getStmtListNoTransform().getChildNoTransform(i); } /** * Retrieves the Stmt list. * @return The node representing the Stmt list. * @apilevel high-level */ public List getStmts() { return getStmtList(); } /** * Retrieves the Stmt list. *

This method does not invoke AST transformations.

* @return The node representing the Stmt list. * @apilevel low-level */ public List getStmtsNoTransform() { return getStmtListNoTransform(); } /** * @attribute syn * @aspect DeclareBeforeUse * @declaredat /home/jesper/git/extendj/java4/frontend/DeclareBeforeUse.jrag:42 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="DeclareBeforeUse", declaredAt="/home/jesper/git/extendj/java4/frontend/DeclareBeforeUse.jrag:42") public boolean declaredBeforeUse(VariableDeclarator decl, int indexUse) { boolean declaredBeforeUse_VariableDeclarator_int_value = decl.blockIndex() < indexUse; return declaredBeforeUse_VariableDeclarator_int_value; } /** @apilevel internal */ private void canCompleteNormally_reset() { canCompleteNormally_computed = null; } /** @apilevel internal */ protected ASTState.Cycle canCompleteNormally_computed = null; /** @apilevel internal */ protected boolean canCompleteNormally_value; /** * @attribute syn * @aspect UnreachableStatements * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:50 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="UnreachableStatements", declaredAt="/home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:50") public boolean canCompleteNormally() { ASTState state = state(); if (canCompleteNormally_computed == ASTState.NON_CYCLE || canCompleteNormally_computed == state().cycle()) { return canCompleteNormally_value; } canCompleteNormally_value = getNumStmt() == 0 ? reachable() : getStmt(getNumStmt() - 1).canCompleteNormally(); if (state().inCircle()) { canCompleteNormally_computed = state().cycle(); } else { canCompleteNormally_computed = ASTState.NON_CYCLE; } return canCompleteNormally_value; } /** * @attribute syn * @aspect PrettyPrintUtil * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:298 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="PrettyPrintUtil", declaredAt="/home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:298") public boolean hasStmts() { boolean hasStmts_value = getNumStmt() > 0; return hasStmts_value; } /** @apilevel internal */ private void localVariableDeclaration_String_reset() { localVariableDeclaration_String_computed = null; localVariableDeclaration_String_values = null; } /** @apilevel internal */ protected java.util.Map localVariableDeclaration_String_values; /** @apilevel internal */ protected java.util.Map localVariableDeclaration_String_computed; /** * @attribute syn * @aspect VariableScope * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:199 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="VariableScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:199") public VariableDeclarator localVariableDeclaration(String name) { Object _parameters = name; if (localVariableDeclaration_String_computed == null) localVariableDeclaration_String_computed = new java.util.HashMap(4); if (localVariableDeclaration_String_values == null) localVariableDeclaration_String_values = new java.util.HashMap(4); ASTState state = state(); if (localVariableDeclaration_String_values.containsKey(_parameters) && localVariableDeclaration_String_computed.containsKey(_parameters) && (localVariableDeclaration_String_computed.get(_parameters) == ASTState.NON_CYCLE || localVariableDeclaration_String_computed.get(_parameters) == state().cycle())) { return (VariableDeclarator) localVariableDeclaration_String_values.get(_parameters); } VariableDeclarator localVariableDeclaration_String_value = localVariableDeclaration_compute(name); if (state().inCircle()) { localVariableDeclaration_String_values.put(_parameters, localVariableDeclaration_String_value); localVariableDeclaration_String_computed.put(_parameters, state().cycle()); } else { localVariableDeclaration_String_values.put(_parameters, localVariableDeclaration_String_value); localVariableDeclaration_String_computed.put(_parameters, ASTState.NON_CYCLE); } return localVariableDeclaration_String_value; } /** @apilevel internal */ private VariableDeclarator localVariableDeclaration_compute(String name) { for (Stmt stmt : getStmtList()) { VariableDeclarator decl = stmt.variableDeclaration(name); if (decl != null) { return decl; } } return null; } /** @apilevel internal */ private void assignedAfterReturn_Variable_reset() { assignedAfterReturn_Variable_values = null; } protected java.util.Map assignedAfterReturn_Variable_values; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true) @ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:349") public boolean assignedAfterReturn(Variable v) { Object _parameters = v; if (assignedAfterReturn_Variable_values == null) assignedAfterReturn_Variable_values = new java.util.HashMap(4); ASTState.CircularValue _value; if (assignedAfterReturn_Variable_values.containsKey(_parameters)) { Object _cache = assignedAfterReturn_Variable_values.get(_parameters); if (!(_cache instanceof ASTState.CircularValue)) { return (Boolean) _cache; } else { _value = (ASTState.CircularValue) _cache; } } else { _value = new ASTState.CircularValue(); assignedAfterReturn_Variable_values.put(_parameters, _value); _value.value = true; } ASTState state = state(); if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); boolean new_assignedAfterReturn_Variable_value; do { _value.cycle = state.nextCycle(); new_assignedAfterReturn_Variable_value = assignedAfterReturn_compute(v); if (((Boolean)_value.value) != new_assignedAfterReturn_Variable_value) { state.setChangeInCycle(); _value.value = new_assignedAfterReturn_Variable_value; } } while (state.testAndClearChangeInCycle()); assignedAfterReturn_Variable_values.put(_parameters, new_assignedAfterReturn_Variable_value); state.leaveCircle(); return new_assignedAfterReturn_Variable_value; } else if (_value.cycle != state.cycle()) { _value.cycle = state.cycle(); boolean new_assignedAfterReturn_Variable_value = assignedAfterReturn_compute(v); if (((Boolean)_value.value) != new_assignedAfterReturn_Variable_value) { state.setChangeInCycle(); _value.value = new_assignedAfterReturn_Variable_value; } return new_assignedAfterReturn_Variable_value; } else { return (Boolean) _value.value; } } /** @apilevel internal */ private boolean assignedAfterReturn_compute(Variable v) { Collection branches = new HashSet(); collectBranches(branches); for (Stmt branch : branches) { if (branch instanceof ReturnStmt) { ReturnStmt stmt = (ReturnStmt) branch; if (!stmt.assignedAfterReachedFinallyBlocks(v)) { return false; } } } return true; } /** @apilevel internal */ private void assignedAfter_Variable_reset() { assignedAfter_Variable_values = null; } protected java.util.Map assignedAfter_Variable_values; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true) @ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:264") public boolean assignedAfter(Variable v) { Object _parameters = v; if (assignedAfter_Variable_values == null) assignedAfter_Variable_values = new java.util.HashMap(4); ASTState.CircularValue _value; if (assignedAfter_Variable_values.containsKey(_parameters)) { Object _cache = assignedAfter_Variable_values.get(_parameters); if (!(_cache instanceof ASTState.CircularValue)) { return (Boolean) _cache; } else { _value = (ASTState.CircularValue) _cache; } } else { _value = new ASTState.CircularValue(); assignedAfter_Variable_values.put(_parameters, _value); _value.value = true; } ASTState state = state(); if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); boolean new_assignedAfter_Variable_value; do { _value.cycle = state.nextCycle(); new_assignedAfter_Variable_value = getNumStmt() == 0 ? assignedBefore(v) : getStmt(getNumStmt()-1).assignedAfter(v); if (((Boolean)_value.value) != new_assignedAfter_Variable_value) { state.setChangeInCycle(); _value.value = new_assignedAfter_Variable_value; } } while (state.testAndClearChangeInCycle()); assignedAfter_Variable_values.put(_parameters, new_assignedAfter_Variable_value); state.leaveCircle(); return new_assignedAfter_Variable_value; } else if (_value.cycle != state.cycle()) { _value.cycle = state.cycle(); boolean new_assignedAfter_Variable_value = getNumStmt() == 0 ? assignedBefore(v) : getStmt(getNumStmt()-1).assignedAfter(v); if (((Boolean)_value.value) != new_assignedAfter_Variable_value) { state.setChangeInCycle(); _value.value = new_assignedAfter_Variable_value; } return new_assignedAfter_Variable_value; } else { return (Boolean) _value.value; } } /** * @attribute syn * @aspect DefiniteAssignment * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:567 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:567") public boolean unassignedEverywhere(Variable v) { boolean unassignedEverywhere_Variable_value = unassignedBefore(v) && checkDUeverywhere(v); return unassignedEverywhere_Variable_value; } /** @apilevel internal */ private void unassignedAfterReturn_Variable_reset() { unassignedAfterReturn_Variable_values = null; } protected java.util.Map unassignedAfterReturn_Variable_values; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true) @ASTNodeAnnotation.Source(aspect="DefiniteUnassignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:977") public boolean unassignedAfterReturn(Variable v) { Object _parameters = v; if (unassignedAfterReturn_Variable_values == null) unassignedAfterReturn_Variable_values = new java.util.HashMap(4); ASTState.CircularValue _value; if (unassignedAfterReturn_Variable_values.containsKey(_parameters)) { Object _cache = unassignedAfterReturn_Variable_values.get(_parameters); if (!(_cache instanceof ASTState.CircularValue)) { return (Boolean) _cache; } else { _value = (ASTState.CircularValue) _cache; } } else { _value = new ASTState.CircularValue(); unassignedAfterReturn_Variable_values.put(_parameters, _value); _value.value = true; } ASTState state = state(); if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); boolean new_unassignedAfterReturn_Variable_value; do { _value.cycle = state.nextCycle(); new_unassignedAfterReturn_Variable_value = unassignedAfterReturn_compute(v); if (((Boolean)_value.value) != new_unassignedAfterReturn_Variable_value) { state.setChangeInCycle(); _value.value = new_unassignedAfterReturn_Variable_value; } } while (state.testAndClearChangeInCycle()); unassignedAfterReturn_Variable_values.put(_parameters, new_unassignedAfterReturn_Variable_value); state.leaveCircle(); return new_unassignedAfterReturn_Variable_value; } else if (_value.cycle != state.cycle()) { _value.cycle = state.cycle(); boolean new_unassignedAfterReturn_Variable_value = unassignedAfterReturn_compute(v); if (((Boolean)_value.value) != new_unassignedAfterReturn_Variable_value) { state.setChangeInCycle(); _value.value = new_unassignedAfterReturn_Variable_value; } return new_unassignedAfterReturn_Variable_value; } else { return (Boolean) _value.value; } } /** @apilevel internal */ private boolean unassignedAfterReturn_compute(Variable v) { Collection branches = new HashSet(); collectBranches(branches); for (Stmt branch : branches) { if (branch instanceof ReturnStmt) { ReturnStmt stmt = (ReturnStmt) branch; if (!stmt.unassignedAfterReachedFinallyBlocks(v)) { return false; } } } return true; } /** @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:895") 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 = getNumStmt() == 0 ? unassignedBefore(v) : getStmt(getNumStmt() - 1).unassignedAfter(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 = getNumStmt() == 0 ? unassignedBefore(v) : getStmt(getNumStmt() - 1).unassignedAfter(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 variableScopeEndLabel_CodeGeneration_reset() { variableScopeEndLabel_CodeGeneration_computed = null; variableScopeEndLabel_CodeGeneration_values = null; } /** @apilevel internal */ protected java.util.Map variableScopeEndLabel_CodeGeneration_values; /** @apilevel internal */ protected java.util.Map variableScopeEndLabel_CodeGeneration_computed; /** * @attribute syn * @aspect CodeGeneration * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:73 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="CodeGeneration", declaredAt="/home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:73") public int variableScopeEndLabel(CodeGeneration gen) { Object _parameters = gen; if (variableScopeEndLabel_CodeGeneration_computed == null) variableScopeEndLabel_CodeGeneration_computed = new java.util.HashMap(4); if (variableScopeEndLabel_CodeGeneration_values == null) variableScopeEndLabel_CodeGeneration_values = new java.util.HashMap(4); ASTState state = state(); if (variableScopeEndLabel_CodeGeneration_values.containsKey(_parameters) && variableScopeEndLabel_CodeGeneration_computed.containsKey(_parameters) && (variableScopeEndLabel_CodeGeneration_computed.get(_parameters) == ASTState.NON_CYCLE || variableScopeEndLabel_CodeGeneration_computed.get(_parameters) == state().cycle())) { return (Integer) variableScopeEndLabel_CodeGeneration_values.get(_parameters); } int variableScopeEndLabel_CodeGeneration_value = gen.variableScopeLabel(); if (state().inCircle()) { variableScopeEndLabel_CodeGeneration_values.put(_parameters, variableScopeEndLabel_CodeGeneration_value); variableScopeEndLabel_CodeGeneration_computed.put(_parameters, state().cycle()); } else { variableScopeEndLabel_CodeGeneration_values.put(_parameters, variableScopeEndLabel_CodeGeneration_value); variableScopeEndLabel_CodeGeneration_computed.put(_parameters, ASTState.NON_CYCLE); } return variableScopeEndLabel_CodeGeneration_value; } /** * @attribute inh * @aspect UnreachableStatements * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:49 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH) @ASTNodeAnnotation.Source(aspect="UnreachableStatements", declaredAt="/home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:49") public boolean reachable() { boolean reachable_value = getParent().Define_reachable(this, null); return reachable_value; } /** * @attribute inh * @aspect TypeScopePropagation * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:400 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH) @ASTNodeAnnotation.Source(aspect="TypeScopePropagation", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:400") public SimpleSet lookupType(String name) { Object _parameters = name; if (lookupType_String_computed == null) lookupType_String_computed = new java.util.HashMap(4); if (lookupType_String_values == null) lookupType_String_values = new java.util.HashMap(4); ASTState state = state(); if (lookupType_String_values.containsKey(_parameters) && lookupType_String_computed.containsKey(_parameters) && (lookupType_String_computed.get(_parameters) == ASTState.NON_CYCLE || lookupType_String_computed.get(_parameters) == state().cycle())) { return (SimpleSet) lookupType_String_values.get(_parameters); } SimpleSet lookupType_String_value = getParent().Define_lookupType(this, null, name); if (state().inCircle()) { lookupType_String_values.put(_parameters, lookupType_String_value); lookupType_String_computed.put(_parameters, state().cycle()); } else { lookupType_String_values.put(_parameters, lookupType_String_value); lookupType_String_computed.put(_parameters, ASTState.NON_CYCLE); } return lookupType_String_value; } /** @apilevel internal */ private void lookupType_String_reset() { lookupType_String_computed = null; lookupType_String_values = null; } /** @apilevel internal */ protected java.util.Map lookupType_String_values; /** @apilevel internal */ protected java.util.Map lookupType_String_computed; /** * @attribute inh * @aspect VariableScope * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:41 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH) @ASTNodeAnnotation.Source(aspect="VariableScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:41") public SimpleSet lookupVariable(String name) { Object _parameters = name; if (lookupVariable_String_computed == null) lookupVariable_String_computed = new java.util.HashMap(4); if (lookupVariable_String_values == null) lookupVariable_String_values = new java.util.HashMap(4); ASTState state = state(); if (lookupVariable_String_values.containsKey(_parameters) && lookupVariable_String_computed.containsKey(_parameters) && (lookupVariable_String_computed.get(_parameters) == ASTState.NON_CYCLE || lookupVariable_String_computed.get(_parameters) == state().cycle())) { return (SimpleSet) lookupVariable_String_values.get(_parameters); } SimpleSet lookupVariable_String_value = getParent().Define_lookupVariable(this, null, name); if (state().inCircle()) { lookupVariable_String_values.put(_parameters, lookupVariable_String_value); lookupVariable_String_computed.put(_parameters, state().cycle()); } else { lookupVariable_String_values.put(_parameters, lookupVariable_String_value); lookupVariable_String_computed.put(_parameters, ASTState.NON_CYCLE); } return lookupVariable_String_value; } /** @apilevel internal */ private void lookupVariable_String_reset() { lookupVariable_String_computed = null; lookupVariable_String_values = null; } /** @apilevel internal */ protected java.util.Map lookupVariable_String_values; /** @apilevel internal */ protected java.util.Map lookupVariable_String_computed; /** * @attribute inh * @aspect NameCheck * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:684 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH) @ASTNodeAnnotation.Source(aspect="NameCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/NameCheck.jrag:684") public SimpleSet otherLocalClassDecls(String name) { SimpleSet otherLocalClassDecls_String_value = getParent().Define_otherLocalClassDecls(this, null, name); return otherLocalClassDecls_String_value; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36 * @apilevel internal */ public NameType Define_nameType(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:134 int childIndex = _callerNode.getIndexOfChild(_childNode); return NameType.EXPRESSION_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/DeclareBeforeUse.jrag:35 * @apilevel internal */ public int Define_blockIndex(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DeclareBeforeUse.jrag:40 int index = _callerNode.getIndexOfChild(_childNode); return index; } else { return getParent().Define_blockIndex(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DeclareBeforeUse.jrag:35 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute blockIndex */ protected boolean canDefine_blockIndex(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:49 * @apilevel internal */ public boolean Define_reachable(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:70 int index = _callerNode.getIndexOfChild(_childNode); return index == 0 ? reachable() : getStmt(index-1).canCompleteNormally(); } else { return getParent().Define_reachable(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:49 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute reachable */ protected boolean canDefine_reachable(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:207 * @apilevel internal */ public boolean Define_reportUnreachable(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:208 int i = _callerNode.getIndexOfChild(_childNode); return i == 0 ? reachable() : getStmt(i-1).reachable(); } else { return getParent().Define_reportUnreachable(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:207 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute reportUnreachable */ protected boolean canDefine_reportUnreachable(ASTNode _callerNode, ASTNode _childNode) { 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 == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:562 int index = _callerNode.getIndexOfChild(_childNode); { SimpleSet result = emptySet(); for (int i = index; i >= 0 && !(getStmt(i) instanceof Case); i--) { if (getStmt(i) instanceof LocalClassDeclStmt) { TypeDecl t = ((LocalClassDeclStmt) getStmt(i)).getClassDecl(); if (t.name().equals(name)) { result = result.add(t); } } } if (!result.isEmpty()) { return result; } return 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 == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:127 int index = _callerNode.getIndexOfChild(_childNode); { VariableDeclarator v = localVariableDeclaration(name); // Declare before use and shadowing. if (v != null && declaredBeforeUse(v, index)) { return v; } return 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/DefiniteAssignment.jrag:66 * @apilevel internal */ public boolean Define_isIncOrDec(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:69 int childIndex = _callerNode.getIndexOfChild(_childNode); return false; } else { return getParent().Define_isIncOrDec(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:66 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute isIncOrDec */ protected boolean canDefine_isIncOrDec(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 == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:557 int index = _callerNode.getIndexOfChild(_childNode); return index == 0 ? assignedBefore(v) : getStmt(index - 1).assignedAfter(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 == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1164 int index = _callerNode.getIndexOfChild(_childNode); return index == 0 ? unassignedBefore(v) : getStmt(index - 1).unassignedAfter(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/frontend/NameCheck.jrag:441 * @apilevel internal */ public VariableScope Define_outerScope(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:447 int childIndex = _callerNode.getIndexOfChild(_childNode); return this; } else { return getParent().Define_outerScope(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:441 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute outerScope */ protected boolean canDefine_outerScope(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:682 * @apilevel internal */ public SimpleSet Define_otherLocalClassDecls(ASTNode _callerNode, ASTNode _childNode, String name) { if (_callerNode == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:688 int index = _callerNode.getIndexOfChild(_childNode); { SimpleSet local = emptySet(); for (int i = index-1; i >= 0 && !(getStmt(i) instanceof Case); --i) { if (getStmt(i) instanceof LocalClassDeclStmt) { TypeDecl t = ((LocalClassDeclStmt) getStmt(i)).getClassDecl(); if (t.name().equals(name)) { local = local.add(t); } } } if (!local.isEmpty()) { return local; } else { return otherLocalClassDecls(name); } } } else { return getParent().Define_otherLocalClassDecls(this, _callerNode, name); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:682 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute otherLocalClassDecls */ protected boolean canDefine_otherLocalClassDecls(ASTNode _callerNode, ASTNode _childNode, String name) { return true; } /** * @declaredat /home/jesper/git/extendj/java5/frontend/MethodSignature.jrag:519 * @apilevel internal */ public Block Define_enclosingBlock(ASTNode _callerNode, ASTNode _childNode) { int childIndex = this.getIndexOfChild(_callerNode); return this; } /** * @declaredat /home/jesper/git/extendj/java5/frontend/MethodSignature.jrag:519 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute enclosingBlock */ protected boolean canDefine_enclosingBlock(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/backend/LocalNum.jrag:63 * @apilevel internal */ public int Define_localNum(ASTNode _callerNode, ASTNode _childNode) { if (_callerNode == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/backend/LocalNum.jrag:178 int index = _callerNode.getIndexOfChild(_childNode); { if (index == 0) { return localNum(); } else { return getStmt(index-1).localNum() + getStmt(index-1).localSize(); } } } else { return getParent().Define_localNum(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/backend/LocalNum.jrag:63 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute localNum */ protected boolean canDefine_localNum(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:71 * @apilevel internal */ public int Define_variableScopeEndLabel(ASTNode _callerNode, ASTNode _childNode, CodeGeneration gen) { if (_callerNode == getStmtListNoTransform()) { // @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:75 int i = _callerNode.getIndexOfChild(_childNode); return variableScopeEndLabel(gen); } else { return getParent().Define_variableScopeEndLabel(this, _callerNode, gen); } } /** * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:71 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute variableScopeEndLabel */ protected boolean canDefine_variableScopeEndLabel(ASTNode _callerNode, ASTNode _childNode, CodeGeneration gen) { return true; } /** @apilevel internal */ public ASTNode rewriteTo() { return super.rewriteTo(); } /** @apilevel internal */ public boolean canRewrite() { return false; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy