UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

26 lines (25 loc) 1.16 kB
import { FuncArgBase } from "./FuncArgBase.js"; import { ExprEvalTypeErrorObj, } from "../../ExprEvalResult.js"; import { ExprKind } from "../../ExprKind.js"; import { NumericValue } from "../../../value/NumericValue.js"; import { Type } from "../../../type/Types.js"; export class FuncArgInt extends FuncArgBase { constructor(required, name, defaultValue) { super(required, name, defaultValue); } getType() { return Type.NUMERIC; } transformForTypeCheck(callingExpr, invocationValue) { const result = invocationValue.result; if (!NumericValue.isNumericValueType(result)) { return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Argument ${this.name} must be a NumericValue, but was ${result}`, result, callingExpr.getTextSpan()); } const value = result.numericValue; if (value.isInteger()) { return invocationValue; } return new ExprEvalTypeErrorObj(ExprKind.FUNCTION_ARGUMENTS, `Value of argument ${this.name} must be an integer, but was ${value}`, value, callingExpr.getTextSpan()); } } //# sourceMappingURL=FuncArgInt.js.map