UNPKG

js-slang

Version:

Javascript-based implementations of Source, written in Typescript

61 lines (60 loc) 3.06 kB
import type es from 'estree'; import createContext from './createContext'; import { setBreakpointAtLine } from './stdlib/inspector'; import { type Context, type Error as ResultError, type ExecutionMethod, type Finished, type ModuleContext, type RecursivePartial, type Result, type SourceError, type SVMProgram, type Variant } from './types'; import { assemble } from './vm/svml-assembler'; export { SourceDocumentation } from './editors/ace/docTooltip'; import type { ImportOptions } from './modules/moduleTypes'; import { type NameDeclaration } from './name-extractor'; export interface IOptions { steps: number; stepLimit: number; executionMethod: ExecutionMethod; variant: Variant; originalMaxExecTime: number; useSubst: boolean; isPrelude: boolean; throwInfiniteLoops: boolean; envSteps: number; importOptions: ImportOptions; /** * Set this to true if source file information should be * added when parsing programs into ASTs * * Set to null to let js-slang decide automatically */ shouldAddFileName: boolean | null; } export declare function parseError(errors: SourceError[], verbose?: boolean): string; export declare function findDeclaration(code: string, context: Context, loc: { line: number; column: number; }): es.SourceLocation | null | undefined; export declare function getScope(code: string, context: Context, loc: { line: number; column: number; }): es.SourceLocation[]; export declare function getAllOccurrencesInScope(code: string, context: Context, loc: { line: number; column: number; }): es.SourceLocation[]; export declare function hasDeclaration(code: string, context: Context, loc: { line: number; column: number; }): boolean; /** * Gets names present within a string of code * @param code Code to parse * @param line Line position of the cursor * @param col Column position of the cursor * @param context Evaluation context * @returns `[NameDeclaration[], true]` if suggestions should be displayed, `[[], false]` otherwise */ export declare function getNames(code: string, line: number, col: number, context: Context): Promise<[NameDeclaration[], boolean]>; export declare function runInContext(code: string, context: Context, options?: RecursivePartial<IOptions>): Promise<Result>; export declare function runFilesInContext(files: Partial<Record<string, string>>, entrypointFilePath: string, context: Context, options?: RecursivePartial<IOptions>): Promise<Result>; export declare function resume(result: Result): Finished | ResultError | Promise<Result>; export declare function interrupt(context: Context): void; export declare function compile(code: string, context: Context, vmInternalFunctions?: string[]): Promise<SVMProgram | undefined>; export declare function compileFiles(files: Partial<Record<string, string>>, entrypointFilePath: string, context: Context, vmInternalFunctions?: string[]): Promise<SVMProgram | undefined>; export { createContext, Context, ModuleContext, Result, setBreakpointAtLine, assemble };