import { PathReference } from '@glimmer/reference'; import { CompiledExpression } from '../expressions'; import { PublicVM as VM } from '../../vm'; import { SymbolTable } from '@glimmer/interfaces'; export type FunctionExpression = (VM: VM, symbolTable: SymbolTable) => PathReference; export class CompiledFunctionExpression extends CompiledExpression { public type = "function"; constructor(private func: FunctionExpression, private symbolTable: SymbolTable) { super(); this.func = func; } evaluate(vm: VM): PathReference { let { func, symbolTable } = this; return func(vm, symbolTable); } toJSON(): string { let { func } = this; if (func.name) { return `\`${func.name}(...)\``; } else { return "`func(...)`"; } } }