org.extendj.ast.ConstructorReferenceAccess Maven / Gradle / Ivy
/* 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/java8/grammar/ConstructorReference.ast:5
* @astdecl ConstructorReferenceAccess : ClassInstanceExpr;
* @production ConstructorReferenceAccess : {@link ClassInstanceExpr};
*/
public class ConstructorReferenceAccess extends ClassInstanceExpr implements Cloneable {
/**
* @aspect Synthetics
* @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:446
*/
private FunctionDescriptor targetDescriptor;
/**
* @aspect Synthetics
* @declaredat /home/jesper/git/extendj/java8/frontend/MethodReference.jrag:447
*/
public ConstructorReferenceAccess(Access access,
List args, FunctionDescriptor fd) {
super(access, args);
this.targetDescriptor = fd;
}
/**
* @declaredat ASTNode:1
*/
public ConstructorReferenceAccess() {
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 ConstructorReferenceAccess(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();
targetType_reset();
}
/** @apilevel internal
* @declaredat ASTNode:41
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:45
*/
public ConstructorReferenceAccess clone() throws CloneNotSupportedException {
ConstructorReferenceAccess node = (ConstructorReferenceAccess) super.clone();
return node;
}
/** @apilevel internal
* @declaredat ASTNode:50
*/
public ConstructorReferenceAccess copy() {
try {
ConstructorReferenceAccess node = (ConstructorReferenceAccess) 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:69
*/
@Deprecated
public ConstructorReferenceAccess 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:79
*/
public ConstructorReferenceAccess treeCopyNoTransform() {
ConstructorReferenceAccess tree = (ConstructorReferenceAccess) 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:99
*/
public ConstructorReferenceAccess treeCopy() {
ConstructorReferenceAccess tree = (ConstructorReferenceAccess) 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:113
*/
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);
}
/** @apilevel internal */
private void targetType_reset() {
targetType_computed = null;
targetType_value = null;
}
/** @apilevel internal */
protected ASTState.Cycle targetType_computed = null;
/** @apilevel internal */
protected TypeDecl targetType_value;
/**
* @attribute syn
* @aspect TargetType
* @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:207
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="TargetType", declaredAt="/home/jesper/git/extendj/java8/frontend/TargetType.jrag:207")
public TypeDecl targetType() {
ASTState state = state();
if (targetType_computed == ASTState.NON_CYCLE || targetType_computed == state().cycle()) {
return targetType_value;
}
targetType_value = targetType_compute();
if (state().inCircle()) {
targetType_computed = state().cycle();
} else {
targetType_computed = ASTState.NON_CYCLE;
}
return targetType_value;
}
/** @apilevel internal */
private TypeDecl targetType_compute() {
if (targetDescriptor.method.hasValue()) {
return targetDescriptor.method.get().type();
} else {
return unknownType();
}
}
/**
* @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:31
* @apilevel internal
*/
public TypeDecl Define_targetType(ASTNode _callerNode, ASTNode _childNode) {
if (getAccessNoTransform() != null && _callerNode == getAccess()) {
// @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:223
{
if (targetDescriptor.method.hasValue()) {
return targetDescriptor.method.get().type();
} else {
return unknownType();
}
}
}
else {
return super.Define_targetType(_callerNode, _childNode);
}
}
/**
* @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:31
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute targetType
*/
protected boolean canDefine_targetType(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/** @apilevel internal */
public ASTNode rewriteTo() {
return super.rewriteTo();
}
/** @apilevel internal */
public boolean canRewrite() {
return false;
}
}