Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
# Copyright (c) 2013-2016, The JastAdd Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the Lund University nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
ASTState = [[
/** Wrapper class for storing nullable attribute values. */
public class AttributeValue {
/**
* 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();
public final T value;
public AttributeValue(T value) {
this.value = value;
}
public static boolean equals(AttributeValue v1, AttributeValue v2) {
if (v1 == null || v2 == null) {
return v1 == v2;
} else {
return equals(v1.value, v2.value);
}
}
public static boolean equals(V v1, V v2) {
if (v1 == null || v2 == null) {
return v1 == v2;
} else {
return v1 == v2 || v1.equals(v2);
}
}
}
$if(Concurrent)
/**
* Tuple for storing attribute value and done flag.
*
Used in concurrent circular attribute evaluation.
*/
public class CircularAttributeValue {
public volatile boolean done;
public final AtomicReference value;
public CircularAttributeValue() {
this.value = new AtomicReference(AttributeValue.NONE);
}
public CircularAttributeValue(Object value) {
this.value = new AtomicReference(value);
}
public boolean compareAndSet(Object expected, Object next) {
return value.compareAndSet(expected, next);
}
public Object get() {
return value.get();
}
}
$endif
/** @apilevel internal */
public class $StateClass {
/**
* This class stores an attribute value tagged with an iteration ID for
* a circular evaluation.
*
* @apilevel internal
*/
protected static class CircularValue {
Object value;
Cycle cycle;
}
/**
* Instances of this class are used to uniquely identify circular evaluation iterations.
* These iteration ID objects are created for each new fixed-point iteration in
* a circular evaluation.
*
* @apilevel internal
*/
protected static class Cycle {
}
/**
* The iteration ID used outside of circular evaluation.
*
*
This is the iteration ID when no circular evaluation is ongoing.
*/
public static final Cycle NON_CYCLE = new Cycle();
/**
* Tracks the state of the current circular evaluation. This class defines a
* stack structure where the next element on the stack is pointed to by the
* {@code next} field.
*
* @apilevel internal
*/
protected static class CircleState {
final CircleState next;
$if(LegacyRewrite)
boolean resetCycle = false;
$endif
boolean change = false;
/** Evaluation depth of lazy attributes. */
int lazyAttribute = 0;
$if(CacheCycle)
boolean lastCycle = false;
$endif
$if(ComponentCheck)
boolean completed = false; // Whether the circular evaluation has completed.
$endif
/** Cycle ID of the latest cycle in this circular evaluation. */
Cycle cycle = NON_CYCLE;
$if(Concurrent)
/**
* Tracks attribute value observations during circular evaluation.
*
*
The purpose of this map is a little different when evaluating
* a circular attribute and when evaluating a non-circular attribute
* during a fixed-point evaluation.
* For a circularly evaluated attribute, this map is only used to track
* iteration IDs. For a non-circularly evaluated attribute, the map
* stores thread-local attribute approximations.
*/
final java.util.Map