sonic-weave
    Preparing search index...

    Class ExpressionVisitor

    Abstract syntax tree visitor for SonicWeave expressions.

    Index

    Constructors

    Properties

    mutables: VisitorContext

    Local context inside arrow functions and array comprehensions.

    Parent context containing a particular expression statement.

    Accessors

    • get currentScale(): Interval[]

      Get the array of Interval instances accumulated in the current context.

      Returns Interval[]

      An array of intervals. (Assuming the user hasn't corrupted the context.)

    • set currentScale(scale: Interval[]): void

      Set an array of Interval instances as the current scale where new intervals are accumulated.

      Parameters

      Returns void

    • get rootContext(): RootContext | undefined

      Get the root context with the current values of the root pitch, ups, lifts, etc.

      Returns RootContext | undefined

    • set rootContext(context: RootContext | undefined): void

      Set the root context with the current values of the root pitch, ups, lifts, etc.

      Warning: Modifies parent context!

      Parameters

      Returns void

    Methods

    • Get the value of a variable in the current context.

      Parameters

      • name: string

        Name of the variable.

      Returns SonicWeaveValue

      Value of the variable.

      An error if there is no variable declared under the given name.

    • Assign arguments to their corresponding parameter(s) in the current context.

      Parameters

      Returns void

    • Parameters

      • parent: boolean

      Returns Interval[]

    • Set the value of a variable in the current context.

      Parameters

      • name: string

        Name of the variable.

      • value: SonicWeaveValue

        Value for the variable.

      Returns void

      An error if there is no variable declared under the given name or the given variable is declared constant.

    • Parameters

      • Optionalamount: number

      Returns void

    • Visit a node in the abstract syntax tree and evaluate to a value.

      Parameters

      • node: Expression

        The AST node of the expression to evaluate.

      Returns SonicWeaveValue

      The result of evaluation.

    • Parameters

      Returns number | Fraction

    • Construct a square-superparticular from an AST node.

      Parameters

      Returns Interval

      The square-superparticular or a product of a range of them as a logarithmic interval.