Function extractUnexecutedRanges

  • Extract an array of ranges that were unused by an evaluation. This is useful in development tooling for fading out or hiding code that is unimportant to the current evaluation being tested.

    Type Parameters

    Parameters

    • samples: EvaluationSample<ProgramState>[]

      an array of samples ordered by the ending position (line and column) of their range.

    • evaluationBegins: string = '1,1'

      the line and column at which the initial sample's evaluation range begins (where the preceding state is assumed to be executing), defaults to 1,1

    Returns Range[]

    Remarks

    Only ranges that are guaranteed to be unimportant to an evaluation are returned by this method. These ranges are extracted from samples that:

    • are preceded by a sample that ends with execution disabled (e.g. an unsuccessful OP_IF)
    • end with execution disabled, and
    • contain no internalStates that enable execution.

    Note, internal states that temporarily re-enable and then disable execution again can still have an effect on the parent evaluation, so this method conservatively excludes such samples. For example, the hex literal 0x675167, which encodes OP_ELSE OP_1 OP_ELSE, could begin and end with states in which execution is disabled, yet a 1 is pushed to the stack during the sample's evaluation. (Samples like this are unusual, and can almost always be reformatted to clearly separate the executed and unexecuted instructions.)

Generated using TypeDoc