org.extendj.ast.FieldDeclarator 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;
/**
* @ast node
* @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:202
* @astdecl FieldDeclarator : Declarator;
* @production FieldDeclarator : {@link Declarator};
*/
public class FieldDeclarator extends Declarator implements Cloneable {
/** Create an access to this field.
* @aspect BoundNames
* @declaredat /home/jesper/git/extendj/java4/frontend/BoundNames.jrag:33
*/
public Access createBoundAccess() {
if (isStatic()) {
return hostType().createQualifiedAccess().qualifiesAccess(new BoundFieldAccess(this));
} else {
return new ThisAccess().qualifiesAccess(new BoundFieldAccess(this));
}
}
/**
* Copies the declarator without initializer.
* @aspect LookupParTypeDecl
* @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1502
*/
public FieldDeclarator signatureCopy() {
return new FieldDeclarator(getID(), getDimsList().treeCopyNoTransform(), new Opt());
}
/**
* @aspect CreateBCode
* @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:595
*/
public void refined_CreateBCode_FieldDeclarator_emitLoadVariable(CodeGeneration gen, Access access) {
access.createLoadQualifier(gen, this);
if (isConstant() && (type().isPrimitive() || type().isString())) {
if (!isStatic()) {
gen.POP(access.fieldQualifierType());
}
constant().createBCode(gen);
} else if (access.requiresAccessor()) {
access.fieldQualifierType().fieldAccessor(this).emitInvokeMethod(gen,
access.fieldQualifierType());
} else {
emitLoadField(gen, access.fieldQualifierType());
}
}
/**
* @aspect InnerClasses
* @declaredat /home/jesper/git/extendj/java4/backend/InnerClasses.jrag:389
*/
protected Access createAccess() {
Access fieldAccess = new BoundFieldAccess(this);
return isStatic() ? fieldAccess : new VarAccess("that").qualifiesAccess(fieldAccess);
}
/**
* @declaredat ASTNode:1
*/
public FieldDeclarator() {
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(), 0);
setChild(new Opt(), 1);
}
/**
* @declaredat ASTNode:15
*/
@ASTNodeAnnotation.Constructor(
name = {"ID", "Dims", "Init"},
type = {"String", "List", "Opt"},
kind = {"Token", "List", "Opt"}
)
public FieldDeclarator(String p0, List p1, Opt p2) {
setID(p0);
setChild(p1, 0);
setChild(p2, 1);
}
/**
* @declaredat ASTNode:25
*/
public FieldDeclarator(beaver.Symbol p0, List p1, Opt p2) {
setID(p0);
setChild(p1, 0);
setChild(p2, 1);
}
/** @apilevel low-level
* @declaredat ASTNode:31
*/
protected int numChildren() {
return 2;
}
/**
* @apilevel internal
* @declaredat ASTNode:37
*/
public boolean mayHaveRewrite() {
return false;
}
/** @apilevel internal
* @declaredat ASTNode:41
*/
public void flushAttrCache() {
super.flushAttrCache();
accessibleFrom_TypeDecl_reset();
constant_reset();
exceptions_reset();
assignedAfter_Variable_reset();
unassignedAfter_Variable_reset();
usesTypeVariable_reset();
flags_reset();
attributes_reset();
}
/** @apilevel internal
* @declaredat ASTNode:53
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:57
*/
public FieldDeclarator clone() throws CloneNotSupportedException {
FieldDeclarator node = (FieldDeclarator) super.clone();
return node;
}
/** @apilevel internal
* @declaredat ASTNode:62
*/
public FieldDeclarator copy() {
try {
FieldDeclarator node = (FieldDeclarator) 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:81
*/
@Deprecated
public FieldDeclarator 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:91
*/
public FieldDeclarator treeCopyNoTransform() {
FieldDeclarator tree = (FieldDeclarator) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
switch (i) {
case 2:
tree.children[i] = null;
continue;
}
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:116
*/
public FieldDeclarator treeCopy() {
FieldDeclarator tree = (FieldDeclarator) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
switch (i) {
case 2:
tree.children[i] = null;
continue;
}
ASTNode child = (ASTNode) getChild(i);
if (child != null) {
child = child.treeCopy();
tree.setChild(child, i);
}
}
}
return tree;
}
/** @apilevel internal
* @declaredat ASTNode:135
*/
protected boolean is$Equal(ASTNode node) {
return super.is$Equal(node) && (tokenString_ID == ((FieldDeclarator) node).tokenString_ID);
}
/**
* Replaces the lexeme ID.
* @param value The new value for the lexeme ID.
* @apilevel high-level
*/
public void setID(String value) {
tokenString_ID = value;
}
/**
* JastAdd-internal setter for lexeme ID using the Beaver parser.
* @param symbol Symbol containing the new value for the lexeme ID
* @apilevel internal
*/
public void setID(beaver.Symbol symbol) {
if (symbol.value != null && !(symbol.value instanceof String))
throw new UnsupportedOperationException("setID is only valid for String lexemes");
tokenString_ID = (String)symbol.value;
IDstart = symbol.getStart();
IDend = symbol.getEnd();
}
/**
* Retrieves the value for the lexeme ID.
* @return The value for the lexeme ID.
* @apilevel high-level
*/
@ASTNodeAnnotation.Token(name="ID")
public String getID() {
return tokenString_ID != null ? tokenString_ID : "";
}
/**
* Replaces the Dims list.
* @param list The new list node to be used as the Dims list.
* @apilevel high-level
*/
public void setDimsList(List list) {
setChild(list, 0);
}
/**
* Retrieves the number of children in the Dims list.
* @return Number of children in the Dims list.
* @apilevel high-level
*/
public int getNumDims() {
return getDimsList().getNumChild();
}
/**
* Retrieves the number of children in the Dims list.
* Calling this method will not trigger rewrites.
* @return Number of children in the Dims list.
* @apilevel low-level
*/
public int getNumDimsNoTransform() {
return getDimsListNoTransform().getNumChildNoTransform();
}
/**
* Retrieves the element at index {@code i} in the Dims list.
* @param i Index of the element to return.
* @return The element at position {@code i} in the Dims list.
* @apilevel high-level
*/
public Dims getDims(int i) {
return (Dims) getDimsList().getChild(i);
}
/**
* Check whether the Dims list has any children.
* @return {@code true} if it has at least one child, {@code false} otherwise.
* @apilevel high-level
*/
public boolean hasDims() {
return getDimsList().getNumChild() != 0;
}
/**
* Append an element to the Dims list.
* @param node The element to append to the Dims list.
* @apilevel high-level
*/
public void addDims(Dims node) {
List list = (parent == null) ? getDimsListNoTransform() : getDimsList();
list.addChild(node);
}
/** @apilevel low-level
*/
public void addDimsNoTransform(Dims node) {
List list = getDimsListNoTransform();
list.addChild(node);
}
/**
* Replaces the Dims 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 setDims(Dims node, int i) {
List list = getDimsList();
list.setChild(node, i);
}
/**
* Retrieves the Dims list.
* @return The node representing the Dims list.
* @apilevel high-level
*/
@ASTNodeAnnotation.ListChild(name="Dims")
public List getDimsList() {
List list = (List) getChild(0);
return list;
}
/**
* Retrieves the Dims list.
* This method does not invoke AST transformations.
* @return The node representing the Dims list.
* @apilevel low-level
*/
public List getDimsListNoTransform() {
return (List) getChildNoTransform(0);
}
/**
* @return the element at index {@code i} in the Dims list without
* triggering rewrites.
*/
public Dims getDimsNoTransform(int i) {
return (Dims) getDimsListNoTransform().getChildNoTransform(i);
}
/**
* Retrieves the Dims list.
* @return The node representing the Dims list.
* @apilevel high-level
*/
public List getDimss() {
return getDimsList();
}
/**
* Retrieves the Dims list.
* This method does not invoke AST transformations.
* @return The node representing the Dims list.
* @apilevel low-level
*/
public List getDimssNoTransform() {
return getDimsListNoTransform();
}
/**
* Replaces the optional node for the Init child. This is the Opt
* node containing the child Init, not the actual child!
* @param opt The new node to be used as the optional node for the Init child.
* @apilevel low-level
*/
public void setInitOpt(Opt opt) {
setChild(opt, 1);
}
/**
* Replaces the (optional) Init child.
* @param node The new node to be used as the Init child.
* @apilevel high-level
*/
public void setInit(Expr node) {
getInitOpt().setChild(node, 0);
}
/**
* Check whether the optional Init child exists.
* @return {@code true} if the optional Init child exists, {@code false} if it does not.
* @apilevel high-level
*/
public boolean hasInit() {
return getInitOpt().getNumChild() != 0;
}
/**
* Retrieves the (optional) Init child.
* @return The Init child, if it exists. Returns {@code null} otherwise.
* @apilevel low-level
*/
public Expr getInit() {
return (Expr) getInitOpt().getChild(0);
}
/**
* Retrieves the optional node for the Init child. This is the Opt
node containing the child Init, not the actual child!
* @return The optional node for child the Init child.
* @apilevel low-level
*/
@ASTNodeAnnotation.OptChild(name="Init")
public Opt getInitOpt() {
return (Opt) getChild(1);
}
/**
* Retrieves the optional node for child Init. This is the Opt
node containing the child Init, not the actual child!
* This method does not invoke AST transformations.
* @return The optional node for child Init.
* @apilevel low-level
*/
public Opt getInitOptNoTransform() {
return (Opt) getChildNoTransform(1);
}
/**
* Retrieves the TypeAccess child.
* This method does not invoke AST transformations.
* @return The current node used as the TypeAccess child.
* @apilevel low-level
*/
public Access getTypeAccessNoTransform() {
return (Access) getChildNoTransform(2);
}
/**
* Retrieves the child position of the optional child TypeAccess.
* @return The the child position of the optional child TypeAccess.
* @apilevel low-level
*/
protected int getTypeAccessChildPosition() {
return 2;
}
/**
* @aspect GenericsCodegen
* @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:110
*/
public void emitLoadVariable(CodeGeneration gen, Access access) {
if (erasedField() != this) {
erasedField().emitLoadVariable(gen, access);
} else {
refined_CreateBCode_FieldDeclarator_emitLoadVariable(gen, access);
}
}
/**
* @aspect Attributes
* @declaredat /home/jesper/git/extendj/java4/backend/Attributes.jrag:276
*/
private Collection refined_Attributes_FieldDeclarator_attributes()
{
Collection attributes = new ArrayList();
if (isFinal() && isConstant() && (type().isPrimitive() || type().isString())) {
attributes.add(new ConstantValueAttribute(hostType().constantPool(), this));
}
return attributes;
}
/**
* @aspect AnnotationsCodegen
* @declaredat /home/jesper/git/extendj/java5/backend/AnnotationsCodegen.jrag:39
*/
private Collection refined_AnnotationsCodegen_FieldDeclarator_attributes()
{
Collection attributes = refined_Attributes_FieldDeclarator_attributes();
getModifiers().addRuntimeVisibleAnnotationsAttribute(attributes);
getModifiers().addRuntimeInvisibleAnnotationsAttribute(attributes);
return attributes;
}
/** @apilevel internal */
private void accessibleFrom_TypeDecl_reset() {
accessibleFrom_TypeDecl_computed = null;
accessibleFrom_TypeDecl_values = null;
}
/** @apilevel internal */
protected java.util.Map accessibleFrom_TypeDecl_values;
/** @apilevel internal */
protected java.util.Map accessibleFrom_TypeDecl_computed;
/**
* @attribute syn
* @aspect AccessControl
* @declaredat /home/jesper/git/extendj/java4/frontend/AccessControl.jrag:138
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="AccessControl", declaredAt="/home/jesper/git/extendj/java4/frontend/AccessControl.jrag:138")
public boolean accessibleFrom(TypeDecl type) {
Object _parameters = type;
if (accessibleFrom_TypeDecl_computed == null) accessibleFrom_TypeDecl_computed = new java.util.HashMap(4);
if (accessibleFrom_TypeDecl_values == null) accessibleFrom_TypeDecl_values = new java.util.HashMap(4);
ASTState state = state();
if (accessibleFrom_TypeDecl_values.containsKey(_parameters)
&& accessibleFrom_TypeDecl_computed.containsKey(_parameters)
&& (accessibleFrom_TypeDecl_computed.get(_parameters) == ASTState.NON_CYCLE || accessibleFrom_TypeDecl_computed.get(_parameters) == state().cycle())) {
return (Boolean) accessibleFrom_TypeDecl_values.get(_parameters);
}
boolean accessibleFrom_TypeDecl_value = accessibleFrom_compute(type);
if (state().inCircle()) {
accessibleFrom_TypeDecl_values.put(_parameters, accessibleFrom_TypeDecl_value);
accessibleFrom_TypeDecl_computed.put(_parameters, state().cycle());
} else {
accessibleFrom_TypeDecl_values.put(_parameters, accessibleFrom_TypeDecl_value);
accessibleFrom_TypeDecl_computed.put(_parameters, ASTState.NON_CYCLE);
}
return accessibleFrom_TypeDecl_value;
}
/** @apilevel internal */
private boolean accessibleFrom_compute(TypeDecl type) {
if (isPublic()) {
return true;
} else if (isProtected()) {
if (hostPackage().equals(type.hostPackage())) {
return true;
}
if (type.withinBodyThatSubclasses(hostType()) != null) {
return true;
}
return false;
} else if (isPrivate()) {
return hostType().topLevelType() == type.topLevelType();
} else {
return hostPackage().equals(type.hostPackage());
}
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:55
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:55")
public boolean isParameter() {
boolean isParameter_value = false;
return isParameter_value;
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:57
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:57")
public boolean isClassVariable() {
boolean isClassVariable_value = isStatic() || hostType().isInterfaceDecl();
return isClassVariable_value;
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:58
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:58")
public boolean isInstanceVariable() {
boolean isInstanceVariable_value = (hostType().isClassDecl() || hostType().isAnonymous()) && !isStatic();
return isInstanceVariable_value;
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:60
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:60")
public boolean isMethodParameter() {
boolean isMethodParameter_value = false;
return isMethodParameter_value;
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:61
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:61")
public boolean isConstructorParameter() {
boolean isConstructorParameter_value = false;
return isConstructorParameter_value;
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:62
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:62")
public boolean isExceptionHandlerParameter() {
boolean isExceptionHandlerParameter_value = false;
return isExceptionHandlerParameter_value;
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:63
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:63")
public boolean isLocalVariable() {
boolean isLocalVariable_value = false;
return isLocalVariable_value;
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:64
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:64")
public boolean isField() {
boolean isField_value = true;
return isField_value;
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:66
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:66")
public boolean isBlank() {
boolean isBlank_value = !hasInit();
return isBlank_value;
}
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:68
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:68")
public String name() {
String name_value = getID();
return name_value;
}
/** @apilevel internal */
private void constant_reset() {
constant_computed = null;
constant_value = null;
}
/** @apilevel internal */
protected ASTState.Cycle constant_computed = null;
/** @apilevel internal */
protected Constant constant_value;
/**
* @attribute syn
* @aspect Variables
* @declaredat /home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:69
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Variables", declaredAt="/home/jesper/git/extendj/java4/frontend/VariableDeclaration.jrag:69")
public Constant constant() {
ASTState state = state();
if (constant_computed == ASTState.NON_CYCLE || constant_computed == state().cycle()) {
return constant_value;
}
constant_value = type().cast(getInit().constant());
if (state().inCircle()) {
constant_computed = state().cycle();
} else {
constant_computed = ASTState.NON_CYCLE;
}
return constant_value;
}
/** @apilevel internal */
private void exceptions_reset() {
exceptions_computed = null;
exceptions_value = null;
}
/** @apilevel internal */
protected ASTState.Cycle exceptions_computed = null;
/** @apilevel internal */
protected Collection exceptions_value;
/**
* Used in bytecode generation to generate the exception list for this field.
* @attribute syn
* @aspect AnonymousClasses
* @declaredat /home/jesper/git/extendj/java4/frontend/AnonymousClasses.jrag:100
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="AnonymousClasses", declaredAt="/home/jesper/git/extendj/java4/frontend/AnonymousClasses.jrag:100")
public Collection exceptions() {
ASTState state = state();
if (exceptions_computed == ASTState.NON_CYCLE || exceptions_computed == state().cycle()) {
return exceptions_value;
}
exceptions_value = exceptions_compute();
if (state().inCircle()) {
exceptions_computed = state().cycle();
} else {
exceptions_computed = ASTState.NON_CYCLE;
}
return exceptions_value;
}
/** @apilevel internal */
private Collection exceptions_compute() {
Collection exceptions = new HashSet();
if (isInstanceVariable() && hasInit()) {
collectExceptions(exceptions);
}
return exceptions;
}
/**
* @attribute syn
* @aspect Modifiers
* @declaredat /home/jesper/git/extendj/java4/frontend/Modifiers.jrag:273
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Modifiers", declaredAt="/home/jesper/git/extendj/java4/frontend/Modifiers.jrag:273")
public boolean isPublic() {
boolean isPublic_value = getModifiers().isPublic() || hostType().isInterfaceDecl();
return isPublic_value;
}
/**
* @attribute syn
* @aspect Modifiers
* @declaredat /home/jesper/git/extendj/java4/frontend/Modifiers.jrag:292
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Modifiers", declaredAt="/home/jesper/git/extendj/java4/frontend/Modifiers.jrag:292")
public boolean isStatic() {
boolean isStatic_value = getModifiers().isStatic() || hostType().isInterfaceDecl();
return isStatic_value;
}
/**
* @attribute syn
* @aspect Modifiers
* @declaredat /home/jesper/git/extendj/java4/frontend/Modifiers.jrag:294
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Modifiers", declaredAt="/home/jesper/git/extendj/java4/frontend/Modifiers.jrag:294")
public boolean isFinal() {
boolean isFinal_value = getModifiers().isFinal() || hostType().isInterfaceDecl();
return isFinal_value;
}
/**
* @attribute syn
* @aspect Modifiers
* @declaredat /home/jesper/git/extendj/java4/frontend/Modifiers.jrag:295
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Modifiers", declaredAt="/home/jesper/git/extendj/java4/frontend/Modifiers.jrag:295")
public boolean isTransient() {
boolean isTransient_value = getModifiers().isTransient();
return isTransient_value;
}
/**
* @attribute syn
* @aspect Modifiers
* @declaredat /home/jesper/git/extendj/java4/frontend/Modifiers.jrag:296
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Modifiers", declaredAt="/home/jesper/git/extendj/java4/frontend/Modifiers.jrag:296")
public boolean isVolatile() {
boolean isVolatile_value = getModifiers().isVolatile();
return isVolatile_value;
}
/**
* @attribute syn
* @aspect DefiniteAssignment
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:197
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:197")
public Collection definiteAssignmentProblems() {
{
Collection problems = new LinkedList();
if (isBlank() && isFinal() && isClassVariable()) {
boolean found = false;
TypeDecl typeDecl = hostType();
for (int i = 0; i < typeDecl.getNumBodyDecl(); i++) {
if (typeDecl.getBodyDecl(i) instanceof StaticInitializer) {
StaticInitializer s = (StaticInitializer) typeDecl.getBodyDecl(i);
if (s.assignedAfter(this)) {
found = true;
}
} else if (typeDecl.getBodyDecl(i) instanceof FieldDecl) {
FieldDecl f = (FieldDecl) typeDecl.getBodyDecl(i);
if (f.isStatic() && f.assignedAfter(this)) {
found = true;
}
}
}
if (!found) {
problems.add(errorf("blank final class variable %s in %s is not definitely assigned "
+ "in static initializer", name(), hostType().typeName()));
}
}
if (isBlank() && isFinal() && isInstanceVariable()) {
TypeDecl typeDecl = hostType();
boolean found = false;
for (int i = 0; !found && i < typeDecl.getNumBodyDecl(); i++) {
if (typeDecl.getBodyDecl(i) instanceof FieldDecl) {
FieldDecl f = (FieldDecl) typeDecl.getBodyDecl(i);
if (!f.isStatic() && f.assignedAfter(this)) {
found = true;
}
} else if (typeDecl.getBodyDecl(i) instanceof InstanceInitializer) {
InstanceInitializer ii = (InstanceInitializer) typeDecl.getBodyDecl(i);
if (ii.getBlock().assignedAfter(this)) {
found = true;
}
}
}
if (!found) {
for (ConstructorDecl cons : typeDecl.constructors()) {
if (!cons.assignedAfter(this)) {
problems.add(errorf(
"blank final instance variable %s in %s is not definitely assigned after %s",
name(), hostType().typeName(), cons.signature()));
}
}
}
}
if (isBlank() && hostType().isInterfaceDecl()) {
problems.add(errorf("variable %s in %s which is an interface must have an initializer",
name(), hostType().typeName()));
}
return problems;
}
}
/** @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:632")
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 = hasInit()
? v == this || getInit().assignedAfter(v)
: assignedBefore(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 = hasInit()
? v == this || getInit().assignedAfter(v)
: assignedBefore(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;
}
}
/** @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:1181")
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 = hasInit()
? v != this && getInit().unassignedAfter(v)
: v == this || unassignedBefore(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 = hasInit()
? v != this && getInit().unassignedAfter(v)
: v == this || unassignedBefore(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;
}
}
/**
* @attribute syn
* @aspect NameCheck
* @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:430
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="NameCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/NameCheck.jrag:430")
public Collection nameProblems() {
{
// 8.3
for (Variable v : hostType().memberFields(name())) {
if (v != this && v.hostType() == hostType()) {
return Collections.singletonList(errorf("field named %s is multiply declared in type %s",
name(), hostType().typeName()));
}
}
return Collections.emptyList();
}
}
/**
* @attribute syn
* @aspect TypeCheck
* @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:51
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="TypeCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:51")
public Collection typeProblems() {
{
if (hasInit()) {
TypeDecl source = getInit().type();
TypeDecl dest = type();
if (!source.assignConversionTo(dest, getInit())
&& !getInit().type().isUnknown()) {
return Collections.singletonList(errorf(
"can not assign field %s of type %s a value of type %s",
name(), dest.typeName(), source.typeName()));
}
}
return Collections.emptyList();
}
}
/** @apilevel internal */
private void usesTypeVariable_reset() {
usesTypeVariable_computed = null;
}
/** @apilevel internal */
protected ASTState.Cycle usesTypeVariable_computed = null;
/** @apilevel internal */
protected boolean usesTypeVariable_value;
/**
* @attribute syn
* @aspect LookupParTypeDecl
* @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1333
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="LookupParTypeDecl", declaredAt="/home/jesper/git/extendj/java5/frontend/Generics.jrag:1333")
public boolean usesTypeVariable() {
ASTState state = state();
if (usesTypeVariable_computed == ASTState.NON_CYCLE || usesTypeVariable_computed == state().cycle()) {
return usesTypeVariable_value;
}
usesTypeVariable_value = getTypeAccess().usesTypeVariable();
if (state().inCircle()) {
usesTypeVariable_computed = state().cycle();
} else {
usesTypeVariable_computed = ASTState.NON_CYCLE;
}
return usesTypeVariable_value;
}
/** @apilevel internal */
private void flags_reset() {
flags_computed = null;
}
/** @apilevel internal */
protected ASTState.Cycle flags_computed = null;
/** @apilevel internal */
protected int flags_value;
/**
* @attribute syn
* @aspect Flags
* @declaredat /home/jesper/git/extendj/java4/backend/Flags.jrag:138
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Flags", declaredAt="/home/jesper/git/extendj/java4/backend/Flags.jrag:138")
public int flags() {
ASTState state = state();
if (flags_computed == ASTState.NON_CYCLE || flags_computed == state().cycle()) {
return flags_value;
}
flags_value = flags_compute();
if (state().inCircle()) {
flags_computed = state().cycle();
} else {
flags_computed = ASTState.NON_CYCLE;
}
return flags_value;
}
/** @apilevel internal */
private int flags_compute() {
int res = 0;
if (isPublic()) {
res |= Modifiers.ACC_PUBLIC;
}
if (isPrivate()) {
res |= Modifiers.ACC_PRIVATE;
}
if (isProtected()) {
res |= Modifiers.ACC_PROTECTED;
}
if (isStatic()) {
res |= Modifiers.ACC_STATIC;
}
if (isFinal()) {
res |= Modifiers.ACC_FINAL;
}
if (isVolatile()) {
res |= Modifiers.ACC_VOLATILE;
}
if (isTransient()) {
res |= Modifiers.ACC_TRANSIENT;
}
if (isSynthetic()) {
res |= Modifiers.ACC_SYNTHETIC;
}
return res;
}
/** @apilevel internal */
private void attributes_reset() {
attributes_computed = null;
attributes_value = null;
}
/** @apilevel internal */
protected ASTState.Cycle attributes_computed = null;
/** @apilevel internal */
protected Collection attributes_value;
/**
* @attribute syn
* @aspect Attributes
* @declaredat /home/jesper/git/extendj/java4/backend/Attributes.jrag:276
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Attributes", declaredAt="/home/jesper/git/extendj/java4/backend/Attributes.jrag:276")
public Collection attributes() {
ASTState state = state();
if (attributes_computed == ASTState.NON_CYCLE || attributes_computed == state().cycle()) {
return attributes_value;
}
attributes_value = attributes_compute();
if (state().inCircle()) {
attributes_computed = state().cycle();
} else {
attributes_computed = ASTState.NON_CYCLE;
}
return attributes_value;
}
/** @apilevel internal */
private Collection attributes_compute() {
Collection attributes = refined_AnnotationsCodegen_FieldDeclarator_attributes();
if (needsSignatureAttribute()) {
attributes.add(new SignatureAttribute(hostType().constantPool(),
type().fieldTypeSignature()));
}
return attributes;
}
/**
* @attribute syn
* @aspect GenericsCodegen
* @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:157
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="GenericsCodegen", declaredAt="/home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:157")
public TypeDecl erasedType() {
TypeDecl erasedType_value = erasedField().type();
return erasedType_value;
}
/**
* @attribute syn
* @aspect GenericsCodegen
* @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:462
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="GenericsCodegen", declaredAt="/home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:462")
public boolean needsSignatureAttribute() {
boolean needsSignatureAttribute_value = type().needsSignatureAttribute();
return needsSignatureAttribute_value;
}
/**
* @attribute inh
* @aspect LookupParTypeDecl
* @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1659
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.INH)
@ASTNodeAnnotation.Source(aspect="LookupParTypeDecl", declaredAt="/home/jesper/git/extendj/java5/frontend/Generics.jrag:1659")
public FieldDeclarator erasedField() {
FieldDeclarator erasedField_value = getParent().Define_erasedField(this, null);
return erasedField_value;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:256
* @apilevel internal
*/
public boolean Define_assignedBefore(ASTNode _callerNode, ASTNode _childNode, Variable v) {
if (_callerNode == getInitOptNoTransform()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:368
return assignedBefore(v);
}
else {
return super.Define_assignedBefore(_callerNode, _childNode, 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;
}
/** @apilevel internal */
public ASTNode rewriteTo() {
return super.rewriteTo();
}
/** @apilevel internal */
public boolean canRewrite() {
return false;
}
/** @apilevel internal */
protected void collect_contributors_CompilationUnit_problems(CompilationUnit _root, java.util.Map> _map) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:195
{
java.util.Set contributors = _map.get(_root);
if (contributors == null) {
contributors = new java.util.LinkedHashSet();
_map.put((ASTNode) _root, contributors);
}
contributors.add(this);
}
// @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:428
{
java.util.Set contributors = _map.get(_root);
if (contributors == null) {
contributors = new java.util.LinkedHashSet();
_map.put((ASTNode) _root, contributors);
}
contributors.add(this);
}
// @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:49
{
java.util.Set contributors = _map.get(_root);
if (contributors == null) {
contributors = new java.util.LinkedHashSet();
_map.put((ASTNode) _root, contributors);
}
contributors.add(this);
}
super.collect_contributors_CompilationUnit_problems(_root, _map);
}
/** @apilevel internal */
protected void contributeTo_CompilationUnit_problems(LinkedList collection) {
super.contributeTo_CompilationUnit_problems(collection);
for (Problem value : definiteAssignmentProblems()) {
collection.add(value);
}
for (Problem value : nameProblems()) {
collection.add(value);
}
for (Problem value : typeProblems()) {
collection.add(value);
}
}
}