Skip to content
Snippets Groups Projects
Unverified Commit 5c265881 authored by wangyingjian's avatar wangyingjian Committed by GitHub
Browse files

Add files via upload

parents
Branches main
No related tags found
No related merge requests found
Showing
with 494 additions and 0 deletions
/* This file was generated with JastAdd2 (http://jastadd.org) version 2.3.5 */
package org.jastadd.ag.ast;
import java.util.*;
/**
* @ast node
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\ag.ast:4
* @astdecl Atom : Connective ::= Relation;
* @production Atom : {@link Connective} ::= <span class="component">{@link Relation}</span>;
*/
public class Atom extends Connective implements Cloneable {
/**
* @aspect ReferenceCreation
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:39
*/
public static Atom createRef(String ref) {
Unresolved$Atom unresolvedNode = new Unresolved$Atom();
unresolvedNode.setUnresolved$Token(ref);
unresolvedNode.setUnresolved$ResolveOpposite(true);
return unresolvedNode;
}
/**
* @aspect ReferenceCreation
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:45
*/
public static Atom createRefDirection(String ref) {
Unresolved$Atom unresolvedNode = new Unresolved$Atom();
unresolvedNode.setUnresolved$Token(ref);
unresolvedNode.setUnresolved$ResolveOpposite(false);
return unresolvedNode;
}
/**
* @aspect ResolverTrigger
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:312
*/
public void resolveAll() {
super.resolveAll();
}
/**
* @aspect RefResolverHelpers
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:503
*/
Unresolved$Node$Interface as$Unresolved() {
return null;
}
/**
* @aspect RefResolverHelpers
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:509
*/
boolean is$Unresolved() {
return false;
}
/**
* @declaredat ASTNode:1
*/
public Atom() {
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]; getChild_handler = new ASTNode$DepGraphNode[children.length];
state().enterConstruction();
state().exitConstruction();
}
/**
* @declaredat ASTNode:15
*/
@ASTNodeAnnotation.Constructor(
name = {"Relation"},
type = {"Relation"},
kind = {"Child"}
)
public Atom(Relation p0) {
state().enterConstruction();
setChild(p0, 0);
state().exitConstruction();
}
/** @apilevel low-level
* @declaredat ASTNode:26
*/
protected int numChildren() {
state().addHandlerDepTo(numChildren_handler);
return 1;
}
/**
* @apilevel internal
* @declaredat ASTNode:34
*/
public boolean mayHaveRewrite() {
return false;
}
/** @apilevel internal
* @declaredat ASTNode:38
*/
public void flushAttrCache() {
}
/** @apilevel internal
* @declaredat ASTNode:41
*/
public void flushCollectionCache() {
}
/** @apilevel internal
* @declaredat ASTNode:44
*/
public Atom clone() throws CloneNotSupportedException {
Atom node = (Atom) super.clone();
return node;
}
/** @apilevel internal
* @declaredat ASTNode:49
*/
public Atom copy() {
try {
Atom node = (Atom) clone();
node.parent = null;
if (children != null) {
node.children = (ASTNode[]) children.clone();
}
node.inc_state = inc_CLONED;
for (int i = 0; node.children != null && i < node.children.length; i++) {
node.children[i] = null;
}
inc_copyHandlers(node);
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:73
*/
@Deprecated
public Atom 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:83
*/
public Atom treeCopyNoTransform() {
Atom tree = (Atom) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
ASTNode child = (ASTNode) children[i];
if (child != null) {
child = child.treeCopyNoTransform();
tree.children[i] = child;
child.parent = tree;
}
}
}
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:104
*/
public Atom treeCopy() {
Atom tree = (Atom) copy();
if (children != null) {
for (int i = 0; i < children.length; ++i) {
ASTNode child = (ASTNode) getChild(i);
if (child != null) {
child = child.treeCopy();
tree.children[i] = child;
child.parent = tree;
}
}
}
return tree;
}
/** @apilevel internal
* @declaredat ASTNode:119
*/
protected boolean childIsNTA(int index) {
return super.childIsNTA(index);
}
/**
* @declaredat ASTNode:122
*/
protected ASTNode$DepGraphNode eval_handler;
/**
* @declaredat ASTNode:123
*/
protected void inc_copyHandlers(Atom copy) {
super.inc_copyHandlers(copy);
if (eval_handler != null) {
copy.eval_handler = ASTNode$DepGraphNode.createAttrHandler(eval_handler, copy);
}
}
/** @apilevel internal
* @declaredat ASTNode:132
*/
public void reactToDependencyChange(String attrID, Object _parameters) {
super.reactToDependencyChange(attrID, _parameters);
}
/**
* @declaredat ASTNode:139
*/
private boolean inc_throwAway_visited = false;
/** @apilevel internal
* @declaredat ASTNode:141
*/
public void inc_throwAway() {
if (inc_throwAway_visited) {
return;
}
inc_throwAway_visited = true;
inc_state = inc_GARBAGE;
super.inc_throwAway();
if (eval_handler != null) {
eval_handler.throwAway();
}
inc_throwAway_visited = false;
}
/**
* @declaredat ASTNode:153
*/
private boolean inc_cleanupListeners_visited = false;
/**
* @declaredat ASTNode:154
*/
public void cleanupListeners() {
if (inc_cleanupListeners_visited) {
return;
}
inc_cleanupListeners_visited = true;
if (eval_handler != null) {
eval_handler.cleanupListeners();
}
super.cleanupListeners();
inc_cleanupListeners_visited = false;
}
/**
* @declaredat ASTNode:165
*/
private boolean inc_cleanupListenersInTree_visited = false;
/**
* @declaredat ASTNode:166
*/
public void cleanupListenersInTree() {
if (inc_cleanupListenersInTree_visited) {
return;
}
inc_cleanupListenersInTree_visited = true;
cleanupListeners();
for (int i = 0; children != null && i < children.length; i++) {
ASTNode child = children[i];
if (child == null) {
continue;
}
child.cleanupListenersInTree();
}
inc_cleanupListenersInTree_visited = false;
}
/**
* Replaces the Relation child.
* @param node The new node to replace the Relation child.
* @apilevel high-level
*/
public Atom setRelation(Relation node) {
setChild(node, 0);
return this;
}
/**
* Retrieves the Relation child.
* @return The current node used as the Relation child.
* @apilevel high-level
*/
@ASTNodeAnnotation.Child(name="Relation")
public Relation getRelation() {
return (Relation) getChild(0);
}
/**
* Retrieves the Relation child.
* <p><em>This method does not invoke AST transformations.</em></p>
* @return The current node used as the Relation child.
* @apilevel low-level
*/
public Relation getRelationNoTransform() {
return (Relation) getChildNoTransform(0);
}
/** @apilevel internal */
private void eval_reset() {
state().trace().flushAttr(this, "Connective.eval()", "", eval_value);
eval_computed = null;
}
/** @apilevel internal */
protected ASTState.Cycle eval_computed = null;
/** @apilevel internal */
protected boolean eval_value;
/**
* @attribute syn
* @aspect Connectives
* @declaredat E:\\project\\20211201\\src\\main\\jastadd\\hanoi\\Constraints.jrag:14
*/
@ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
@ASTNodeAnnotation.Source(aspect="Connectives", declaredAt="E:\\project\\20211201\\src\\main\\jastadd\\hanoi\\Constraints.jrag:3")
public boolean eval() {
ASTState state = state();
if (eval_handler == null) {
eval_handler = new ASTNode$DepGraphNode(this, "eval", null, ASTNode.inc_EMPTY) {
@Override public void reactToDependencyChange() {
{
eval_computed = null;
eval_handler.notifyDependencies();
Atom.this.state().trace().flushIncAttr(Atom.this, "eval", "", "");
}
}
};
}
state().addHandlerDepTo(eval_handler);
if (eval_computed == ASTState.NON_CYCLE || eval_computed == state().cycle()) {
state().trace().cacheRead(this, "Connective.eval()", "", eval_value);
return eval_value;
}
state().enterAttrStoreEval(eval_handler);
eval_value = eval_compute();
if (state().inCircle()) {
eval_computed = state().cycle();
state().trace().cacheWrite(this, "Connective.eval()", "", eval_value);
} else {
eval_computed = ASTState.NON_CYCLE;
state().trace().cacheWrite(this, "Connective.eval()", "", eval_value);
}
state().exitAttrStoreEval(eval_handler);
return eval_value;
}
/** @apilevel internal */
private boolean eval_compute() {
return this.getRelation().eval();
}
/** @apilevel internal */
public ASTNode rewriteTo() {
return super.rewriteTo();
}
/** @apilevel internal */
public boolean canRewrite() {
return false;
}
}
package org.jastadd.ag.ast;
import java.util.*;
/** Wrapper class for storing nullable attribute values.
* @ast class
* @declaredat ASTState:2
*/
public class AttributeValue<T> extends java.lang.Object {
/**
* This singleton object is an illegal, unused, attribute value.
* It represents that an attribute has not been memoized, or that
* a circular attribute approximation has not been initialized.
* @declaredat ASTState:8
*/
/**
* This singleton object is an illegal, unused, attribute value.
* It represents that an attribute has not been memoized, or that
* a circular attribute approximation has not been initialized.
*/
public static final Object NONE = new Object();
/**
* @declaredat ASTState:10
*/
public final T value;
/**
* @declaredat ASTState:12
*/
public AttributeValue(T value) {
this.value = value;
}
/**
* @declaredat ASTState:16
*/
public static <V> boolean equals(AttributeValue<V> v1, AttributeValue<V> v2) {
if (v1 == null || v2 == null) {
return v1 == v2;
} else {
return equals(v1.value, v2.value);
}
}
/**
* @declaredat ASTState:24
*/
public static <V> boolean equals(V v1, V v2) {
if (v1 == null || v2 == null) {
return v1 == v2;
} else {
return v1 == v2 || v1.equals(v2);
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package org.jastadd.ag.ast;
import java.util.*;
/**
* @ast class
* @aspect RelAstAPI
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\ag.jadd:87
*/
public class Pair<T1, T2> extends java.lang.Object {
/**
* @aspect RelAstAPI
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\ag.jadd:88
*/
public final T1 _1;
/**
* @aspect RelAstAPI
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\ag.jadd:89
*/
public final T2 _2;
/**
* @aspect RelAstAPI
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\ag.jadd:90
*/
public Pair(T1 _1, T2 _2) {
ASTNode.assertNotNull(_1);
ASTNode.assertNotNull(_2);
this._1 = _1;
this._2 = _2;
}
/**
* @aspect RelAstAPI
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\ag.jadd:96
*/
public boolean equals(Object other) {
if (other instanceof Pair) {
Pair<?,?> p = (Pair<?,?>) other;
return _1.equals(p._1) && _2.equals(p._2);
} else {
return false;
}
}
/**
* @aspect RelAstAPI
* @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\ag.jadd:104
*/
public int hashCode() {
return 31*_1.hashCode() + _2.hashCode();
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment