import * as core from "..";
import { EventEmitter } from "events";
import { BrsType, BrsInvalid, Callable, RoArray, Signature } from "../brsTypes";
import { BrsExtension } from "../extensions";
import { Location } from "../lexer/Token";
import { Expr, Stmt } from "../parser";
import { BrsError, RuntimeError } from "../error/BrsError";
import { Scope, Environment } from "./Environment";
/** The set of options used to configure an interpreter's execution. */
export interface ExecutionOptions {
    root?: string;
    ext?: string;
    entryPoint?: boolean;
    stopOnCrash?: boolean;
    /** The stdout stream that brs should use. Default: process.stdout. */
    stdout: NodeJS.WriteStream;
    /** The stderr stream that brs should use. Default: process.stderr. */
    stderr: NodeJS.WriteStream;
    /** If enabled makes OutputProxy print output via postMessage(). Default: true */
    post: boolean;
}
/** The default set of execution options.  */
export declare const defaultExecutionOptions: ExecutionOptions;
/** The definition of a trace point to be added to the stack trace */
export interface TracePoint {
    functionName: string;
    functionLocation: Location;
    callLocation: Location;
    signature: Signature;
}
export declare class Interpreter implements Expr.Visitor<BrsType>, Stmt.Visitor<BrsType> {
    private readonly _stack;
    private readonly _startTime;
    private readonly _creationTime;
    private _environment;
    private _sourceMap;
    private _runParams;
    private _tryMode;
    private _dotLevel;
    private _printed;
    location: Location;
    static readonly InternalLocation: {
        file: string;
        start: {
            line: number;
            column: number;
        };
        end: {
            line: number;
            column: number;
        };
    };
    readonly options: ExecutionOptions;
    readonly manifest: Map<string, string>;
    readonly translations: Map<string, string>;
    readonly extensions: Map<string, BrsExtension>;
    /** Allows consumers to observe errors as they're detected. */
    readonly events: EventEmitter<[never]>;
    /** The set of errors detected from executing an AST. */
    errors: (BrsError | RuntimeError)[];
    get environment(): core.Environment;
    get sourceMap(): Map<string, string>;
    get runParams(): core.RoAssociativeArray | undefined;
    get stack(): core.TracePoint[];
    get startTime(): number;
    get creationTime(): string | undefined;
    debugMode: boolean;
    stepMode: boolean;
    private lastStmt;
    /**
     * Adds a TracePoint to the call stack.
     * @param tracePoint The TracePoint to add to the stack
     */
    addToStack(tracePoint: TracePoint): void;
    /**
     * Updates the interpreter manifest with the provided data.
     * @param manifest Map with manifest content
     */
    setManifest(manifest: Map<string, string>): void;
    /**
     * Convenience function to subscribe to the `err` events emitted by `interpreter.events`.
     * @param errorHandler the function to call for every runtime error emitted after subscribing
     * @returns an object with a `dispose` function, used to unsubscribe from errors
     */
    onError(errorHandler: (err: BrsError | RuntimeError) => void): {
        dispose: () => void;
    };
    /**
     * Convenience function to subscribe to a single `err` event emitted by `interpreter.events`.
     * @param errorHandler the function to call for the first runtime error emitted after subscribing
     */
    onErrorOnce(errorHandler: (err: BrsError | RuntimeError) => void): void;
    /**
     * Creates a new Interpreter, including any global properties and functions.
     * @param options configuration for the execution
     */
    constructor(options?: Partial<ExecutionOptions>);
    /**
     * Temporarily sets an interpreter's environment to the provided one, then
     * passes the sub-interpreter to the provided JavaScript function. Always
     * reverts the current interpreter's environment to its original value.
     * @param func The JavaScript function to execute with the sub interpreter
     * @param environment Optional environment to run the interpreter in
     * @returns The result of executing the function in the sub-environment
     */
    inSubEnv(func: (interpreter: Interpreter) => BrsType, environment?: Environment): BrsType;
    /**
     * Executes the provided statements in the current environment.
     * @param statements Array of statements to execute
     * @param sourceMap Optional source code map for debugging
     * @param args Run parameters for Main() or RunUserInterface() functions
     * @returns Array with the results of the executed statements
     */
    exec(statements: readonly Stmt.Statement[], sourceMap?: Map<string, string>, ...args: BrsType[]): core.BrsType[];
    /**
     * Retrieves the Callable function from the environment.
     * @param functionName The name of the function to retrieve
     * @param location Optional location from where the function will be called
     * @returns The Callable function or BrsInvalid if not found
     */
    getCallableFunction(functionName: string, location?: Location): Callable | BrsInvalid;
    visitLibrary(statement: Stmt.Library): BrsInvalid;
    visitNamedFunction(statement: Stmt.Function): BrsType;
    visitReturn(statement: Stmt.Return): never;
    visitExpression(statement: Stmt.Expression): BrsType;
    visitPrint(statement: Stmt.Print): BrsType;
    visitStop(statement: Stmt.Stop): BrsType;
    visitAssignment(statement: Stmt.Assignment): BrsType;
    visitDim(statement: Stmt.Dim): BrsType;
    visitBinary(expression: Expr.Binary): core.BrsString | core.BrsBoolean | import("../brsTypes/BrsNumber").BrsNumber;
    visitTryCatch(statement: Stmt.TryCatch): BrsInvalid;
    visitThrow(statement: Stmt.Throw): never;
    visitBlock(block: Stmt.Block): BrsType;
    visitGoto(statement: Stmt.Goto): never;
    visitContinueFor(statement: Stmt.ContinueFor): never;
    visitExitFor(statement: Stmt.ExitFor): never;
    visitContinueWhile(statement: Stmt.ContinueWhile): never;
    visitExitWhile(statement: Stmt.ExitWhile): never;
    visitCall(expression: Expr.Call): core.Int32 | core.Int64 | core.Double | core.Float | core.BrsString | core.BrsInterface | core.BrsInvalid | core.BrsBoolean | core.Callable | core.AllComponents | core.Uninitialized;
    visitAtSignGet(expression: Expr.AtSignGet): core.BrsString | core.BrsInvalid;
    visitDottedGet(expression: Expr.DottedGet): core.BrsType | core.RoFunction | core.RoInvalid | core.RoString | core.RoBoolean | core.RoDouble | core.RoFloat | core.RoInt | core.RoLongInteger;
    visitIndexedGet(expression: Expr.IndexedGet): BrsType;
    visitGrouping(expr: Expr.Grouping): core.BrsType;
    visitFor(statement: Stmt.For): BrsType;
    visitForEach(statement: Stmt.ForEach): BrsType;
    visitWhile(statement: Stmt.While): BrsType;
    visitIf(statement: Stmt.If): BrsType;
    visitAnonymousFunction(func: Expr.Function): BrsType;
    visitLiteral(expression: Expr.Literal): BrsType;
    visitArrayLiteral(expression: Expr.ArrayLiteral): RoArray;
    visitAALiteral(expression: Expr.AALiteral): BrsType;
    visitDottedSet(statement: Stmt.DottedSet): core.BrsInvalid;
    visitIndexedSet(statement: Stmt.IndexedSet): core.BrsInvalid;
    visitIncrement(statement: Stmt.Increment): core.BrsInvalid;
    visitUnary(expression: Expr.Unary): core.Int32 | core.Int64 | core.Double | core.Float | core.BrsString | core.BrsInterface | core.BrsInvalid | core.BrsBoolean | core.Callable | core.AllComponents | core.Uninitialized;
    visitVariable(expression: Expr.Variable): core.BrsType;
    /**
     * Evaluates an expression and returns its BrsType value.
     * @param expression The expression to evaluate
     * @returns The BrsType result of evaluating the expression
     */
    evaluate(this: Interpreter, expression: Expr.Expression): BrsType;
    /**
     * Executes a statement and returns its BrsType result.
     * Handles goto labels, debugger checks, and extension ticks.
     * @param statement The statement to execute
     * @returns The BrsType result of executing the statement
     */
    execute(this: Interpreter, statement: Stmt.Statement): BrsType;
    /**
     * Checks for debugger break commands and handles debug mode state.
     * @param statement The statement being executed
     */
    private checkDebugger;
    /**
     * Iterates through the statements to find the label to jump to.
     * @param statement The root statement to start searching from
     * @returns BrsInvalid if no exception is thrown
     */
    private searchLabel;
    /**
     * Returns the memory heap information from the interpreter.
     * @returns Object with the heap size limit and the used heap size in KB
     */
    getMemoryHeapInfo(): {
        heapSizeLimit: number;
        usedHeapSize: number;
    };
    /**
     * Returns the backtrace formatted as a string or an array.
     * @param loc The location of the error
     * @param asString If true returns the backtrace as a string, otherwise as RoArray
     * @param bt Optional backtrace array, defaults to current stack
     * @returns String or RoArray with the formatted backtrace
     */
    formatBacktrace(loc: Location, asString?: boolean, bt?: TracePoint[]): RoArray | string;
    /**
     * Returns a formatted string of variables in the selected scope for REPL and Micro Debugger.
     * @param scope The scope to inspect (defaults to Function scope)
     * @returns String representation of the variables in the selected scope
     */
    formatVariables(scope?: Scope): string;
    /**
     * Formats a BrsType value for display in the debugger.
     * @param value The BrsType value to format
     * @returns Formatted string representation of the value
     */
    formatValue(value: BrsType): string;
    /**
     * Returns a string with the source code location in pkg: format.
     * @param location The location to format (defaults to current location)
     * @returns String representation of the location in format "pkg:/file(line)"
     */
    formatLocation(location?: Location): string;
    /**
     * Returns the statistics of the interpreter for the REPL and Micro Debugger.
     * @returns String representation of the interpreter statistics
     */
    formatStats(): string;
    /**
     * Returns the current app's formatted version from the manifest.
     * @returns The current app version in format "major.minor.build"
     */
    getChannelVersion(): string;
    /**
     * Emits an error via this interpreter's `events` property, then throws it.
     * @param err The BrsError to emit and throw
     */
    addError(err: BrsError): never;
    /**
     * Formats a BrsError into an associative array for error handling in BrightScript.
     * @param err The BrsError to format
     * @returns RoAssociativeArray containing error details (backtrace, message, number, etc.)
     */
    private formatErrorVariable;
    /**
     * Evaluates if a number is positive or NaN.
     * @param value Number to evaluate (number or Long)
     * @returns True if the number is positive or NaN, false otherwise
     */
    private isPositive;
    /**
     * Evaluates if a number is less than a comparison value.
     * @param value Number to evaluate (number or Long)
     * @param compare Number to compare against
     * @returns True if value is less than compare, false otherwise
     */
    private lessThan;
}
