js-slang
Version:
Javascript-based implementations of Source, written in Typescript
19 lines (18 loc) • 1.09 kB
TypeScript
import type es from 'estree';
import { type RawSourceMap } from 'source-map';
import { type Context, type NativeStorage } from '../types';
import { NativeIds } from '../utils/uniqueIds';
/**
* This whole transpiler includes many many many many hacks to get stuff working.
* Order in which certain functions are called matter as well.
* There should be an explanation on it coming up soon.
*/
export declare function transformImportDeclarations(program: es.Program, moduleExpr: es.Expression): [es.VariableDeclaration[], Exclude<es.Program['body'][0], es.ImportDeclaration>[]];
export declare function getGloballyDeclaredIdentifiers(program: es.Program): string[];
export declare function getBuiltins(nativeStorage: NativeStorage): es.Statement[];
export declare function evallerReplacer(nativeStorageId: NativeIds['native'], usedIdentifiers: Set<string>): es.ExpressionStatement;
export type TranspiledResult = {
transpiled: string;
sourceMapJson?: RawSourceMap;
};
export declare function transpile(program: es.Program, context: Context, skipUndefined?: boolean): TranspiledResult;