UNPKG

calcium-lang

Version:
27 lines 799 B
import { CannotUnpackValue } from "../error"; import { default as Sym } from "../symbol"; import { retrieveValue } from "../util"; /** * multiple values assignment or unpacking */ export default class Comma { constructor(refs) { this.refs = refs; } assign(rhs, env) { const kind = Reflect.get(rhs, Sym.class); if (kind !== "list" && kind !== "tuple") { throw new CannotUnpackValue(); } const container = retrieveValue(rhs, env); for (let i = 0; i < this.refs.length; ++i) { this.refs[i].assign(container[i], env); } } get [Sym.description]() { return `${this.refs .map((r) => Reflect.get(r, Sym.description)) .join(", ")}`; } } //# sourceMappingURL=comma.js.map