sonic-weave
    Preparing search index...

    Class StatementVisitor

    Abstract syntax tree visitor for statements in a SonicWeave program.

    Index

    Constructors

    Properties

    deferred: Statement[]

    Deferred statement to be executed at the end of the current block.

    Exported constants and functions usually from a module declaration.

    immutables: VisitorContext

    Local context for immutable (const) variables.

    imported: Set<string>

    Imported names.

    isUserRoot: boolean

    Whether or not the state of the visitor can be represented as text and that state represents the runtime from a user's perspective. The global context doesn't have a representation because the builtins are not written in the SonicWeave DSL.

    modules: Map<string, SonicWeaveModule>

    Declared modules.

    mutables: VisitorContext

    Local context for mutable (let) variables.

    Parent context of the surrounding code block.

    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

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

      Returns RootContext | undefined

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

      Parameters

      Returns void

    Methods

    • Construct a visitor for evaluating the contents of an ExpressionStatement.

      Parameters

      • inheritVariables: boolean = false

        If true the expression visitor will share context of the variables with this one.

      Returns ExpressionVisitor

      A new visitor for the AST of an expression.

    • Execute the abstract syntax tree of a SonicWeave program.

      Parameters

      • program: Program

        Program containing the AST to be executed.

      Returns void

    • Execute an array of SonicWeave statements from an abstract syntax tree.

      Parameters

      • body: Statement[]

        The AST nodes to be executed.

      Returns Interrupt | undefined

      An interrupt or undefined if none encountered.

    • Convert the state of this statement visitor into a block of text in the SonicWeave DSL. Only intended for the user scope just above the global scope.

      Parameters

      • defaultRootContext: RootContext

        Root context for determining if root pitch declaration must be included.

      Returns string

      A string that when evaluated should recreate the same runtime state.

    • Returns void

    • 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.

    • Handle a value by pushing it to the current scale or taking some other action depending on the type of the value.

      Parameters

      Returns void

    • 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.

      Parameters

      • node: Statement

        The AST node of the statement to evaluate.

      Returns Interrupt | undefined

      An interrupt if encountered. undefined otherwise.

    • Parameters

      Returns undefined