UNPKG

js-slang

Version:

Javascript-based implementations of Source, written in Typescript

63 lines (62 loc) 3.08 kB
import type es from 'estree'; import createContext from './createContext'; import { type Variant } from './langs'; import { setBreakpointAtLine } from './stdlib/inspector'; import type { Context, ExecutionMethod, Finished, ModuleContext, RecursivePartial, Result, Error as ResultError, SVMProgram } from './types'; import { assemble } from './vm/svml-assembler'; import type { SourceError } from './errors/base'; import type { ImportOptions } from './modules/moduleTypes'; import { type NameDeclaration } from './name-extractor'; export { SourceDocumentation } from './editors/ace/docTooltip'; 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 { assemble, Context, createContext, ModuleContext, Result, setBreakpointAtLine };