avoid wasm symbol conflicts

This commit is contained in:
nora 2023-07-31 13:49:43 +02:00
parent 6bdbf14ecb
commit e951cd5ee1
8 changed files with 188 additions and 99 deletions

View file

@ -32,7 +32,7 @@ import { Ids } from "./utils";
type Parser<T> = (t: Token[]) => [Token[], T];
export function parse(t: Token[]): Ast {
export function parse(packageName: string, t: Token[]): Ast {
const items: Item[] = [];
while (t.length > 0) {
@ -41,7 +41,7 @@ export function parse(t: Token[]): Ast {
items.push(item);
}
const ast = assignIds(items);
const ast = buildAst(packageName, items);
validateAst(ast);
@ -711,13 +711,14 @@ function validateAst(ast: Ast) {
foldAst(ast, validator);
}
function assignIds(rootItems: Item[]): Ast {
function buildAst(packageName: string, rootItems: Item[]): Ast {
const itemId = new Ids();
const loopId = new Ids();
const ast: Ast = {
rootItems,
itemsById: new Map(),
packageName,
};
const assigner: Folder = {