import { Observable } from "../../util/observe"; import { RunnableProgram } from "../compilation/Program"; import { Value } from "./Value"; import { Memory } from "./Memory"; import { RuntimeConstruct } from "../constructs/CPPConstruct"; import { RuntimeGlobalObjectAllocator } from "../constructs/GlobalObjectAllocator"; import { CPPRandom } from "../../util/util"; import { MainReturnObject } from "./objects"; import { Int, AtomicType, FunctionType, PotentiallyCompleteObjectType, ReferenceType, ReferredType } from "../compilation/types"; import { RuntimeDirectInitializer } from "../constructs/initializers/DirectInitializer"; import { PassByReferenceParameterEntity, PassByValueParameterEntity } from "../compilation/entities"; import { RuntimeExpression } from "../constructs/expressions/RuntimeExpression"; import { RuntimeFunction } from "../compilation/functions"; import { StandardInputStream } from "../compilation/streams"; export declare enum SimulationEvent { UNDEFINED_BEHAVIOR = "undefined_behavior", UNSPECIFIED_BEHAVIOR = "unspecified_behavior", IMPLEMENTATION_DEFINED_BEHAVIOR = "implementation_defined_behavior", MEMORY_LEAK = "memory_leak", ASSERTION_FAILURE = "assertion_failure", CRASH = "crash" } export declare enum SimulationActionKind { STEP_FORWARD = 0, CIN_INPUT = 1 } export interface StepForwardAction { kind: SimulationActionKind.STEP_FORWARD; } export interface CinInputAction { kind: SimulationActionKind.CIN_INPUT; text: string; } export declare type SimulationAction = StepForwardAction | CinInputAction; export declare const STEP_FORWARD_ACTION: StepForwardAction; export declare enum SimulationOutputKind { COUT = 0, CIN_ECHO = 1 } export interface CoutOutput { kind: SimulationOutputKind.COUT; text: string; } export interface CinEchoOutput { kind: SimulationOutputKind.CIN_ECHO; text: string; } export declare type SimulationOutput = CoutOutput | CinEchoOutput; export declare type SimulationMessages = "started" | "reset" | "mainCalled" | "pushed" | "popped" | "beforeUpNext" | "afterUpNext" | "beforeStepForward" | "afterStepForward" | "afterFullStep" | "atEnded" | "parameterPassedByReference" | "parameterPassedByAtomicValue" | "returnPassed" | "istreamBufferUpdated" | "cout" | "cinInput" | "eventOccurred"; declare type SimulationOptions = { cin?: StandardInputStream; start?: boolean; }; export declare class Simulation { readonly observable: Observable; readonly program: RunnableProgram; readonly memory: Memory; private readonly _execStack; readonly execStack: readonly RuntimeConstruct[]; readonly random: CPPRandom; readonly stepsTaken: number; private readonly _actionsTaken; readonly actionsTaken: readonly SimulationAction[]; readonly allOutput: string; readonly outputProduced: readonly SimulationOutput[]; readonly cin: StandardInputStream; readonly rng: CPPRandom; readonly isPaused: boolean; readonly atEnd: boolean; readonly isBlockingUntilCin: boolean; private readonly pendingNews; private leakCheckIndex; private alertsOff; private readonly _eventsOccurred; readonly eventsOccurred: { [p in SimulationEvent]: readonly string[]; }; readonly hasAnyEventOccurred: boolean; readonly mainReturnObject: MainReturnObject; readonly mainFunction: RuntimeFunction>; readonly globalAllocator: RuntimeGlobalObjectAllocator; constructor(program: RunnableProgram, options?: SimulationOptions); clone(stepsTaken?: number): Simulation; reset(): void; private start; private callMain; push(rt: RuntimeConstruct): void; top(): RuntimeConstruct | undefined; /** * Removes the top runtime construct from the execution stack. * Does nothing if there's nothing on the execution stack. */ pop(): RuntimeConstruct | undefined; popUntil(rt: RuntimeConstruct): void; startCleanupUntil(rt: RuntimeConstruct): void; topFunction(): RuntimeFunction | undefined; private allocateStringLiterals; takeAction(action: SimulationAction): void; stepForward(): void; private upNext; stepToEnd(): void; atEndOfMain(): boolean; parameterPassedByReference>(target: PassByReferenceParameterEntity, arg: RuntimeExpression, "lvalue">): void; parameterPassedByAtomicValue(target: PassByValueParameterEntity, arg: RuntimeExpression): void; returnPassed(rt: RuntimeDirectInitializer): void; cinInput(text: string): void; blockUntilCin(): void; cout(value: Value): void; eventOccurred(event: SimulationEvent, message: string, showAlert?: boolean): void; hasEventOccurred(event: SimulationEvent): boolean; printState(): string; } export {};