|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
import type { AST, Pattern, Definition } from './ast';
|
|
|
|
|
import { _rt, store } from './runtime-js';
|
|
|
|
|
|
|
|
|
|
let matchCounter = 0;
|
|
|
|
|
|
|
|
|
|
export const definitions: Map<string, AST> = new Map();
|
|
|
|
|
export const dependencies: Map<string, Set<string>> = new Map();
|
|
|
|
|
export const dependents: Map<string, Set<string>> = new Map();
|
|
|
|
|
@ -135,7 +137,7 @@ function sanitizeName(name: string): string {
|
|
|
|
|
|
|
|
|
|
function compileMatch(ast: AST & { kind: 'match'}, useStore = true, bound = new Set<string>()): string {
|
|
|
|
|
const expr = compile(ast.expr, useStore, bound);
|
|
|
|
|
const tmpVar = `_m${Math.floor(Math.random() * 10000)}`;
|
|
|
|
|
const tmpVar = `_m${matchCounter++}`;
|
|
|
|
|
|
|
|
|
|
let code = `((${tmpVar}) => { `;
|
|
|
|
|
|
|
|
|
|
|