sdr 0.7

net.cscott.sdr.calls.ast
Class Part

java.lang.Object
  extended by net.cscott.sdr.calls.ast.AstNode
      extended by net.cscott.sdr.calls.ast.SeqCall
          extended by net.cscott.sdr.calls.ast.Part

public class Part
extends SeqCall

Part denotes an fractional part of a call. The Part also denotes timing: each part executes in the same amount of time (unless modified by In. Part has exactly one child, which is a Comp. The howMany argument is usually 1 but allows non-standard divisions: for example, "swing and mix" is a three-part call of which the final "mix" counts for two parts. The howMany argument may also be zero, which is used for "adjust" calls, for example the initial step to a wave when doing a swing thru from facing couples is specified as "0 parts" to ensure that "do 1/4 of a swing thru" works correctly from facing couples.

The divisibility argument has three values. If it is Part.Divisibility.DIVISIBLE, calls inside this Part can be further fractionalized. In the "swing and mix" example, both the "swing" and the "mix" can be further divided, allowing "1/6 swing and mix" and "2/3 swing and mix" to be valid. If divisibility is Part.Divisibility.INDIVISIBLE, then the child can not be further divided. For example, "partner swing" can not be divided; it makes no sense to "half swing your partner". Indivisible parts are also used around Prims composing a call, to avoid exposing the implementation of the dancer's path, where this is not well standardized, for example in the definition of "flutterwheel".

The final possible value for divisibility is Part.Divisibility.INDETERMINATE. This allows the specification of calls with clear first and/or last parts, but which can't be otherwise fractionalized. For example, a call which is defined as:

(Part 'DIVISIBLE '1 ...) (Part 'INDETERMINATE '1 ...) (Part 'INDIVISIBLE '1 ...)
can be used with "finish <anything>" and "like an <anything>", but "1/3 <anything>" and "interrupt after each part with <anything>" would both be invalid, because the number of parts in the middle is not defined. The howMany argument is still used internally to divide up the timing of the call, but is otherwise overridden by Part.Divisibility.INDETERMINATE.

Author:
C. Scott Ananian

Nested Class Summary
static class Part.Divisibility
          Whether this Part can be fractionalized.
 
Field Summary
 Comp child
           
 Part.Divisibility divisibility
           
 Expr howMany
           
 
Fields inherited from class net.cscott.sdr.calls.ast.AstNode
type
 
Constructor Summary
Part(Part.Divisibility divisibility, Expr howMany, Comp child)
           
Part(Part.Divisibility divisibility, Fraction howMany, Comp child)
           
 
Method Summary
<T> SeqCall
accept(TransformVisitor<T> v, T t)
          Visitor pattern implementation for transformations.
<RESULT,CLOSURE>
RESULT
accept(ValueVisitor<RESULT,CLOSURE> v, CLOSURE cl)
          Visitor pattern implementation for computations.
 String argsToString()
           
 Part build(Part.Divisibility divisibility, Expr howMany, Comp child)
          Factory: creates new Part only if it would differ from this.
 boolean isIndeterminate()
          True if the result of SeqCall.parts() can not be used for fractionalization.
 Expr parts()
          How many 'parts' are represented by this SeqCall.
 
Methods inherited from class net.cscott.sdr.calls.ast.AstNode
toString, valueOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

divisibility

public final Part.Divisibility divisibility

howMany

public final Expr howMany

child

public final Comp child
Constructor Detail

Part

public Part(Part.Divisibility divisibility,
            Expr howMany,
            Comp child)

Part

public Part(Part.Divisibility divisibility,
            Fraction howMany,
            Comp child)
Method Detail

parts

public Expr parts()
Description copied from class: SeqCall
How many 'parts' are represented by this SeqCall. Should be Expr.literal(Fraction.ONE) for all but Part.

Specified by:
parts in class SeqCall

isIndeterminate

public boolean isIndeterminate()
Description copied from class: SeqCall
True if the result of SeqCall.parts() can not be used for fractionalization.

Specified by:
isIndeterminate in class SeqCall

accept

public <T> SeqCall accept(TransformVisitor<T> v,
                          T t)
Description copied from class: AstNode
Visitor pattern implementation for transformations. Each AstNode accepts a TransformVisitor and a value, and returns an instance of its own type (ie, Seq.accept(tv, "A") returns a Seq). The 't' parameter is a closure.

Specified by:
accept in class SeqCall

accept

public <RESULT,CLOSURE> RESULT accept(ValueVisitor<RESULT,CLOSURE> v,
                                      CLOSURE cl)
Description copied from class: AstNode
Visitor pattern implementation for computations. Each AstNode accepts a ValueVisitor and a closure, and returns an object of the appropriate result type.

Specified by:
accept in class AstNode

build

public Part build(Part.Divisibility divisibility,
                  Expr howMany,
                  Comp child)
Factory: creates new Part only if it would differ from this.


argsToString

public String argsToString()
Overrides:
argsToString in class AstNode

sdr 0.7

Copyright © 2006-2009 C. Scott Ananian