UNPKG

expression-evaluation

Version:
45 lines (44 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FunctionSignature = exports.FUNCTION_ARG_MAX = void 0; const Type_js_1 = require("./Type.js"); exports.FUNCTION_ARG_MAX = 16536; class FunctionSignature { _type; _argTypes; _minArity; _maxArity; _typeInference; _pure; static unknown = new FunctionSignature(Type_js_1.typeUnknown, [Type_js_1.typeUnknown], 0, exports.FUNCTION_ARG_MAX); constructor(_type, _argTypes, _minArity, _maxArity, _typeInference, _pure = true) { this._type = _type; this._argTypes = _argTypes; this._minArity = _minArity; this._maxArity = _maxArity; this._typeInference = _typeInference; this._pure = _pure; } get pure() { return this._pure; } get minArity() { return this._minArity ?? this._argTypes.length; } get maxArity() { return this._maxArity ?? this._argTypes.length; } get type() { return this._type; } argType(index) { return this._argTypes[index] ?? this._argTypes[this._argTypes.length - 1]; } argTypeInference(type, index) { return this._typeInference && this._typeInference <= index ? this.argType(index).reduce(type) : this.argType(index); } toString() { return `${this._type.toString()}(${this._argTypes.map((i) => i.toString()).join(', ')})`; } } exports.FunctionSignature = FunctionSignature;