⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 astnode.java

📁 JDK1.4编译器后端
💻 JAVA
📖 第 1 页 / 共 3 页
字号:

package AST;
import java.util.HashSet;import java.util.LinkedHashSet;import java.io.FileNotFoundException;import java.io.File;import java.util.*;import beaver.*;import java.util.ArrayList;import java.util.zip.*;import java.io.*;// Generated with JastAdd II (http://jastadd.cs.lth.se) version R20080407public class ASTNode<T extends ASTNode> extends beaver.Symbol  implements Cloneable, Iterable<T> {
    public void flushCache() {    }     @SuppressWarnings({"unchecked", "cast"})  public ASTNode<T> clone() throws CloneNotSupportedException {        ASTNode node = (ASTNode)super.clone();        node.in$Circle(false);        node.is$Final(false);    return node;    }     @SuppressWarnings({"unchecked", "cast"})  public ASTNode<T> copy() {      try {          ASTNode node = (ASTNode)clone();          if(children != null) node.children = (ASTNode[])children.clone();          return node;      } catch (CloneNotSupportedException e) {      }      System.err.println("Error: Could not clone node of type " + getClass().getName() + "!");      return null;    }     @SuppressWarnings({"unchecked", "cast"})  public ASTNode<T> fullCopy() {        ASTNode res = (ASTNode)copy();        for(int i = 0; i < getNumChildNoTransform(); i++) {          ASTNode node = getChildNoTransform(i);          if(node != null) node = node.fullCopy();          res.setChild(node, i);        }        return res;    }    // Declared in AccessControl.jrag at line 125      public void accessControl() {  }    // Declared in AnonymousClasses.jrag at line 136  protected void collectExceptions(Collection c, ASTNode target) {    for(int i = 0; i < getNumChild(); i++)      getChild(i).collectExceptions(c, target);  }    // Declared in BranchTarget.jrag at line 45    public void collectBranches(Collection c) {    for(int i = 0; i < getNumChild(); i++)      getChild(i).collectBranches(c);  }    // Declared in BranchTarget.jrag at line 151  public Stmt branchTarget(Stmt branchStmt) {    if(getParent() != null)      return getParent().branchTarget(branchStmt);    else      return null;  }    // Declared in BranchTarget.jrag at line 191  public void collectFinally(Stmt branchStmt, ArrayList list) {    if(getParent() != null)      getParent().collectFinally(branchStmt, list);  }    // Declared in DeclareBeforeUse.jrag at line 13  public int varChildIndex(Block b) {    ASTNode node = this;    while(node.getParent().getParent() != b) {      node = node.getParent();    }    return b.getStmtListNoTransform().getIndexOfChild(node);  }    // Declared in DeclareBeforeUse.jrag at line 31  public int varChildIndex(TypeDecl t) {    ASTNode node = this;    while(node != null && node.getParent() != null && node.getParent().getParent() != t) {      node = node.getParent();    }    if(node == null)      return -1;    return t.getBodyDeclListNoTransform().getIndexOfChild(node);  }    // Declared in DefiniteAssignment.jrag at line 12  public void definiteAssignment() {  }    // Declared in DefiniteAssignment.jrag at line 451  // 16.2.2 9th, 10th bullet  protected boolean checkDUeverywhere(Variable v) {    for(int i = 0; i < getNumChild(); i++)      if(!getChild(i).checkDUeverywhere(v))        return false;    return true;  }    // Declared in DefiniteAssignment.jrag at line 561  protected boolean isDescendantTo(ASTNode node) {    if(this == node)      return true;    if(getParent() == null)      return false;    return getParent().isDescendantTo(node);  }    // Declared in ErrorCheck.jrag at line 12  protected String sourceFile() {    ASTNode node = this;    while(node != null && !(node instanceof CompilationUnit))      node = node.getParent();    if(node == null)      return "Unknown file";    CompilationUnit u = (CompilationUnit)node;    return u.relativeName();  }    // Declared in ErrorCheck.jrag at line 34  // set start and end position to the same as the argument and return self  public ASTNode setLocation(ASTNode node) {    setStart(node.getStart());    setEnd(node.getEnd());    return this;  }    // Declared in ErrorCheck.jrag at line 40  public ASTNode setStart(int i) {    start = i;    return this;  }    // Declared in ErrorCheck.jrag at line 44  public int start() {    return start;  }    // Declared in ErrorCheck.jrag at line 47  public ASTNode setEnd(int i) {    end = i;    return this;  }    // Declared in ErrorCheck.jrag at line 51  public int end() {    return end;  }    // Declared in ErrorCheck.jrag at line 57  public String location() {    return "" + lineNumber();  }    // Declared in ErrorCheck.jrag at line 60  public String errorPrefix() {    return sourceFile() + ":" + location() + ":\n" + "  *** Semantic Error: ";  }    // Declared in ErrorCheck.jrag at line 63  public String warningPrefix() {    return sourceFile() + ":" + location() + ":\n" + "  *** WARNING: ";  }    // Declared in ErrorCheck.jrag at line 173  protected void error(String s) {    ASTNode node = this;    while(node != null && !(node instanceof CompilationUnit))      node = node.getParent();    CompilationUnit cu = (CompilationUnit)node;    if(getNumChild() == 0 && getStart() != 0 && getEnd() != 0) {        int line = getLine(getStart());      int column = getColumn(getStart());      int endLine = getLine(getEnd());      int endColumn = getColumn(getEnd());      cu.errors.add(new Problem(sourceFile(), s, line, column, endLine, endColumn, Problem.Severity.ERROR, Problem.Kind.SEMANTIC));    }    else      cu.errors.add(new Problem(sourceFile(), s, lineNumber(), Problem.Severity.ERROR, Problem.Kind.SEMANTIC));  }    // Declared in ErrorCheck.jrag at line 189  protected void warning(String s) {    ASTNode node = this;    while(node != null && !(node instanceof CompilationUnit))      node = node.getParent();    CompilationUnit cu = (CompilationUnit)node;    cu.warnings.add(new Problem(sourceFile(), "WARNING: " + s, lineNumber(), Problem.Severity.WARNING));  }    // Declared in ErrorCheck.jrag at line 197    public void collectErrors() {    nameCheck();    typeCheck();    accessControl();    exceptionHandling();    checkUnreachableStmt();    definiteAssignment();    checkModifiers();    for(int i = 0; i < getNumChild(); i++) {      getChild(i).collectErrors();    }  }    // Declared in ExceptionHandling.jrag at line 40    public void exceptionHandling() {  }    // Declared in ExceptionHandling.jrag at line 196  protected boolean reachedException(TypeDecl type) {    for(int i = 0; i < getNumChild(); i++)      if(getChild(i).reachedException(type))        return true;    return false;  }    // Declared in LookupMethod.jrag at line 54  public static Collection removeInstanceMethods(Collection c) {    c = new LinkedList(c);    for(Iterator iter = c.iterator(); iter.hasNext(); ) {      MethodDecl m = (MethodDecl)iter.next();      if(!m.isStatic())        iter.remove();    }    return c;  }    // Declared in LookupMethod.jrag at line 342  protected static void putSimpleSetElement(HashMap map, Object key, Object value) {    SimpleSet set = (SimpleSet)map.get(key);    if(set == null) set = SimpleSet.emptySet;    map.put(key, set.add(value));  }    // Declared in LookupVariable.jrag at line 177  public SimpleSet removeInstanceVariables(SimpleSet oldSet) {    SimpleSet newSet = SimpleSet.emptySet;    for(Iterator iter = oldSet.iterator(); iter.hasNext(); ) {      Variable v = (Variable)iter.next();      if(!v.isInstanceVariable())        newSet = newSet.add(v);    }    return newSet;  }    // Declared in Modifiers.jrag at line 11  void checkModifiers() {  }    // Declared in NameCheck.jrag at line 11  public void nameCheck() {  }    // Declared in NameCheck.jrag at line 14  public TypeDecl extractSingleType(SimpleSet c) {    if(c.size() != 1)      return null;    return (TypeDecl)c.iterator().next();  }    // Declared in PrettyPrint.jadd at line 13  // Helper for indentation    protected static int indent = 0;    // Declared in PrettyPrint.jadd at line 15    public static String indent() {    StringBuffer s = new StringBuffer();    for(int i = 0; i < indent; i++) {      s.append("  ");    }    return s.toString();  }    // Declared in PrettyPrint.jadd at line 25  // Default output    public String toString() {    StringBuffer s = new StringBuffer();    toString(s);    return s.toString().trim();  }    // Declared in PrettyPrint.jadd at line 31    public void toString(StringBuffer s) {    throw new Error("Operation toString(StringBuffer s) not implemented for " + getClass().getName());  }    // Declared in PrettyPrint.jadd at line 749  // dump the AST to standard output  public String dumpTree() {    StringBuffer s = new StringBuffer();    dumpTree(s, 0);    return s.toString();  }    // Declared in PrettyPrint.jadd at line 755  public void dumpTree(StringBuffer s, int j) {    for(int i = 0; i < j; i++) {      s.append("  ");    }    s.append(dumpString() + "\n");    for(int i = 0; i < getNumChild(); i++)      getChild(i).dumpTree(s, j + 1);  }    // Declared in PrettyPrint.jadd at line 764  public String dumpTreeNoRewrite() {    StringBuffer s = new StringBuffer();    dumpTreeNoRewrite(s, 0);    return s.toString();  }    // Declared in PrettyPrint.jadd at line 769  protected void dumpTreeNoRewrite(StringBuffer s, int indent) {    for(int i = 0; i < indent; i++)      s.append("  ");    s.append(dumpString());    s.append("\n");    for(int i = 0; i < getNumChildNoTransform(); i++) {      getChildNoTransform(i).dumpTreeNoRewrite(s, indent+1);    }  }    // Declared in PrimitiveTypes.jrag at line 11  protected static final String PRIMITIVE_PACKAGE_NAME = "@primitive";    // Declared in TypeCheck.jrag at line 12  public void typeCheck() {  }    // Declared in UnreachableStatements.jrag at line 12  void checkUnreachableStmt() {  }    // Declared in CodeGeneration.jrag at line 11  public void setSourceLineNumber(int i) {    setStart(ASTNode.makePosition(i, 1));  }    // Declared in CodeGeneration.jrag at line 30  protected int findFirstSourceLineNumber() {    if(getStart() != 0)      return getLine(getStart());    for(int i = 0; i < getNumChild(); i++) {      int num = getChild(i).findFirstSourceLineNumber();      if(num != -1)        return num;    }    return -1;  }    // Declared in CodeGeneration.jrag at line 591  public void error() {    Throwable t = new Throwable();    StackTraceElement[] ste = new Throwable().getStackTrace();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -