UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

28 lines (27 loc) 1.03 kB
import { Func } from "../Func.js"; import { ExprEvalSuccessObj } from "../../ExprEvalResult.js"; import { Types } from "../../../type/Types.js"; import { FuncArgNumeric } from "../arg/FuncArgNumeric.js"; import { FuncArgArray } from "../arg/FuncArgArray.js"; import { TupleType } from "../../../type/TupleType.js"; export class AT extends Func { constructor() { super("AT", [ new FuncArgArray(true, "input"), new FuncArgNumeric(true, "index"), ]); } calculateResult(callingExpr, evaluatedArguments) { const inputArray = evaluatedArguments.get("input").getValue(); const index = evaluatedArguments.get("index").getValue(); return new ExprEvalSuccessObj(inputArray.at(index.toNumber())); } getReturnType(argumentTypes) { const arrType = argumentTypes[0]; if (arrType instanceof TupleType) { return Types.or(...arrType.getTypes()); } return arrType.getElementType(); } } //# sourceMappingURL=AT.js.map