bolt/src/bindings.ts
Sam Vervaeck a1304e177d Major update to code
- Many small fixes to parser and scanner
 - Extended type checking algorithm for existing nodes
 - Add partial support for module definitions and records
 - Add an evaluator
 - Prepare for new version of macro system
2020-02-26 18:53:28 +01:00

22 lines
493 B
TypeScript

import { Value, RecordValue } from "./evaluator"
interface Binding {
name: string;
createValue: () => Value,
}
export const bindings = new Map<string, Binding>();
export function bind(name: string) {
return function (target: any) {
if (bindings.has(name)) {
throw new Error(`A binding with the name '${name}' already exists.`)
}
bindings.set(name, {
name,
createValue: (...args) => new RecordValue(target.META_TYPE, new target(...args)),
});
}
}