org.extendj.ast.NTAFinallyBlock Maven / Gradle / Ivy
/* This file was generated with JastAdd2 (http://jastadd.org) version 2.3.0 */
package org.extendj.ast;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
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.*;
import java.util.zip.*;
import java.io.*;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import org.jastadd.util.PrettyPrintable;
import org.jastadd.util.PrettyPrinter;
import java.io.FileNotFoundException;
import java.io.InputStream;
import org.jastadd.util.*;
import java.io.File;
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;
/**
* This node only exists to distinguish NTA-finally blocks from
* regular, non-NTA, blocks. This is required to avoid an endlessly
* recursive AST.
* @ast node
* @declaredat /home/jesper/git/extendj/java4/grammar/NTAFinally.ast:6
* @astdecl NTAFinallyBlock : Block;
* @production NTAFinallyBlock : {@link Block};
*/
public class NTAFinallyBlock extends Block implements Cloneable {
/**
* @aspect NTAFinally
* @declaredat /home/jesper/git/extendj/java4/frontend/NTAFinally.jrag:82
*/
private FinallyHost origin;
/**
* @aspect NTAFinally
* @declaredat /home/jesper/git/extendj/java4/frontend/NTAFinally.jrag:84
*/
public NTAFinallyBlock(FinallyHost finallyHost) {
this.origin = finallyHost;
}
/**
* @declaredat ASTNode:1
*/
public NTAFinallyBlock() {
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 NTAFinallyBlock(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();
}
/** @apilevel internal
* @declaredat ASTNode:37
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:41
*/
public NTAFinallyBlock clone() throws CloneNotSupportedException {
NTAFinallyBlock node = (NTAFinallyBlock) super.clone();
return node;
}
/** @apilevel internal
* @declaredat ASTNode:46
*/
public NTAFinallyBlock copy() {
try {
NTAFinallyBlock node = (NTAFinallyBlock) 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:65
*/
@Deprecated
public NTAFinallyBlock 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:75
*/
public NTAFinallyBlock treeCopyNoTransform() {
NTAFinallyBlock tree = (NTAFinallyBlock) 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:95
*/
public NTAFinallyBlock treeCopy() {
NTAFinallyBlock tree = (NTAFinallyBlock) 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:109
*/
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();
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/BranchTarget.jrag:273
* @apilevel internal
*/
public FinallyHost Define_enclosingFinally(ASTNode _callerNode, ASTNode _childNode, Stmt branch) {
int childIndex = this.getIndexOfChild(_callerNode);
return origin.enclosingFinally(branch);
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/BranchTarget.jrag:273
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute enclosingFinally
*/
protected boolean canDefine_enclosingFinally(ASTNode _callerNode, ASTNode _childNode, Stmt branch) {
return true;
}
/** @apilevel internal */
public ASTNode rewriteTo() {
return super.rewriteTo();
}
/** @apilevel internal */
public boolean canRewrite() {
return false;
}
}