org.extendj.ast.PostfixExpr 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/java4/grammar/Java.ast:263
* @astdecl PostfixExpr : Unary;
* @production PostfixExpr : {@link Unary};
*/
public abstract class PostfixExpr extends Unary implements Cloneable {
/**
* @aspect DefiniteAssignment
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:597
*/
protected boolean checkDUeverywhere(Variable v) {
if (getOperand().isVariable() && getOperand().varDecl() == v) {
if (!assignedBefore(v)) {
return false;
}
}
return super.checkDUeverywhere(v);
}
/**
* @declaredat ASTNode:1
*/
public PostfixExpr() {
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 = {"Operand"},
type = {"Expr"},
kind = {"Child"}
)
public PostfixExpr(Expr 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();
}
/** @apilevel internal
* @declaredat ASTNode:36
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:40
*/
public PostfixExpr clone() throws CloneNotSupportedException {
PostfixExpr node = (PostfixExpr) 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:51
*/
@Deprecated
public abstract PostfixExpr 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:59
*/
public abstract PostfixExpr 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:67
*/
public abstract PostfixExpr treeCopy();
/**
* Replaces the Operand child.
* @param node The new node to replace the Operand child.
* @apilevel high-level
*/
public void setOperand(Expr node) {
setChild(node, 0);
}
/**
* Retrieves the Operand child.
* @return The current node used as the Operand child.
* @apilevel high-level
*/
@ASTNodeAnnotation.Child(name="Operand")
public Expr getOperand() {
return (Expr) getChild(0);
}
/**
* Retrieves the Operand child.
* This method does not invoke AST transformations.
* @return The current node used as the Operand child.
* @apilevel low-level
*/
public Expr getOperandNoTransform() {
return (Expr) getChildNoTransform(0);
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36
* @apilevel internal
*/
public NameType Define_nameType(ASTNode _callerNode, ASTNode _childNode) {
if (getOperandNoTransform() != null && _callerNode == getOperand()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:121
return NameType.EXPRESSION_NAME;
}
else {
return getParent().Define_nameType(this, _callerNode);
}
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:36
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute nameType
*/
protected boolean canDefine_nameType(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:34
* @apilevel internal
*/
public boolean Define_isDest(ASTNode _callerNode, ASTNode _childNode) {
if (getOperandNoTransform() != null && _callerNode == getOperand()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:62
return true;
}
else {
return getParent().Define_isDest(this, _callerNode);
}
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:34
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute isDest
*/
protected boolean canDefine_isDest(ASTNode _callerNode, ASTNode _childNode) {
return true;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:66
* @apilevel internal
*/
public boolean Define_isIncOrDec(ASTNode _callerNode, ASTNode _childNode) {
if (getOperandNoTransform() != null && _callerNode == getOperand()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:72
return true;
}
else {
return getParent().Define_isIncOrDec(this, _callerNode);
}
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:66
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute isIncOrDec
*/
protected boolean canDefine_isIncOrDec(ASTNode _callerNode, ASTNode _childNode) {
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:82
if (getOperand().isVariable()
&& getOperand().varDecl() != null
&& getOperand().varDecl().isFinal()) {
{
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:404
if (!getOperand().isVariable()) {
{
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:409
if (!getOperand().type().isNumericType()) {
{
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);
if (getOperand().isVariable()
&& getOperand().varDecl() != null
&& getOperand().varDecl().isFinal()) {
collection.add(error("++ and -- can not be applied to final variable " + getOperand().varDecl().name()));
}
if (!getOperand().isVariable()) {
collection.add(error("postfix expression only works on variables"));
}
if (!getOperand().type().isNumericType()) {
collection.add(error("postfix expression only operates on numeric types"));
}
}
}