kiama.attribution.AttributionBase

class CircularAttribute

[source: kiama/attribution/AttributionBase.scala]

class CircularAttribute[T <: AnyRef, U](init : U, f : scala.PartialFunction[T, U])
extends scala.PartialFunction[T, U]
An attribute of a node type T with value of type U which has a circular definition. The value of the attribute is computed by the function f which may itself use the value of the attribute. init specifies an initial value for the attribute. The attribute (and any circular attributes on which it depends) are evaluated until no value changes (i.e., a fixed point is reached). The final result is memoised so that subsequent evaluations return the same value. This code implements the basic circular evaluation algorithm from "Circular Reference Attributed Grammars - their Evaluation and Applications", by Magnusson and Hedin from LDTA 2003.
Method Summary
def apply (t : T) : U
Return the value of this attribute for node t. Essentially Figure 6 from the CRAG paper.
def isDefinedAt (t : T) : Boolean
A circular attribute is defined at the same places as its defining function.
Methods inherited from scala.PartialFunction
scala.PartialFunction.orElse, scala.PartialFunction.andThen
Methods inherited from scala.Function1
scala.Function1.toString, scala.Function1.compose
Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
def apply(t : T) : U
Return the value of this attribute for node t. Essentially Figure 6 from the CRAG paper.

def isDefinedAt(t : T) : Boolean
A circular attribute is defined at the same places as its defining function.
Overrides
scala.PartialFunction.scala.PartialFunction.isDefinedAt