org.extendj.ast.CatchClause 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 org.jastadd.util.PrettyPrintable;
import org.jastadd.util.PrettyPrinter;
import org.jastadd.util.*;
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.io.BufferedInputStream;
import java.io.DataInputStream;
/**
* Abstract superclass for catch clauses.
* @ast node
* @declaredat /home/jesper/git/extendj/java4/grammar/CatchClause.ast:4
* @astdecl CatchClause : ASTNode ::= Block;
* @production CatchClause : {@link ASTNode} ::= {@link Block};
*/
public abstract class CatchClause extends ASTNode implements Cloneable, VariableScope {
/**
* @aspect CreateBCode
* @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:39
*/
public abstract void exceptionTableEntries(CodeGeneration gen,
int begin_lbl, int end_lbl);
/**
* @declaredat ASTNode:1
*/
public CatchClause() {
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];
}
/**
* @declaredat ASTNode:13
*/
@ASTNodeAnnotation.Constructor(
name = {"Block"},
type = {"Block"},
kind = {"Child"}
)
public CatchClause(Block p0) {
setChild(p0, 0);
}
/** @apilevel low-level
* @declaredat ASTNode:22
*/
protected int numChildren() {
return 1;
}
/**
* @apilevel internal
* @declaredat ASTNode:28
*/
public boolean mayHaveRewrite() {
return false;
}
/** @apilevel internal
* @declaredat ASTNode:32
*/
public void flushAttrCache() {
super.flushAttrCache();
parameterDeclaration_String_reset();
label_reset();
typeThrowable_reset();
reachableCatchClause_TypeDecl_reset();
lookupVariable_String_reset();
}
/** @apilevel internal
* @declaredat ASTNode:41
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:45
*/
public CatchClause clone() throws CloneNotSupportedException {
CatchClause node = (CatchClause) super.clone();
return node;
}
/**
* 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:56
*/
@Deprecated
public abstract CatchClause fullCopy();
/**
* 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:64
*/
public abstract CatchClause treeCopyNoTransform();
/**
* 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:72
*/
public abstract CatchClause treeCopy();
/**
* Replaces the Block child.
* @param node The new node to replace the Block child.
* @apilevel high-level
*/
public void setBlock(Block node) {
setChild(node, 0);
}
/**
* Retrieves the Block child.
* @return The current node used as the Block child.
* @apilevel high-level
*/
@ASTNodeAnnotation.Child(name="Block")
public Block getBlock() {
return (Block) getChild(0);
}
/**
* Retrieves the Block child.
* This method does not invoke AST transformations.
* @return The current node used as the Block child.
* @apilevel low-level
*/
public Block getBlockNoTransform() {
return (Block) getChildNoTransform(0);
}
/**
* @attribute syn
* @aspect ExceptionHandling
* @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:279
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="ExceptionHandling", declaredAt="/home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:279")
public boolean handles(TypeDecl exceptionType) {
boolean handles_TypeDecl_value = false;
return handles_TypeDecl_value;
}
/** @apilevel internal */
private void parameterDeclaration_String_reset() {
parameterDeclaration_String_computed = null;
parameterDeclaration_String_values = null;
}
/** @apilevel internal */
protected java.util.Map parameterDeclaration_String_values;
/** @apilevel internal */
protected java.util.Map parameterDeclaration_String_computed;
/**
* @attribute syn
* @aspect VariableScope
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:192
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="VariableScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:192")
public SimpleSet parameterDeclaration(String name) {
Object _parameters = name;
if (parameterDeclaration_String_computed == null) parameterDeclaration_String_computed = new java.util.HashMap(4);
if (parameterDeclaration_String_values == null) parameterDeclaration_String_values = new java.util.HashMap(4);
ASTState state = state();
if (parameterDeclaration_String_values.containsKey(_parameters)
&& parameterDeclaration_String_computed.containsKey(_parameters)
&& (parameterDeclaration_String_computed.get(_parameters) == ASTState.NON_CYCLE || parameterDeclaration_String_computed.get(_parameters) == state().cycle())) {
return (SimpleSet) parameterDeclaration_String_values.get(_parameters);
}
SimpleSet parameterDeclaration_String_value = emptySet();
if (state().inCircle()) {
parameterDeclaration_String_values.put(_parameters, parameterDeclaration_String_value);
parameterDeclaration_String_computed.put(_parameters, state().cycle());
} else {
parameterDeclaration_String_values.put(_parameters, parameterDeclaration_String_value);
parameterDeclaration_String_computed.put(_parameters, ASTState.NON_CYCLE);
}
return parameterDeclaration_String_value;
}
/** @apilevel internal */
private void label_reset() {
label_computed = null;
}
/** @apilevel internal */
protected ASTState.Cycle label_computed = null;
/** @apilevel internal */
protected int label_value;
/**
* @attribute syn
* @aspect CreateBCode
* @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1874
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="CreateBCode", declaredAt="/home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1874")
public int label() {
ASTState state = state();
if (label_computed == ASTState.NON_CYCLE || label_computed == state().cycle()) {
return label_value;
}
label_value = hostType().constantPool().newLabel();
if (state().inCircle()) {
label_computed = state().cycle();
} else {
label_computed = ASTState.NON_CYCLE;
}
return label_value;
}
/**
* @attribute inh
* @aspect SpecialClasses
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:93
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH)
@ASTNodeAnnotation.Source(aspect="SpecialClasses", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupType.jrag:93")
public TypeDecl typeThrowable() {
ASTState state = state();
if (typeThrowable_computed == ASTState.NON_CYCLE || typeThrowable_computed == state().cycle()) {
return typeThrowable_value;
}
typeThrowable_value = getParent().Define_typeThrowable(this, null);
if (state().inCircle()) {
typeThrowable_computed = state().cycle();
} else {
typeThrowable_computed = ASTState.NON_CYCLE;
}
return typeThrowable_value;
}
/** @apilevel internal */
private void typeThrowable_reset() {
typeThrowable_computed = null;
typeThrowable_value = null;
}
/** @apilevel internal */
protected ASTState.Cycle typeThrowable_computed = null;
/** @apilevel internal */
protected TypeDecl typeThrowable_value;
/**
* @return true if an exception of type exceptionType is catchable by the catch clause
* @attribute inh
* @aspect UnreachableStatements
* @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:182
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH)
@ASTNodeAnnotation.Source(aspect="UnreachableStatements", declaredAt="/home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:182")
public boolean reachableCatchClause(TypeDecl exceptionType) {
Object _parameters = exceptionType;
if (reachableCatchClause_TypeDecl_computed == null) reachableCatchClause_TypeDecl_computed = new java.util.HashMap(4);
if (reachableCatchClause_TypeDecl_values == null) reachableCatchClause_TypeDecl_values = new java.util.HashMap(4);
ASTState state = state();
if (reachableCatchClause_TypeDecl_values.containsKey(_parameters)
&& reachableCatchClause_TypeDecl_computed.containsKey(_parameters)
&& (reachableCatchClause_TypeDecl_computed.get(_parameters) == ASTState.NON_CYCLE || reachableCatchClause_TypeDecl_computed.get(_parameters) == state().cycle())) {
return (Boolean) reachableCatchClause_TypeDecl_values.get(_parameters);
}
boolean reachableCatchClause_TypeDecl_value = getParent().Define_reachableCatchClause(this, null, exceptionType);
if (state().inCircle()) {
reachableCatchClause_TypeDecl_values.put(_parameters, reachableCatchClause_TypeDecl_value);
reachableCatchClause_TypeDecl_computed.put(_parameters, state().cycle());
} else {
reachableCatchClause_TypeDecl_values.put(_parameters, reachableCatchClause_TypeDecl_value);
reachableCatchClause_TypeDecl_computed.put(_parameters, ASTState.NON_CYCLE);
}
return reachableCatchClause_TypeDecl_value;
}
/** @apilevel internal */
private void reachableCatchClause_TypeDecl_reset() {
reachableCatchClause_TypeDecl_computed = null;
reachableCatchClause_TypeDecl_values = null;
}
/** @apilevel internal */
protected java.util.Map reachableCatchClause_TypeDecl_values;
/** @apilevel internal */
protected java.util.Map reachableCatchClause_TypeDecl_computed;
/**
* @attribute inh
* @aspect VariableScope
* @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:44
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH)
@ASTNodeAnnotation.Source(aspect="VariableScope", declaredAt="/home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:44")
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 CreateBCode
* @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:37
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH)
@ASTNodeAnnotation.Source(aspect="CreateBCode", declaredAt="/home/jesper/git/extendj/java4/backend/CreateBCode.jrag:37")
public TypeDecl hostType() {
TypeDecl hostType_value = getParent().Define_hostType(this, null);
return hostType_value;
}
/**
* @declaredat /home/jesper/git/extendj/java5/frontend/EnhancedFor.jrag:138
* @apilevel internal
*/
public SimpleSet Define_lookupVariable(ASTNode _callerNode, ASTNode _childNode, String name) {
if (getBlockNoTransform() != null && _callerNode == getBlock()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:138
{
SimpleSet result = parameterDeclaration(name);
if (!result.isEmpty()) {
return result;
}
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;
}
/** @apilevel internal */
public ASTNode rewriteTo() {
return super.rewriteTo();
}
/** @apilevel internal */
public boolean canRewrite() {
return false;
}
}