org.extendj.ast.AndLogicalExpr 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;
/**
* @ast node
* @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:262
* @astdecl AndLogicalExpr : LogicalExpr;
* @production AndLogicalExpr : {@link LogicalExpr};
*/
public class AndLogicalExpr extends LogicalExpr implements Cloneable {
/**
* @aspect CreateBCode
* @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1258
*/
public void branchTrue(CodeGeneration gen, int target) {
// Branch when true.
Expr left = getLeftOperand();
Expr right = getRightOperand();
int skip_lbl = -1;
if (!left.isConstant()) {
skip_lbl = gen.constantPool().newLabel();
left.branchFalse(gen, skip_lbl);
}
if (left.canBeTrue()) {
right.branchTrue(gen, target);
}
if (skip_lbl != -1) {
gen.addLabel(skip_lbl);
}
}
/**
* @aspect CreateBCode
* @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1369
*/
public void branchFalse(CodeGeneration gen, int target) {
// branch when false
Expr left = getLeftOperand();
Expr right = getRightOperand();
if (!left.isTrue()) {
left.branchFalse(gen, target);
}
if (left.canBeTrue()) {
right.branchFalse(gen, target);
}
}
/**
* @declaredat ASTNode:1
*/
public AndLogicalExpr() {
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[2];
}
/**
* @declaredat ASTNode:13
*/
@ASTNodeAnnotation.Constructor(
name = {"LeftOperand", "RightOperand"},
type = {"Expr", "Expr"},
kind = {"Child", "Child"}
)
public AndLogicalExpr(Expr p0, Expr p1) {
setChild(p0, 0);
setChild(p1, 1);
}
/** @apilevel low-level
* @declaredat ASTNode:23
*/
protected int numChildren() {
return 2;
}
/**
* @apilevel internal
* @declaredat ASTNode:29
*/
public boolean mayHaveRewrite() {
return false;
}
/** @apilevel internal
* @declaredat ASTNode:33
*/
public void flushAttrCache() {
super.flushAttrCache();
assignedAfterTrue_Variable_reset();
assignedAfterFalse_Variable_reset();
unassignedAfterTrue_Variable_reset();
unassignedAfterFalse_Variable_reset();
unassignedAfter_Variable_reset();
}
/** @apilevel internal
* @declaredat ASTNode:42
*/
public void flushCollectionCache() {
super.flushCollectionCache();
}
/** @apilevel internal
* @declaredat ASTNode:46
*/
public AndLogicalExpr clone() throws CloneNotSupportedException {
AndLogicalExpr node = (AndLogicalExpr) super.clone();
return node;
}
/** @apilevel internal
* @declaredat ASTNode:51
*/
public AndLogicalExpr copy() {
try {
AndLogicalExpr node = (AndLogicalExpr) 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:70
*/
@Deprecated
public AndLogicalExpr 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:80
*/
public AndLogicalExpr treeCopyNoTransform() {
AndLogicalExpr tree = (AndLogicalExpr) 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:100
*/
public AndLogicalExpr treeCopy() {
AndLogicalExpr tree = (AndLogicalExpr) 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:114
*/
protected boolean is$Equal(ASTNode node) {
return super.is$Equal(node);
}
/**
* Replaces the LeftOperand child.
* @param node The new node to replace the LeftOperand child.
* @apilevel high-level
*/
public void setLeftOperand(Expr node) {
setChild(node, 0);
}
/**
* Retrieves the LeftOperand child.
* @return The current node used as the LeftOperand child.
* @apilevel high-level
*/
@ASTNodeAnnotation.Child(name="LeftOperand")
public Expr getLeftOperand() {
return (Expr) getChild(0);
}
/**
* Retrieves the LeftOperand child.
* This method does not invoke AST transformations.
* @return The current node used as the LeftOperand child.
* @apilevel low-level
*/
public Expr getLeftOperandNoTransform() {
return (Expr) getChildNoTransform(0);
}
/**
* Replaces the RightOperand child.
* @param node The new node to replace the RightOperand child.
* @apilevel high-level
*/
public void setRightOperand(Expr node) {
setChild(node, 1);
}
/**
* Retrieves the RightOperand child.
* @return The current node used as the RightOperand child.
* @apilevel high-level
*/
@ASTNodeAnnotation.Child(name="RightOperand")
public Expr getRightOperand() {
return (Expr) getChild(1);
}
/**
* Retrieves the RightOperand child.
* This method does not invoke AST transformations.
* @return The current node used as the RightOperand child.
* @apilevel low-level
*/
public Expr getRightOperandNoTransform() {
return (Expr) getChildNoTransform(1);
}
/** The operator string used for pretty printing this expression.
* @attribute syn
* @aspect PrettyPrintUtil
* @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:277
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="PrettyPrintUtil", declaredAt="/home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:277")
public String printOp() {
String printOp_value = "&&";
return printOp_value;
}
/**
* @attribute syn
* @aspect ConstantExpression
* @declaredat /home/jesper/git/extendj/java4/frontend/ConstantExpression.jrag:32
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="ConstantExpression", declaredAt="/home/jesper/git/extendj/java4/frontend/ConstantExpression.jrag:32")
public Constant constant() {
Constant constant_value = Constant.create(left().constant().booleanValue() && right().constant().booleanValue());
return constant_value;
}
/** @apilevel internal */
private void assignedAfterTrue_Variable_reset() {
assignedAfterTrue_Variable_values = null;
}
protected java.util.Map assignedAfterTrue_Variable_values;
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true)
@ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:488")
public boolean assignedAfterTrue(Variable v) {
Object _parameters = v;
if (assignedAfterTrue_Variable_values == null) assignedAfterTrue_Variable_values = new java.util.HashMap(4);
ASTState.CircularValue _value;
if (assignedAfterTrue_Variable_values.containsKey(_parameters)) {
Object _cache = assignedAfterTrue_Variable_values.get(_parameters);
if (!(_cache instanceof ASTState.CircularValue)) {
return (Boolean) _cache;
} else {
_value = (ASTState.CircularValue) _cache;
}
} else {
_value = new ASTState.CircularValue();
assignedAfterTrue_Variable_values.put(_parameters, _value);
_value.value = true;
}
ASTState state = state();
if (!state.inCircle() || state.calledByLazyAttribute()) {
state.enterCircle();
boolean new_assignedAfterTrue_Variable_value;
do {
_value.cycle = state.nextCycle();
new_assignedAfterTrue_Variable_value = isFalse() || getRightOperand().assignedAfterTrue(v);
if (((Boolean)_value.value) != new_assignedAfterTrue_Variable_value) {
state.setChangeInCycle();
_value.value = new_assignedAfterTrue_Variable_value;
}
} while (state.testAndClearChangeInCycle());
assignedAfterTrue_Variable_values.put(_parameters, new_assignedAfterTrue_Variable_value);
state.leaveCircle();
return new_assignedAfterTrue_Variable_value;
} else if (_value.cycle != state.cycle()) {
_value.cycle = state.cycle();
boolean new_assignedAfterTrue_Variable_value = isFalse() || getRightOperand().assignedAfterTrue(v);
if (((Boolean)_value.value) != new_assignedAfterTrue_Variable_value) {
state.setChangeInCycle();
_value.value = new_assignedAfterTrue_Variable_value;
}
return new_assignedAfterTrue_Variable_value;
} else {
return (Boolean) _value.value;
}
}
/** @apilevel internal */
private void assignedAfterFalse_Variable_reset() {
assignedAfterFalse_Variable_values = null;
}
protected java.util.Map assignedAfterFalse_Variable_values;
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true)
@ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:491")
public boolean assignedAfterFalse(Variable v) {
Object _parameters = v;
if (assignedAfterFalse_Variable_values == null) assignedAfterFalse_Variable_values = new java.util.HashMap(4);
ASTState.CircularValue _value;
if (assignedAfterFalse_Variable_values.containsKey(_parameters)) {
Object _cache = assignedAfterFalse_Variable_values.get(_parameters);
if (!(_cache instanceof ASTState.CircularValue)) {
return (Boolean) _cache;
} else {
_value = (ASTState.CircularValue) _cache;
}
} else {
_value = new ASTState.CircularValue();
assignedAfterFalse_Variable_values.put(_parameters, _value);
_value.value = true;
}
ASTState state = state();
if (!state.inCircle() || state.calledByLazyAttribute()) {
state.enterCircle();
boolean new_assignedAfterFalse_Variable_value;
do {
_value.cycle = state.nextCycle();
new_assignedAfterFalse_Variable_value = isTrue()
|| (getLeftOperand().assignedAfterFalse(v) && getRightOperand().assignedAfterFalse(v));
if (((Boolean)_value.value) != new_assignedAfterFalse_Variable_value) {
state.setChangeInCycle();
_value.value = new_assignedAfterFalse_Variable_value;
}
} while (state.testAndClearChangeInCycle());
assignedAfterFalse_Variable_values.put(_parameters, new_assignedAfterFalse_Variable_value);
state.leaveCircle();
return new_assignedAfterFalse_Variable_value;
} else if (_value.cycle != state.cycle()) {
_value.cycle = state.cycle();
boolean new_assignedAfterFalse_Variable_value = isTrue()
|| (getLeftOperand().assignedAfterFalse(v) && getRightOperand().assignedAfterFalse(v));
if (((Boolean)_value.value) != new_assignedAfterFalse_Variable_value) {
state.setChangeInCycle();
_value.value = new_assignedAfterFalse_Variable_value;
}
return new_assignedAfterFalse_Variable_value;
} else {
return (Boolean) _value.value;
}
}
/**
* @attribute syn
* @aspect DefiniteAssignment
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:268
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:268")
public boolean assignedAfter(Variable v) {
boolean assignedAfter_Variable_value = assignedAfterTrue(v) && assignedAfterFalse(v);
return assignedAfter_Variable_value;
}
/** @apilevel internal */
private void unassignedAfterTrue_Variable_reset() {
unassignedAfterTrue_Variable_values = null;
}
protected java.util.Map unassignedAfterTrue_Variable_values;
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true)
@ASTNodeAnnotation.Source(aspect="DefiniteUnassignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:905")
public boolean unassignedAfterTrue(Variable v) {
Object _parameters = v;
if (unassignedAfterTrue_Variable_values == null) unassignedAfterTrue_Variable_values = new java.util.HashMap(4);
ASTState.CircularValue _value;
if (unassignedAfterTrue_Variable_values.containsKey(_parameters)) {
Object _cache = unassignedAfterTrue_Variable_values.get(_parameters);
if (!(_cache instanceof ASTState.CircularValue)) {
return (Boolean) _cache;
} else {
_value = (ASTState.CircularValue) _cache;
}
} else {
_value = new ASTState.CircularValue();
unassignedAfterTrue_Variable_values.put(_parameters, _value);
_value.value = true;
}
ASTState state = state();
if (!state.inCircle() || state.calledByLazyAttribute()) {
state.enterCircle();
boolean new_unassignedAfterTrue_Variable_value;
do {
_value.cycle = state.nextCycle();
new_unassignedAfterTrue_Variable_value = getRightOperand().unassignedAfterTrue(v);
if (((Boolean)_value.value) != new_unassignedAfterTrue_Variable_value) {
state.setChangeInCycle();
_value.value = new_unassignedAfterTrue_Variable_value;
}
} while (state.testAndClearChangeInCycle());
unassignedAfterTrue_Variable_values.put(_parameters, new_unassignedAfterTrue_Variable_value);
state.leaveCircle();
return new_unassignedAfterTrue_Variable_value;
} else if (_value.cycle != state.cycle()) {
_value.cycle = state.cycle();
boolean new_unassignedAfterTrue_Variable_value = getRightOperand().unassignedAfterTrue(v);
if (((Boolean)_value.value) != new_unassignedAfterTrue_Variable_value) {
state.setChangeInCycle();
_value.value = new_unassignedAfterTrue_Variable_value;
}
return new_unassignedAfterTrue_Variable_value;
} else {
return (Boolean) _value.value;
}
}
/** @apilevel internal */
private void unassignedAfterFalse_Variable_reset() {
unassignedAfterFalse_Variable_values = null;
}
protected java.util.Map unassignedAfterFalse_Variable_values;
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true)
@ASTNodeAnnotation.Source(aspect="DefiniteUnassignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:907")
public boolean unassignedAfterFalse(Variable v) {
Object _parameters = v;
if (unassignedAfterFalse_Variable_values == null) unassignedAfterFalse_Variable_values = new java.util.HashMap(4);
ASTState.CircularValue _value;
if (unassignedAfterFalse_Variable_values.containsKey(_parameters)) {
Object _cache = unassignedAfterFalse_Variable_values.get(_parameters);
if (!(_cache instanceof ASTState.CircularValue)) {
return (Boolean) _cache;
} else {
_value = (ASTState.CircularValue) _cache;
}
} else {
_value = new ASTState.CircularValue();
unassignedAfterFalse_Variable_values.put(_parameters, _value);
_value.value = true;
}
ASTState state = state();
if (!state.inCircle() || state.calledByLazyAttribute()) {
state.enterCircle();
boolean new_unassignedAfterFalse_Variable_value;
do {
_value.cycle = state.nextCycle();
new_unassignedAfterFalse_Variable_value = getLeftOperand().unassignedAfterFalse(v) && getRightOperand().unassignedAfterFalse(v);
if (((Boolean)_value.value) != new_unassignedAfterFalse_Variable_value) {
state.setChangeInCycle();
_value.value = new_unassignedAfterFalse_Variable_value;
}
} while (state.testAndClearChangeInCycle());
unassignedAfterFalse_Variable_values.put(_parameters, new_unassignedAfterFalse_Variable_value);
state.leaveCircle();
return new_unassignedAfterFalse_Variable_value;
} else if (_value.cycle != state.cycle()) {
_value.cycle = state.cycle();
boolean new_unassignedAfterFalse_Variable_value = getLeftOperand().unassignedAfterFalse(v) && getRightOperand().unassignedAfterFalse(v);
if (((Boolean)_value.value) != new_unassignedAfterFalse_Variable_value) {
state.setChangeInCycle();
_value.value = new_unassignedAfterFalse_Variable_value;
}
return new_unassignedAfterFalse_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:899")
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 = unassignedAfterTrue(v) && unassignedAfterFalse(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 = unassignedAfterTrue(v) && unassignedAfterFalse(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 CreateBCode
* @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1144
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="CreateBCode", declaredAt="/home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1144")
public boolean canBeTrue() {
boolean canBeTrue_value = getLeftOperand().canBeTrue() && getRightOperand().canBeTrue();
return canBeTrue_value;
}
/**
* @attribute syn
* @aspect CreateBCode
* @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1156
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="CreateBCode", declaredAt="/home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1156")
public boolean canBeFalse() {
boolean canBeFalse_value = getLeftOperand().canBeFalse() || getRightOperand().canBeFalse();
return canBeFalse_value;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:256
* @apilevel internal
*/
public boolean Define_assignedBefore(ASTNode _callerNode, ASTNode _childNode, Variable v) {
if (getRightOperandNoTransform() != null && _callerNode == getRightOperand()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:425
return getLeftOperand().assignedAfterTrue(v);
}
else if (getLeftOperandNoTransform() != null && _callerNode == getLeftOperand()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:422
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;
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:887
* @apilevel internal
*/
public boolean Define_unassignedBefore(ASTNode _callerNode, ASTNode _childNode, Variable v) {
if (getRightOperandNoTransform() != null && _callerNode == getRightOperand()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1023
return getLeftOperand().unassignedAfterTrue(v);
}
else if (getLeftOperandNoTransform() != null && _callerNode == getLeftOperand()) {
// @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:1021
return unassignedBefore(v);
}
else {
return super.Define_unassignedBefore(_callerNode, _childNode, v);
}
}
/**
* @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:887
* @apilevel internal
* @return {@code true} if this node has an equation for the inherited attribute unassignedBefore
*/
protected boolean canDefine_unassignedBefore(ASTNode _callerNode, ASTNode _childNode, Variable v) {
return true;
}
/** @apilevel internal */
public ASTNode rewriteTo() {
return super.rewriteTo();
}
/** @apilevel internal */
public boolean canRewrite() {
return false;
}
}