ifc-expressions 1.0.0-beta.0 → 2.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cjs/ExprVisitor.js +2 -2
  2. package/dist/cjs/ExprVisitor.js.map +1 -1
  3. package/dist/cjs/IfcExpressionValidationListener.js +2 -2
  4. package/dist/cjs/IfcExpressionValidationListener.js.map +1 -1
  5. package/dist/cjs/expression/poly/PlusOrConcatExpr.js +5 -1
  6. package/dist/cjs/expression/poly/PlusOrConcatExpr.js.map +1 -1
  7. package/dist/cjs/type/TypeManager.js +12 -0
  8. package/dist/cjs/type/TypeManager.js.map +1 -1
  9. package/dist/cjs/type/Types.js +2 -1
  10. package/dist/cjs/type/Types.js.map +1 -1
  11. package/dist/cjs/value/ArrayValue.js +4 -0
  12. package/dist/cjs/value/ArrayValue.js.map +1 -1
  13. package/dist/cjs/value/BooleanValue.js +4 -0
  14. package/dist/cjs/value/BooleanValue.js.map +1 -1
  15. package/dist/cjs/value/LogicalValue.js +4 -0
  16. package/dist/cjs/value/LogicalValue.js.map +1 -1
  17. package/dist/cjs/value/NumericValue.js +4 -0
  18. package/dist/cjs/value/NumericValue.js.map +1 -1
  19. package/dist/cjs/value/ObjectAccessorValue.js +4 -0
  20. package/dist/cjs/value/ObjectAccessorValue.js.map +1 -1
  21. package/dist/cjs/value/ReferenceValue.js +4 -0
  22. package/dist/cjs/value/ReferenceValue.js.map +1 -1
  23. package/dist/cjs/value/StringValue.js +4 -0
  24. package/dist/cjs/value/StringValue.js.map +1 -1
  25. package/dist/cjs/value/Value.js.map +1 -1
  26. package/dist/mjs/ExprVisitor.js +2 -2
  27. package/dist/mjs/ExprVisitor.js.map +1 -1
  28. package/dist/mjs/IfcExpressionValidationListener.js +2 -2
  29. package/dist/mjs/IfcExpressionValidationListener.js.map +1 -1
  30. package/dist/mjs/expression/poly/PlusOrConcatExpr.js +5 -1
  31. package/dist/mjs/expression/poly/PlusOrConcatExpr.js.map +1 -1
  32. package/dist/mjs/type/TypeManager.js +12 -0
  33. package/dist/mjs/type/TypeManager.js.map +1 -1
  34. package/dist/mjs/type/Types.js +2 -1
  35. package/dist/mjs/type/Types.js.map +1 -1
  36. package/dist/mjs/value/ArrayValue.js +4 -0
  37. package/dist/mjs/value/ArrayValue.js.map +1 -1
  38. package/dist/mjs/value/BooleanValue.js +4 -0
  39. package/dist/mjs/value/BooleanValue.js.map +1 -1
  40. package/dist/mjs/value/LogicalValue.js +4 -0
  41. package/dist/mjs/value/LogicalValue.js.map +1 -1
  42. package/dist/mjs/value/NumericValue.js +4 -0
  43. package/dist/mjs/value/NumericValue.js.map +1 -1
  44. package/dist/mjs/value/ObjectAccessorValue.js +4 -0
  45. package/dist/mjs/value/ObjectAccessorValue.js.map +1 -1
  46. package/dist/mjs/value/ReferenceValue.js +4 -0
  47. package/dist/mjs/value/ReferenceValue.js.map +1 -1
  48. package/dist/mjs/value/StringValue.js +4 -0
  49. package/dist/mjs/value/StringValue.js.map +1 -1
  50. package/dist/mjs/value/Value.js.map +1 -1
  51. package/dist/type/TypeManager.d.ts +4 -0
  52. package/dist/type/Types.d.ts +1 -0
  53. package/dist/value/ArrayValue.d.ts +2 -0
  54. package/dist/value/BooleanValue.d.ts +2 -0
  55. package/dist/value/LogicalValue.d.ts +2 -0
  56. package/dist/value/NumericValue.d.ts +2 -0
  57. package/dist/value/ObjectAccessorValue.d.ts +2 -0
  58. package/dist/value/ReferenceValue.d.ts +2 -0
  59. package/dist/value/StringValue.d.ts +2 -0
  60. package/dist/value/Value.d.ts +2 -0
  61. package/package.json +1 -1
@@ -230,8 +230,8 @@ class ExprVisitor extends IfcExpressionVisitor_js_1.default {
230
230
  if (this.typeManager.isString(ctx._left, ctx._right)) {
231
231
  return new StringConcatExpr_js_1.StringConcatExpr(this.visit(ctx._left), this.visit(ctx._right));
232
232
  }
233
- if (this.typeManager.isString(ctx._left, ctx._right) ||
234
- this.typeManager.isNumeric(ctx._left, ctx._right)) {
233
+ if (this.typeManager.overlapsWithString(ctx._left, ctx._right) ||
234
+ this.typeManager.overlapsWithNumeric(ctx._left, ctx._right)) {
235
235
  return new PlusOrConcatExpr_js_1.PlusOrConcatExpr(this.visit(ctx._left), this.visit(ctx._right));
236
236
  }
237
237
  throw new ExpressionTypeError_js_1.ExpressionTypeError("Operator '+' requires the operands to be either both of type numeric or both of type string, but they are not.", ctx);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ExprVisitor.ts"],"names":[],"mappings":";;;;;;AAAA,mGAAwE;AACxE,sFAAgF;AA8BhF,mEAA+D;AAC/D,4DAAiC;AACjC,kEAA4D;AAC5D,oEAA8D;AAE9D,0EAAoE;AACpE,sEAAgE;AAChE,kGAA4F;AAC5F,kGAA4F;AAC5F,mFAA6E;AAC7E,sEAAgE;AAChE,2EAAqE;AACrE,oEAA8D;AAC9D,8EAAwE;AACxE,gEAA0D;AAC1D,sFAAgF;AAChF,8DAAwD;AACxD,gEAA0D;AAC1D,6EAAuE;AACvE,gEAA0D;AAC1D,kFAA4E;AAC5E,yEAAmE;AACnE,+EAAyE;AAEzE,iFAA2E;AAC3E,+EAAyE;AACzE,2EAAqE;AACrE,2EAAqE;AACrE,yFAAmF;AACnF,qEAA+D;AAC/D,mFAA6E;AAE7E,MAAa,WAAY,SAAQ,iCAA+B;IAI9D,YAAY,WAAwB;QAClC,KAAK,EAAE,CAAC;QAJO,0BAAqB,GAAG,EAAE,CAAC;QAQ5C,cAAS,GAAoC,CAAC,GAAG,EAAE,EAAE;YACnD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACtC,CAAC,CAAC;QAEF;;0DAEkD;QAElD,qBAAgB,GAA2C,CAAC,GAAG,EAAE,EAAE;YACjE,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,KAAK,UAAU,EAAE;gBAC3D,OAAO,IAAI,oDAA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;SACpE;QACD,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE;YACpD,OAAO,IAAI,sCAAgB,CACzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CACvB,CAAC;SACH;QACD,IACE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC;YAChD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EACjD;YACA,OAAO,IAAI,sCAAgB,CACzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CACvB,CAAC;SACH;QACD,MAAM,IAAI,4CAAmB,CAC3B,gHAAgH,EAChH,GAAG,CACJ,CAAC;IACJ,CAAC;IAuJO,MAAM,CAAC,QAAQ,CAAC,GAAsB;QAC5C,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;CAKF;AAtSD,kCAsSC","file":"ExprVisitor.js","sourcesContent":["import IfcExpressionVisitor from \"./gen/parser/IfcExpressionVisitor.js\";\nimport { NumericLiteralExpr } from \"./expression/numeric/NumericLiteralExpr.js\";\nimport {\n ArrayElementListContext,\n ArrayExprContext,\n BooleanLiteralContext,\n ExprContext,\n ExprListContext,\n FunctionCallContext,\n LiteralContext,\n MethodCallChainEndContext,\n MethodCallChainInnerContext,\n NumLiteralContext,\n SEAddSubContext,\n SEArrayExprContext,\n SEBooleanBinaryOpContext,\n SEComparisonContext,\n SEFunctionCallContext,\n SELiteralContext,\n SEMethodCallContext,\n SEMulDivContext,\n SENotContext,\n SEParenthesisContext,\n SEPowerContext,\n SEUnaryMinusContext,\n SEUnaryMultipleMinusContext,\n SEVariableRefContext,\n StringLiteralContext,\n VariableRefContext,\n} from \"./gen/parser/IfcExpressionParser.js\";\nimport { Expr } from \"./expression/Expr.js\";\nimport { isNullish, isPresent } from \"./IfcExpressionUtils.js\";\nimport Decimal from \"decimal.js\";\nimport { PlusExpr } from \"./expression/numeric/PlusExpr.js\";\nimport { MinusExpr } from \"./expression/numeric/MinusExpr.js\";\nimport { ParserRuleContext } from \"antlr4\";\nimport { MultiplyExpr } from \"./expression/numeric/MultiplyExpr.js\";\nimport { DivideExpr } from \"./expression/numeric/DivideExpr.js\";\nimport { PropObjectReferenceExpr } from \"./expression/reference/PropObjectReferenceExpr.js\";\nimport { ElemObjectReferenceExpr } from \"./expression/reference/ElemObjectReferenceExpr.js\";\nimport { StringLiteralExpr } from \"./expression/string/StringLiteralExpr.js\";\nimport { ArrayExpr } from \"./expression/structure/ArrayExpr.js\";\nimport { FunctionExpr } from \"./expression/function/FunctionExpr.js\";\nimport { PowerExpr } from \"./expression/numeric/PowerExpr.js\";\nimport { UnaryMinusExpr } from \"./expression/numeric/UnaryMinusExpr.js\";\nimport { AndExpr } from \"./expression/boolean/AndExpr.js\";\nimport { BooleanLiteralExpr } from \"./expression/boolean/BooleanLiteralExpr.js\";\nimport { OrExpr } from \"./expression/boolean/OrExpr.js\";\nimport { XorExpr } from \"./expression/boolean/XorExpr.js\";\nimport { SyntaxErrorException } from \"./error/SyntaxErrorException.js\";\nimport { NotExpr } from \"./expression/boolean/NotExpr.js\";\nimport { ParenthesisExpr } from \"./expression/structure/ParenthesisExpr.js\";\nimport { EqualsExpr } from \"./expression/comparison/EqualsExpr.js\";\nimport { NotEqualsExpr } from \"./expression/comparison/NotEqualsExpr.js\";\nimport { TypeManager } from \"./type/TypeManager.js\";\nimport { StringConcatExpr } from \"./expression/string/StringConcatExpr.js\";\nimport { PlusOrConcatExpr } from \"./expression/poly/PlusOrConcatExpr.js\";\nimport { ExpressionTypeError } from \"./error/ExpressionTypeError.js\";\nimport { GreaterThan } from \"./expression/comparison/GreaterThan.js\";\nimport { GreaterThanOrEqual } from \"./expression/comparison/GreaterThanOrEqual.js\";\nimport { LessThan } from \"./expression/comparison/LessThan.js\";\nimport { LessThanOrEqual } from \"./expression/comparison/LessThanOrEqual.js\";\n\nexport class ExprVisitor extends IfcExpressionVisitor<Expr<any>> {\n private readonly methodCallTargetStack = [];\n private readonly typeManager: TypeManager;\n\n constructor(typeManager: TypeManager) {\n super();\n this.typeManager = typeManager;\n }\n\n visitExpr: (ctx: ExprContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.singleExpr());\n };\n\n /*================================================\n * VariableRef\n *==============================================*/\n\n visitVariableRef: (ctx: VariableRefContext) => Expr<any> = (ctx) => {\n if (ctx.IDENTIFIER().getText().toUpperCase() === \"PROPERTY\") {\n return new PropObjectReferenceExpr();\n } else if (ctx.IDENTIFIER().getText().toUpperCase() === \"ELEMENT\") {\n return new ElemObjectReferenceExpr();\n }\n throw new Error(`Parsing error: No variable '${ctx.getText()}' found `);\n };\n\n visitSEComparison: (ctx: SEComparisonContext) => Expr<any> = (ctx) => {\n const left = this.visit(ctx.singleExpr(0));\n const right = this.visit(ctx.singleExpr(1));\n switch (ctx.CMP_OP().getText()) {\n case \"==\":\n return new EqualsExpr(left, right);\n case \"!=\":\n return new NotEqualsExpr(left, right);\n case \">\":\n return new GreaterThan(left, right);\n case \">=\":\n return new GreaterThanOrEqual(left, right);\n case \"<\":\n return new LessThan(left, right);\n case \"<=\":\n return new LessThanOrEqual(left, right);\n }\n throw new Error(\n `Parsing error: comparison operator '${ctx\n .CMP_OP()\n .getText()}' not supported`\n );\n };\n\n visitSEMethodCall: (ctx: SEMethodCallContext) => Expr<any> = (ctx) => {\n this.methodCallTargetStack.push(this.visit(ctx.singleExpr()));\n return this.visit(ctx.methodCallChain());\n };\n\n visitSELiteral: (ctx: SELiteralContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.literal());\n };\n\n visitSEVariableRef: (ctx: SEVariableRefContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.variableRef());\n };\n visitSEArrayExpr: (ctx: SEArrayExprContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.arrayExpr());\n };\n visitSEFunctionCall: (ctx: SEFunctionCallContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.functionCall());\n };\n visitSEParenthesis: (ctx: SEParenthesisContext) => Expr<any> = (ctx) => {\n return new ParenthesisExpr(this.visit(ctx._sub));\n };\n\n /*================================================\n * MethodCallChain\n *==============================================*/\n\n visitMethodCallChainInner: (ctx: MethodCallChainInnerContext) => Expr<any> = (\n ctx\n ) => {\n this.methodCallTargetStack.push(\n new FunctionExpr(\n ctx.functionCall().IDENTIFIER().getText(),\n this.collectFunctionArguments(ctx.functionCall().exprList(), [\n this.methodCallTargetStack.pop(),\n ])\n )\n );\n return this.visit(ctx.methodCallChain());\n };\n\n visitMethodCallChainEnd: (ctx: MethodCallChainEndContext) => Expr<any> = (\n ctx\n ) => {\n return new FunctionExpr(\n ctx.functionCall().IDENTIFIER().getText(),\n this.collectFunctionArguments(ctx.functionCall().exprList(), [\n this.methodCallTargetStack.pop(),\n ])\n );\n };\n\n visitSEAddSub: (ctx: SEAddSubContext) => Expr<any> = (ctx) => {\n this.typeManager.requireTypesOverlap(ctx._left, ctx._right);\n switch (ctx._op.text) {\n case \"+\":\n return this.makePlusExpr(ctx);\n case \"-\":\n return new MinusExpr(this.visit(ctx._left), this.visit(ctx._right));\n default:\n ExprVisitor.failNode(ctx);\n }\n };\n\n private makePlusExpr(ctx: SEAddSubContext) {\n if (this.typeManager.isNumeric(ctx._left, ctx._right)) {\n return new PlusExpr(this.visit(ctx._left), this.visit(ctx._right));\n }\n if (this.typeManager.isString(ctx._left, ctx._right)) {\n return new StringConcatExpr(\n this.visit(ctx._left),\n this.visit(ctx._right)\n );\n }\n if (\n this.typeManager.isString(ctx._left, ctx._right) ||\n this.typeManager.isNumeric(ctx._left, ctx._right)\n ) {\n return new PlusOrConcatExpr(\n this.visit(ctx._left),\n this.visit(ctx._right)\n );\n }\n throw new ExpressionTypeError(\n \"Operator '+' requires the operands to be either both of type numeric or both of type string, but they are not.\",\n ctx\n );\n }\n\n visitSEMulDiv: (ctx: SEMulDivContext) => Expr<any> = (ctx) => {\n switch (ctx._op.text) {\n case \"*\":\n return new MultiplyExpr(\n this.visit(ctx.getChild(0)),\n this.visit(ctx.getChild(2))\n );\n case \"/\":\n return new DivideExpr(\n this.visit(ctx.getChild(0)),\n this.visit(ctx.getChild(2))\n );\n default:\n ExprVisitor.failNode(ctx);\n }\n };\n\n /*================================================\n * StringExpr\n *===============================================*/\n\n visitStringLiteral: (ctx: StringLiteralContext) => Expr<any> = (ctx) => {\n const quotedString = ctx.QUOTED_STRING().getText();\n const text = quotedString.substring(1, quotedString.length - 1);\n return new StringLiteralExpr(text);\n };\n\n /*================================================\n * NumExpr\n *===============================================*/\n\n visitNumLiteral: (ctx: NumLiteralContext) => Expr<any> = (ctx) => {\n let val = ctx.INT();\n if (isPresent(val)) {\n return new NumericLiteralExpr(new Decimal(ctx.getText()));\n }\n val = ctx.FLOAT();\n if (isPresent(val)) {\n return new NumericLiteralExpr(new Decimal(ctx.getText()));\n }\n ExprVisitor.failNode(ctx);\n };\n\n visitSEUnaryMultipleMinus: (ctx: SEUnaryMultipleMinusContext) => Expr<any> = (\n ctx\n ) => {\n return this.visit(ctx.singleExpr());\n };\n visitSEPower: (ctx: SEPowerContext) => Expr<any> = (ctx) => {\n return new PowerExpr(\n this.visit(ctx.getChild(0)),\n this.visit(ctx.getChild(1))\n );\n };\n visitSEUnaryMinus: (ctx: SEUnaryMinusContext) => Expr<any> = (ctx) => {\n return new UnaryMinusExpr(this.visit(ctx.singleExpr()));\n };\n\n /*================================================\n * BooleanExpr\n *===============================================*/\n\n visitSEBooleanBinaryOp: (ctx: SEBooleanBinaryOpContext) => Expr<any> = (\n ctx\n ) => {\n switch (ctx._op.text) {\n case \"&&\":\n return new AndExpr(\n this.visit(ctx.singleExpr(0)),\n this.visit(ctx.singleExpr(1))\n );\n case \"||\":\n return new OrExpr(\n this.visit(ctx.singleExpr(0)),\n this.visit(ctx.singleExpr(1))\n );\n case \"><\":\n return new XorExpr(\n this.visit(ctx.singleExpr(0)),\n this.visit(ctx.singleExpr(1))\n );\n }\n throw new SyntaxErrorException(\n ctx._op.text,\n ctx._op.line,\n ctx._op.column,\n `Unknown boolean operator ${ctx._op.text}`\n );\n };\n\n visitBooleanLiteral: (ctx: BooleanLiteralContext) => Expr<any> = (ctx) => {\n return new BooleanLiteralExpr(\n ctx.BOOLEAN().getText().toUpperCase() === \"TRUE\"\n );\n };\n\n visitSENot: (ctx: SENotContext) => Expr<any> = (ctx) => {\n return new NotExpr(this.visit(ctx.singleExpr()));\n };\n\n /*================================================\n * ArrayExpr\n *===============================================*/\n\n visitArrayExpr: (ctx: ArrayExprContext) => Expr<any> = (ctx) => {\n return new ArrayExpr(this.collectArrayElements(ctx.arrayElementList()));\n };\n\n collectArrayElements: (ctx: ArrayElementListContext) => Array<Expr<any>> = (\n ctx\n ) => {\n const first = this.visit(ctx.singleExpr());\n const rest = ctx.arrayElementList();\n if (!isNullish(rest)) {\n const arr = this.collectArrayElements(rest);\n arr.unshift(first);\n return arr;\n }\n return [first];\n };\n\n /*================================================\n * FuncExpr\n *===============================================*/\n\n visitFunctionCall: (ctx: FunctionCallContext) => Expr<any> = (ctx) => {\n const args = isNullish(ctx.exprList())\n ? []\n : this.collectFunctionArguments(ctx.exprList());\n return new FunctionExpr(ctx.IDENTIFIER().getText(), args);\n };\n\n collectFunctionArguments: (\n ctx: ExprListContext,\n resultSoFar?: Array<Expr<any>>\n ) => Array<Expr<any>> = (ctx, resultSoFar?: Array<Expr<any>>) => {\n if (isNullish(resultSoFar)) {\n resultSoFar = [];\n }\n if (!isNullish(ctx)) {\n resultSoFar.push(this.visit(ctx.singleExpr()));\n const rest = ctx.exprList();\n if (!isNullish(rest)) {\n return this.collectFunctionArguments(rest, resultSoFar);\n }\n }\n return resultSoFar;\n };\n\n private static failNode(ctx: ParserRuleContext) {\n throw new Error(`Cannot parse (sub)expression ${ctx.getText()}`);\n }\n\n visitLiteral: (ctx: LiteralContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.getChild(0));\n };\n}\n"]}
1
+ {"version":3,"sources":["../../src/ExprVisitor.ts"],"names":[],"mappings":";;;;;;AAAA,mGAAwE;AACxE,sFAAgF;AA8BhF,mEAA+D;AAC/D,4DAAiC;AACjC,kEAA4D;AAC5D,oEAA8D;AAE9D,0EAAoE;AACpE,sEAAgE;AAChE,kGAA4F;AAC5F,kGAA4F;AAC5F,mFAA6E;AAC7E,sEAAgE;AAChE,2EAAqE;AACrE,oEAA8D;AAC9D,8EAAwE;AACxE,gEAA0D;AAC1D,sFAAgF;AAChF,8DAAwD;AACxD,gEAA0D;AAC1D,6EAAuE;AACvE,gEAA0D;AAC1D,kFAA4E;AAC5E,yEAAmE;AACnE,+EAAyE;AAEzE,iFAA2E;AAC3E,+EAAyE;AACzE,2EAAqE;AACrE,2EAAqE;AACrE,yFAAmF;AACnF,qEAA+D;AAC/D,mFAA6E;AAE7E,MAAa,WAAY,SAAQ,iCAA+B;IAI9D,YAAY,WAAwB;QAClC,KAAK,EAAE,CAAC;QAJO,0BAAqB,GAAG,EAAE,CAAC;QAQ5C,cAAS,GAAoC,CAAC,GAAG,EAAE,EAAE;YACnD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;QACtC,CAAC,CAAC;QAEF;;0DAEkD;QAElD,qBAAgB,GAA2C,CAAC,GAAG,EAAE,EAAE;YACjE,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,KAAK,UAAU,EAAE;gBAC3D,OAAO,IAAI,oDAAuB,EAAE,CAAC;aACtC;iBAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE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AE,GAAG,CAAC,MAAM,CAAC,EAAE;YACpD,OAAO,IAAI,sCAAgB,CACzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CACvB,CAAC;SACH;QACD,IACE,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC;YAC1D,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EAC3D;YACA,OAAO,IAAI,sCAAgB,CACzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CACvB,CAAC;SACH;QACD,MAAM,IAAI,4CAAmB,CAC3B,gHAAgH,EAChH,GAAG,CACJ,CAAC;IACJ,CAAC;IAuJO,MAAM,CAAC,QAAQ,CAAC,GAAsB;QAC5C,MAAM,IAAI,KAAK,CAAC,gCAAgC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;CAKF;AAtSD,kCAsSC","file":"ExprVisitor.js","sourcesContent":["import IfcExpressionVisitor from \"./gen/parser/IfcExpressionVisitor.js\";\nimport { NumericLiteralExpr } from \"./expression/numeric/NumericLiteralExpr.js\";\nimport {\n ArrayElementListContext,\n ArrayExprContext,\n BooleanLiteralContext,\n ExprContext,\n ExprListContext,\n FunctionCallContext,\n LiteralContext,\n MethodCallChainEndContext,\n MethodCallChainInnerContext,\n NumLiteralContext,\n SEAddSubContext,\n SEArrayExprContext,\n SEBooleanBinaryOpContext,\n SEComparisonContext,\n SEFunctionCallContext,\n SELiteralContext,\n SEMethodCallContext,\n SEMulDivContext,\n SENotContext,\n SEParenthesisContext,\n SEPowerContext,\n SEUnaryMinusContext,\n SEUnaryMultipleMinusContext,\n SEVariableRefContext,\n StringLiteralContext,\n VariableRefContext,\n} from \"./gen/parser/IfcExpressionParser.js\";\nimport { Expr } from \"./expression/Expr.js\";\nimport { isNullish, isPresent } from \"./IfcExpressionUtils.js\";\nimport Decimal from \"decimal.js\";\nimport { PlusExpr } from \"./expression/numeric/PlusExpr.js\";\nimport { MinusExpr } from \"./expression/numeric/MinusExpr.js\";\nimport { ParserRuleContext } from \"antlr4\";\nimport { MultiplyExpr } from \"./expression/numeric/MultiplyExpr.js\";\nimport { DivideExpr } from \"./expression/numeric/DivideExpr.js\";\nimport { PropObjectReferenceExpr } from \"./expression/reference/PropObjectReferenceExpr.js\";\nimport { ElemObjectReferenceExpr } from \"./expression/reference/ElemObjectReferenceExpr.js\";\nimport { StringLiteralExpr } from \"./expression/string/StringLiteralExpr.js\";\nimport { ArrayExpr } from \"./expression/structure/ArrayExpr.js\";\nimport { FunctionExpr } from \"./expression/function/FunctionExpr.js\";\nimport { PowerExpr } from \"./expression/numeric/PowerExpr.js\";\nimport { UnaryMinusExpr } from \"./expression/numeric/UnaryMinusExpr.js\";\nimport { AndExpr } from \"./expression/boolean/AndExpr.js\";\nimport { BooleanLiteralExpr } from \"./expression/boolean/BooleanLiteralExpr.js\";\nimport { OrExpr } from \"./expression/boolean/OrExpr.js\";\nimport { XorExpr } from \"./expression/boolean/XorExpr.js\";\nimport { SyntaxErrorException } from \"./error/SyntaxErrorException.js\";\nimport { NotExpr } from \"./expression/boolean/NotExpr.js\";\nimport { ParenthesisExpr } from \"./expression/structure/ParenthesisExpr.js\";\nimport { EqualsExpr } from \"./expression/comparison/EqualsExpr.js\";\nimport { NotEqualsExpr } from \"./expression/comparison/NotEqualsExpr.js\";\nimport { TypeManager } from \"./type/TypeManager.js\";\nimport { StringConcatExpr } from \"./expression/string/StringConcatExpr.js\";\nimport { PlusOrConcatExpr } from \"./expression/poly/PlusOrConcatExpr.js\";\nimport { ExpressionTypeError } from \"./error/ExpressionTypeError.js\";\nimport { GreaterThan } from \"./expression/comparison/GreaterThan.js\";\nimport { GreaterThanOrEqual } from \"./expression/comparison/GreaterThanOrEqual.js\";\nimport { LessThan } from \"./expression/comparison/LessThan.js\";\nimport { LessThanOrEqual } from \"./expression/comparison/LessThanOrEqual.js\";\n\nexport class ExprVisitor extends IfcExpressionVisitor<Expr<any>> {\n private readonly methodCallTargetStack = [];\n private readonly typeManager: TypeManager;\n\n constructor(typeManager: TypeManager) {\n super();\n this.typeManager = typeManager;\n }\n\n visitExpr: (ctx: ExprContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.singleExpr());\n };\n\n /*================================================\n * VariableRef\n *==============================================*/\n\n visitVariableRef: (ctx: VariableRefContext) => Expr<any> = (ctx) => {\n if (ctx.IDENTIFIER().getText().toUpperCase() === \"PROPERTY\") {\n return new PropObjectReferenceExpr();\n } else if (ctx.IDENTIFIER().getText().toUpperCase() === \"ELEMENT\") {\n return new ElemObjectReferenceExpr();\n }\n throw new Error(`Parsing error: No variable '${ctx.getText()}' found `);\n };\n\n visitSEComparison: (ctx: SEComparisonContext) => Expr<any> = (ctx) => {\n const left = this.visit(ctx.singleExpr(0));\n const right = this.visit(ctx.singleExpr(1));\n switch (ctx.CMP_OP().getText()) {\n case \"==\":\n return new EqualsExpr(left, right);\n case \"!=\":\n return new NotEqualsExpr(left, right);\n case \">\":\n return new GreaterThan(left, right);\n case \">=\":\n return new GreaterThanOrEqual(left, right);\n case \"<\":\n return new LessThan(left, right);\n case \"<=\":\n return new LessThanOrEqual(left, right);\n }\n throw new Error(\n `Parsing error: comparison operator '${ctx\n .CMP_OP()\n .getText()}' not supported`\n );\n };\n\n visitSEMethodCall: (ctx: SEMethodCallContext) => Expr<any> = (ctx) => {\n this.methodCallTargetStack.push(this.visit(ctx.singleExpr()));\n return this.visit(ctx.methodCallChain());\n };\n\n visitSELiteral: (ctx: SELiteralContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.literal());\n };\n\n visitSEVariableRef: (ctx: SEVariableRefContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.variableRef());\n };\n visitSEArrayExpr: (ctx: SEArrayExprContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.arrayExpr());\n };\n visitSEFunctionCall: (ctx: SEFunctionCallContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.functionCall());\n };\n visitSEParenthesis: (ctx: SEParenthesisContext) => Expr<any> = (ctx) => {\n return new ParenthesisExpr(this.visit(ctx._sub));\n };\n\n /*================================================\n * MethodCallChain\n *==============================================*/\n\n visitMethodCallChainInner: (ctx: MethodCallChainInnerContext) => Expr<any> = (\n ctx\n ) => {\n this.methodCallTargetStack.push(\n new FunctionExpr(\n ctx.functionCall().IDENTIFIER().getText(),\n this.collectFunctionArguments(ctx.functionCall().exprList(), [\n this.methodCallTargetStack.pop(),\n ])\n )\n );\n return this.visit(ctx.methodCallChain());\n };\n\n visitMethodCallChainEnd: (ctx: MethodCallChainEndContext) => Expr<any> = (\n ctx\n ) => {\n return new FunctionExpr(\n ctx.functionCall().IDENTIFIER().getText(),\n this.collectFunctionArguments(ctx.functionCall().exprList(), [\n this.methodCallTargetStack.pop(),\n ])\n );\n };\n\n visitSEAddSub: (ctx: SEAddSubContext) => Expr<any> = (ctx) => {\n this.typeManager.requireTypesOverlap(ctx._left, ctx._right);\n switch (ctx._op.text) {\n case \"+\":\n return this.makePlusExpr(ctx);\n case \"-\":\n return new MinusExpr(this.visit(ctx._left), this.visit(ctx._right));\n default:\n ExprVisitor.failNode(ctx);\n }\n };\n\n private makePlusExpr(ctx: SEAddSubContext) {\n if (this.typeManager.isNumeric(ctx._left, ctx._right)) {\n return new PlusExpr(this.visit(ctx._left), this.visit(ctx._right));\n }\n if (this.typeManager.isString(ctx._left, ctx._right)) {\n return new StringConcatExpr(\n this.visit(ctx._left),\n this.visit(ctx._right)\n );\n }\n if (\n this.typeManager.overlapsWithString(ctx._left, ctx._right) ||\n this.typeManager.overlapsWithNumeric(ctx._left, ctx._right)\n ) {\n return new PlusOrConcatExpr(\n this.visit(ctx._left),\n this.visit(ctx._right)\n );\n }\n throw new ExpressionTypeError(\n \"Operator '+' requires the operands to be either both of type numeric or both of type string, but they are not.\",\n ctx\n );\n }\n\n visitSEMulDiv: (ctx: SEMulDivContext) => Expr<any> = (ctx) => {\n switch (ctx._op.text) {\n case \"*\":\n return new MultiplyExpr(\n this.visit(ctx.getChild(0)),\n this.visit(ctx.getChild(2))\n );\n case \"/\":\n return new DivideExpr(\n this.visit(ctx.getChild(0)),\n this.visit(ctx.getChild(2))\n );\n default:\n ExprVisitor.failNode(ctx);\n }\n };\n\n /*================================================\n * StringExpr\n *===============================================*/\n\n visitStringLiteral: (ctx: StringLiteralContext) => Expr<any> = (ctx) => {\n const quotedString = ctx.QUOTED_STRING().getText();\n const text = quotedString.substring(1, quotedString.length - 1);\n return new StringLiteralExpr(text);\n };\n\n /*================================================\n * NumExpr\n *===============================================*/\n\n visitNumLiteral: (ctx: NumLiteralContext) => Expr<any> = (ctx) => {\n let val = ctx.INT();\n if (isPresent(val)) {\n return new NumericLiteralExpr(new Decimal(ctx.getText()));\n }\n val = ctx.FLOAT();\n if (isPresent(val)) {\n return new NumericLiteralExpr(new Decimal(ctx.getText()));\n }\n ExprVisitor.failNode(ctx);\n };\n\n visitSEUnaryMultipleMinus: (ctx: SEUnaryMultipleMinusContext) => Expr<any> = (\n ctx\n ) => {\n return this.visit(ctx.singleExpr());\n };\n visitSEPower: (ctx: SEPowerContext) => Expr<any> = (ctx) => {\n return new PowerExpr(\n this.visit(ctx.getChild(0)),\n this.visit(ctx.getChild(1))\n );\n };\n visitSEUnaryMinus: (ctx: SEUnaryMinusContext) => Expr<any> = (ctx) => {\n return new UnaryMinusExpr(this.visit(ctx.singleExpr()));\n };\n\n /*================================================\n * BooleanExpr\n *===============================================*/\n\n visitSEBooleanBinaryOp: (ctx: SEBooleanBinaryOpContext) => Expr<any> = (\n ctx\n ) => {\n switch (ctx._op.text) {\n case \"&&\":\n return new AndExpr(\n this.visit(ctx.singleExpr(0)),\n this.visit(ctx.singleExpr(1))\n );\n case \"||\":\n return new OrExpr(\n this.visit(ctx.singleExpr(0)),\n this.visit(ctx.singleExpr(1))\n );\n case \"><\":\n return new XorExpr(\n this.visit(ctx.singleExpr(0)),\n this.visit(ctx.singleExpr(1))\n );\n }\n throw new SyntaxErrorException(\n ctx._op.text,\n ctx._op.line,\n ctx._op.column,\n `Unknown boolean operator ${ctx._op.text}`\n );\n };\n\n visitBooleanLiteral: (ctx: BooleanLiteralContext) => Expr<any> = (ctx) => {\n return new BooleanLiteralExpr(\n ctx.BOOLEAN().getText().toUpperCase() === \"TRUE\"\n );\n };\n\n visitSENot: (ctx: SENotContext) => Expr<any> = (ctx) => {\n return new NotExpr(this.visit(ctx.singleExpr()));\n };\n\n /*================================================\n * ArrayExpr\n *===============================================*/\n\n visitArrayExpr: (ctx: ArrayExprContext) => Expr<any> = (ctx) => {\n return new ArrayExpr(this.collectArrayElements(ctx.arrayElementList()));\n };\n\n collectArrayElements: (ctx: ArrayElementListContext) => Array<Expr<any>> = (\n ctx\n ) => {\n const first = this.visit(ctx.singleExpr());\n const rest = ctx.arrayElementList();\n if (!isNullish(rest)) {\n const arr = this.collectArrayElements(rest);\n arr.unshift(first);\n return arr;\n }\n return [first];\n };\n\n /*================================================\n * FuncExpr\n *===============================================*/\n\n visitFunctionCall: (ctx: FunctionCallContext) => Expr<any> = (ctx) => {\n const args = isNullish(ctx.exprList())\n ? []\n : this.collectFunctionArguments(ctx.exprList());\n return new FunctionExpr(ctx.IDENTIFIER().getText(), args);\n };\n\n collectFunctionArguments: (\n ctx: ExprListContext,\n resultSoFar?: Array<Expr<any>>\n ) => Array<Expr<any>> = (ctx, resultSoFar?: Array<Expr<any>>) => {\n if (isNullish(resultSoFar)) {\n resultSoFar = [];\n }\n if (!isNullish(ctx)) {\n resultSoFar.push(this.visit(ctx.singleExpr()));\n const rest = ctx.exprList();\n if (!isNullish(rest)) {\n return this.collectFunctionArguments(rest, resultSoFar);\n }\n }\n return resultSoFar;\n };\n\n private static failNode(ctx: ParserRuleContext) {\n throw new Error(`Cannot parse (sub)expression ${ctx.getText()}`);\n }\n\n visitLiteral: (ctx: LiteralContext) => Expr<any> = (ctx) => {\n return this.visit(ctx.getChild(0));\n };\n}\n"]}
@@ -92,10 +92,10 @@ class IfcExpressionValidationListener extends IfcExpressionListener_js_1.default
92
92
  this.typeManager.setType(ctx, Types_js_1.Types.numeric());
93
93
  };
94
94
  this.exitSEAddSub = (ctx) => {
95
- if (this.typeManager.isString(ctx._left, ctx._right)) {
95
+ if (this.typeManager.overlapsWithString(ctx._left, ctx._right)) {
96
96
  this.typeManager.setType(ctx, Types_js_1.Types.string());
97
97
  }
98
- else if (this.typeManager.isNumeric(ctx._left, ctx._right)) {
98
+ else if (this.typeManager.overlapsWithNumeric(ctx._left, ctx._right)) {
99
99
  this.typeManager.setType(ctx, Types_js_1.Types.numeric());
100
100
  }
101
101
  else {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/IfcExpressionValidationListener.ts"],"names":[],"mappings":";;;;;;AAAA,qGAA0E;AAC1E,gFA2B6C;AAC7C,+FAAyF;AACzF,mFAA6E;AAC7E,iFAA2E;AAC3E,8CAA8C;AAE9C,0DAAoD;AACpD,2EAAqE;AACrE,mEAAoD;AACpD,2EAAqE;AAGrE,MAAa,+BAAgC,SAAQ,kCAAqB;IAGxE;QACE,KAAK,EAAE,CAAC;QAFF,0BAAqB,GAAG,EAAE,CAAC;QAUnC,sBAAiB,GAAuC,CAAC,GAAG,EAAE,EAAE;YAC9D,IAAI,CAAC,kDAAsB,CAAC,iBAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE;gBACzE,MAAM,IAAI,oDAAuB,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;aACpE;QACH,CAAC,CAAC;QAEF,8BAAyB,GAA+C,CACtE,GAAG,EACH,EAAE;YACF,MAAM,IAAI,kDAAsB,CAA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,CAAC,qBAAqB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC7C;aAAM;YACL,MAAM,IAAI,4CAAmB,CAC3B,yEAAyE,EACzE,GAAG,CACJ,CAAC;SACH;IACH,CAAC;CAsEF;AA1ND,0EA0NC","file":"IfcExpressionValidationListener.js","sourcesContent":["import IfcExpressionListener from \"./gen/parser/IfcExpressionListener.js\";\nimport {\n ArrayElementListContext,\n ArrayExprContext,\n BooleanLiteralContext,\n ExprContext,\n ExprListContext,\n FunctionCallContext,\n LiteralContext,\n MethodCallChainEndContext,\n MethodCallChainInnerContext,\n NumLiteralContext,\n SEAddSubContext,\n SEArrayExprContext,\n SEBooleanBinaryOpContext,\n SEComparisonContext,\n SEFunctionCallContext,\n SELiteralContext,\n SEMethodCallContext,\n SEMulDivContext,\n SENotContext,\n SEParenthesisContext,\n SEPowerContext,\n SEUnaryMinusContext,\n SEUnaryMultipleMinusContext,\n SEVariableRefContext,\n StringLiteralContext,\n VariableRefContext,\n} from \"./gen/parser/IfcExpressionParser.js\";\nimport { IfcExpressionFunctions } from \"./expression/function/IfcExpressionFunctions.js\";\nimport { NoSuchFunctionException } from \"./error/NoSuchFunctionException.js\";\nimport { InvalidSyntaxException } from \"./error/InvalidSyntaxException.js\";\nimport { Type, Types } from \"./type/Types.js\";\nimport { ParserRuleContext } from \"antlr4\";\nimport { TypeManager } from \"./type/TypeManager.js\";\nimport { ExpressionTypeError } from \"./error/ExpressionTypeError.js\";\nimport { isNullish } from \"./IfcExpressionUtils.js\";\nimport { ValidationException } from \"./error/ValidationException.js\";\nimport { ExprType } from \"./type/ExprType.js\";\n\nexport class IfcExpressionValidationListener extends IfcExpressionListener {\n private readonly typeManager: TypeManager;\n private methodCallTargetStack = [];\n constructor() {\n super();\n this.typeManager = new TypeManager();\n }\n\n public getTypeManager(): TypeManager {\n return this.typeManager;\n }\n\n enterFunctionCall: (ctx: FunctionCallContext) => void = (ctx) => {\n if (!IfcExpressionFunctions.isBuiltinFunction(ctx.IDENTIFIER().getText())) {\n throw new NoSuchFunctionException(ctx.IDENTIFIER().getText(), ctx);\n }\n };\n\n enterSEUnaryMultipleMinus: (ctx: SEUnaryMultipleMinusContext) => void = (\n ctx\n ) => {\n throw new InvalidSyntaxException(\"--\", ctx);\n };\n\n exitSEBooleanBinaryOp: (ctx: SEBooleanBinaryOpContext) => void = (ctx) => {\n this.typeManager.requireBoolean(ctx._left);\n this.typeManager.requireBoolean(ctx._right);\n this.typeManager.setType(ctx, Types.boolean());\n };\n\n exitSEComparison: (ctx: SEComparisonContext) => void = (ctx) => {\n this.typeManager.requireTypesOverlap(ctx._left, ctx._right);\n this.typeManager.setType(ctx, Types.boolean());\n };\n\n exitSEParenthesis: (ctx: SEParenthesisContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._sub);\n };\n\n exitSELiteral: (ctx: SELiteralContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._sub);\n };\n exitLiteral: (ctx: LiteralContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx.getChild(0) as ParserRuleContext);\n };\n exitNumLiteral: (ctx: NumLiteralContext) => void = (ctx) => {\n this.typeManager.setType(ctx, Types.numeric());\n };\n exitStringLiteral: (ctx: StringLiteralContext) => void = (ctx) => {\n this.typeManager.setType(ctx, Types.string());\n };\n\n exitBooleanLiteral: (ctx: BooleanLiteralContext) => void = (ctx) => {\n this.typeManager.setType(ctx, Types.boolean());\n };\n\n exitExpr: (ctx: ExprContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx.singleExpr());\n };\n\n exitSEMulDiv: (ctx: SEMulDivContext) => void = (ctx) => {\n this.typeManager.requireNumeric(ctx._left);\n this.typeManager.requireNumeric(ctx._right);\n this.typeManager.setType(ctx, Types.numeric());\n };\n\n exitSEPower: (ctx: SEPowerContext) => void = (ctx) => {\n this.typeManager.requireNumeric(ctx._left);\n this.typeManager.requireNumeric(ctx._right);\n this.typeManager.setType(ctx, Types.numeric());\n };\n exitSEFunctionCall: (ctx: SEFunctionCallContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._sub);\n };\n exitSEArrayExpr: (ctx: SEArrayExprContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._sub);\n };\n\n exitSENot: (ctx: SENotContext) => void = (ctx) => {\n this.typeManager.requireBoolean(ctx._sub);\n this.typeManager.setType(ctx, Types.boolean());\n };\n\n exitSEVariableRef: (ctx: SEVariableRefContext) => void = (ctx) => {\n switch (ctx._sub.IDENTIFIER().getText()) {\n case \"property\":\n this.typeManager.setType(ctx, Type.IFC_PROPERTY_REF);\n return;\n case \"element\":\n this.typeManager.setType(ctx, Type.IFC_ELEMENT_REF);\n return;\n }\n throw new ValidationException(\n `Encountered Variable ref that was neither $property nor $element`,\n ctx\n );\n };\n\n exitSEUnaryMinus: (ctx: SEUnaryMinusContext) => void = (ctx) => {\n this.typeManager.requireNumeric(ctx._sub);\n this.typeManager.setType(ctx, Types.numeric());\n };\n exitSEAddSub: (ctx: SEAddSubContext) => void = (ctx) => {\n if (this.typeManager.isString(ctx._left, ctx._right)) {\n this.typeManager.setType(ctx, Types.string());\n } else if (this.typeManager.isNumeric(ctx._left, ctx._right)) {\n this.typeManager.setType(ctx, Types.numeric());\n } else {\n throw new ExpressionTypeError(\n `Operator '+' does not allow provided operand types ${this.typeManager\n .getType(ctx._left)\n .getName()}(left operand) and ${this.typeManager\n .getType(ctx._right)\n .getName()}(right operand). Operands must be both string or both numeric.`,\n ctx\n );\n }\n };\n\n exitSEMethodCall: (ctx: SEMethodCallContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._call);\n };\n\n enterMethodCallChainInner: (ctx: MethodCallChainInnerContext) => void = (\n ctx\n ) => {\n this.pushMethodCallTarget(ctx);\n };\n exitMethodCallChainInner: (ctx: MethodCallChainInnerContext) => void = (\n ctx\n ) => {\n this.typeManager.copyTypeFrom(ctx, ctx._call);\n };\n\n enterMethodCallChainEnd: (ctx: MethodCallChainEndContext) => void = (ctx) => {\n this.pushMethodCallTarget(ctx);\n };\n\n private pushMethodCallTarget(ctx: ParserRuleContext) {\n if (ctx.parentCtx[\"_target\"]) {\n const targetType = this.typeManager.getType(ctx.parentCtx[\"_target\"]);\n this.methodCallTargetStack.push(targetType);\n } else {\n throw new ValidationException(\n \"Did not find expected context attribute 'target' in parent rule context\",\n ctx\n );\n }\n }\n\n exitMethodCallChainEnd: (ctx: MethodCallChainEndContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx.functionCall());\n };\n exitFunctionCall: (ctx: FunctionCallContext) => void = (ctx) => {\n const func = IfcExpressionFunctions.getFunction(ctx.IDENTIFIER().getText());\n const argumentTypes = this.collectArgumentTypes(ctx.exprList());\n const parent = ctx.parentCtx;\n if (\n parent instanceof MethodCallChainInnerContext ||\n parent instanceof MethodCallChainEndContext ||\n parent instanceof SEMethodCallContext\n ) {\n argumentTypes.unshift(this.methodCallTargetStack.pop());\n }\n const returnType = func.checkArgumentsAndGetReturnType(argumentTypes, ctx);\n this.typeManager.setType(ctx, returnType);\n };\n\n private collectArgumentTypes: (\n ctx: ExprListContext,\n resultSoFar?: Array<ExprType>\n ) => Array<ExprType> = (ctx, resultSoFar?: Array<ExprType>) => {\n if (isNullish(resultSoFar)) {\n resultSoFar = [];\n }\n if (!isNullish(ctx)) {\n resultSoFar.push(this.typeManager.getType(ctx.singleExpr()));\n const rest = ctx.exprList();\n if (!isNullish(rest)) {\n return this.collectArgumentTypes(rest, resultSoFar);\n }\n }\n return resultSoFar;\n };\n\n exitExprList: (ctx: ExprListContext) => void;\n\n exitArrayExpr: (ctx: ArrayExprContext) => void = (ctx) => {\n this.typeManager.setType(\n ctx,\n Types.tuple(...this.collectArrayElementTypes(ctx.arrayElementList()))\n );\n };\n\n private collectArrayElementTypes: (\n ctx: ArrayElementListContext,\n resultSoFar?: Array<ExprType>\n ) => Array<ExprType> = (ctx, resultSoFar?: Array<ExprType>) => {\n if (isNullish(resultSoFar)) {\n resultSoFar = [];\n }\n if (!isNullish(ctx)) {\n resultSoFar.push(this.typeManager.getType(ctx.singleExpr()));\n const rest = ctx.arrayElementList();\n if (!isNullish(rest)) {\n return this.collectArrayElementTypes(rest, resultSoFar);\n }\n }\n return resultSoFar;\n };\n\n exitArrayElementList: (ctx: ArrayElementListContext) => void;\n exitVariableRef: (ctx: VariableRefContext) => void = (ctx) => {\n this.typeManager.setType(\n ctx,\n Types.or(Type.IFC_PROPERTY_REF, Type.IFC_ELEMENT_REF)\n );\n };\n}\n"]}
1
+ {"version":3,"sources":["../../src/IfcExpressionValidationListener.ts"],"names":[],"mappings":";;;;;;AAAA,qGAA0E;AAC1E,gFA2B6C;AAC7C,+FAAyF;AACzF,mFAA6E;AAC7E,iFAA2E;AAC3E,8CAA8C;AAE9C,0DAAoD;AACpD,2EAAqE;AACrE,mEAAoD;AACpD,2EAAqE;AAGrE,MAAa,+BAAgC,SAAQ,kCAAqB;IAGxE;QACE,KAAK,EAAE,CAAC;QAFF,0BAAqB,GAAG,EAAE,CAAC;QAUnC,sBAAiB,GAAuC,CAAC,GAAG,EAAE,EAAE;YAC9D,IAAI,CAAC,kDAAsB,CAAC,iBAAiB,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE;gBACzE,MAAM,IAAI,oDAAuB,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;aACpE;QACH,CAAC,CAAC;QAEF,8BAAyB,GAA+C,CACtE,GAAG,EACH,EAAE;YACF,MAAM,IAAI,kDAAsB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC,CAAC;QAEF,0BAAqB,GAA4C,CAAC,GAAG,EAAE,EAAE;YACvE,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC3C,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,G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ener from \"./gen/parser/IfcExpressionListener.js\";\nimport {\n ArrayElementListContext,\n ArrayExprContext,\n BooleanLiteralContext,\n ExprContext,\n ExprListContext,\n FunctionCallContext,\n LiteralContext,\n MethodCallChainEndContext,\n MethodCallChainInnerContext,\n NumLiteralContext,\n SEAddSubContext,\n SEArrayExprContext,\n SEBooleanBinaryOpContext,\n SEComparisonContext,\n SEFunctionCallContext,\n SELiteralContext,\n SEMethodCallContext,\n SEMulDivContext,\n SENotContext,\n SEParenthesisContext,\n SEPowerContext,\n SEUnaryMinusContext,\n SEUnaryMultipleMinusContext,\n SEVariableRefContext,\n StringLiteralContext,\n VariableRefContext,\n} from \"./gen/parser/IfcExpressionParser.js\";\nimport { IfcExpressionFunctions } from \"./expression/function/IfcExpressionFunctions.js\";\nimport { NoSuchFunctionException } from \"./error/NoSuchFunctionException.js\";\nimport { InvalidSyntaxException } from \"./error/InvalidSyntaxException.js\";\nimport { Type, Types } from \"./type/Types.js\";\nimport { ParserRuleContext } from \"antlr4\";\nimport { TypeManager } from \"./type/TypeManager.js\";\nimport { ExpressionTypeError } from \"./error/ExpressionTypeError.js\";\nimport { isNullish } from \"./IfcExpressionUtils.js\";\nimport { ValidationException } from \"./error/ValidationException.js\";\nimport { ExprType } from \"./type/ExprType.js\";\n\nexport class IfcExpressionValidationListener extends IfcExpressionListener {\n private readonly typeManager: TypeManager;\n private methodCallTargetStack = [];\n constructor() {\n super();\n this.typeManager = new TypeManager();\n }\n\n public getTypeManager(): TypeManager {\n return this.typeManager;\n }\n\n enterFunctionCall: (ctx: FunctionCallContext) => void = (ctx) => {\n if (!IfcExpressionFunctions.isBuiltinFunction(ctx.IDENTIFIER().getText())) {\n throw new NoSuchFunctionException(ctx.IDENTIFIER().getText(), ctx);\n }\n };\n\n enterSEUnaryMultipleMinus: (ctx: SEUnaryMultipleMinusContext) => void = (\n ctx\n ) => {\n throw new InvalidSyntaxException(\"--\", ctx);\n };\n\n exitSEBooleanBinaryOp: (ctx: SEBooleanBinaryOpContext) => void = (ctx) => {\n this.typeManager.requireBoolean(ctx._left);\n this.typeManager.requireBoolean(ctx._right);\n this.typeManager.setType(ctx, Types.boolean());\n };\n\n exitSEComparison: (ctx: SEComparisonContext) => void = (ctx) => {\n this.typeManager.requireTypesOverlap(ctx._left, ctx._right);\n this.typeManager.setType(ctx, Types.boolean());\n };\n\n exitSEParenthesis: (ctx: SEParenthesisContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._sub);\n };\n\n exitSELiteral: (ctx: SELiteralContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._sub);\n };\n exitLiteral: (ctx: LiteralContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx.getChild(0) as ParserRuleContext);\n };\n exitNumLiteral: (ctx: NumLiteralContext) => void = (ctx) => {\n this.typeManager.setType(ctx, Types.numeric());\n };\n exitStringLiteral: (ctx: StringLiteralContext) => void = (ctx) => {\n this.typeManager.setType(ctx, Types.string());\n };\n\n exitBooleanLiteral: (ctx: BooleanLiteralContext) => void = (ctx) => {\n this.typeManager.setType(ctx, Types.boolean());\n };\n\n exitExpr: (ctx: ExprContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx.singleExpr());\n };\n\n exitSEMulDiv: (ctx: SEMulDivContext) => void = (ctx) => {\n this.typeManager.requireNumeric(ctx._left);\n this.typeManager.requireNumeric(ctx._right);\n this.typeManager.setType(ctx, Types.numeric());\n };\n\n exitSEPower: (ctx: SEPowerContext) => void = (ctx) => {\n this.typeManager.requireNumeric(ctx._left);\n this.typeManager.requireNumeric(ctx._right);\n this.typeManager.setType(ctx, Types.numeric());\n };\n exitSEFunctionCall: (ctx: SEFunctionCallContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._sub);\n };\n exitSEArrayExpr: (ctx: SEArrayExprContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._sub);\n };\n\n exitSENot: (ctx: SENotContext) => void = (ctx) => {\n this.typeManager.requireBoolean(ctx._sub);\n this.typeManager.setType(ctx, Types.boolean());\n };\n\n exitSEVariableRef: (ctx: SEVariableRefContext) => void = (ctx) => {\n switch (ctx._sub.IDENTIFIER().getText()) {\n case \"property\":\n this.typeManager.setType(ctx, Type.IFC_PROPERTY_REF);\n return;\n case \"element\":\n this.typeManager.setType(ctx, Type.IFC_ELEMENT_REF);\n return;\n }\n throw new ValidationException(\n `Encountered Variable ref that was neither $property nor $element`,\n ctx\n );\n };\n\n exitSEUnaryMinus: (ctx: SEUnaryMinusContext) => void = (ctx) => {\n this.typeManager.requireNumeric(ctx._sub);\n this.typeManager.setType(ctx, Types.numeric());\n };\n exitSEAddSub: (ctx: SEAddSubContext) => void = (ctx) => {\n if (this.typeManager.overlapsWithString(ctx._left, ctx._right)) {\n this.typeManager.setType(ctx, Types.string());\n } else if (this.typeManager.overlapsWithNumeric(ctx._left, ctx._right)) {\n this.typeManager.setType(ctx, Types.numeric());\n } else {\n throw new ExpressionTypeError(\n `Operator '+' does not allow provided operand types ${this.typeManager\n .getType(ctx._left)\n .getName()}(left operand) and ${this.typeManager\n .getType(ctx._right)\n .getName()}(right operand). Operands must be both string or both numeric.`,\n ctx\n );\n }\n };\n\n exitSEMethodCall: (ctx: SEMethodCallContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx._call);\n };\n\n enterMethodCallChainInner: (ctx: MethodCallChainInnerContext) => void = (\n ctx\n ) => {\n this.pushMethodCallTarget(ctx);\n };\n exitMethodCallChainInner: (ctx: MethodCallChainInnerContext) => void = (\n ctx\n ) => {\n this.typeManager.copyTypeFrom(ctx, ctx._call);\n };\n\n enterMethodCallChainEnd: (ctx: MethodCallChainEndContext) => void = (ctx) => {\n this.pushMethodCallTarget(ctx);\n };\n\n private pushMethodCallTarget(ctx: ParserRuleContext) {\n if (ctx.parentCtx[\"_target\"]) {\n const targetType = this.typeManager.getType(ctx.parentCtx[\"_target\"]);\n this.methodCallTargetStack.push(targetType);\n } else {\n throw new ValidationException(\n \"Did not find expected context attribute 'target' in parent rule context\",\n ctx\n );\n }\n }\n\n exitMethodCallChainEnd: (ctx: MethodCallChainEndContext) => void = (ctx) => {\n this.typeManager.copyTypeFrom(ctx, ctx.functionCall());\n };\n exitFunctionCall: (ctx: FunctionCallContext) => void = (ctx) => {\n const func = IfcExpressionFunctions.getFunction(ctx.IDENTIFIER().getText());\n const argumentTypes = this.collectArgumentTypes(ctx.exprList());\n const parent = ctx.parentCtx;\n if (\n parent instanceof MethodCallChainInnerContext ||\n parent instanceof MethodCallChainEndContext ||\n parent instanceof SEMethodCallContext\n ) {\n argumentTypes.unshift(this.methodCallTargetStack.pop());\n }\n const returnType = func.checkArgumentsAndGetReturnType(argumentTypes, ctx);\n this.typeManager.setType(ctx, returnType);\n };\n\n private collectArgumentTypes: (\n ctx: ExprListContext,\n resultSoFar?: Array<ExprType>\n ) => Array<ExprType> = (ctx, resultSoFar?: Array<ExprType>) => {\n if (isNullish(resultSoFar)) {\n resultSoFar = [];\n }\n if (!isNullish(ctx)) {\n resultSoFar.push(this.typeManager.getType(ctx.singleExpr()));\n const rest = ctx.exprList();\n if (!isNullish(rest)) {\n return this.collectArgumentTypes(rest, resultSoFar);\n }\n }\n return resultSoFar;\n };\n\n exitExprList: (ctx: ExprListContext) => void;\n\n exitArrayExpr: (ctx: ArrayExprContext) => void = (ctx) => {\n this.typeManager.setType(\n ctx,\n Types.tuple(...this.collectArrayElementTypes(ctx.arrayElementList()))\n );\n };\n\n private collectArrayElementTypes: (\n ctx: ArrayElementListContext,\n resultSoFar?: Array<ExprType>\n ) => Array<ExprType> = (ctx, resultSoFar?: Array<ExprType>) => {\n if (isNullish(resultSoFar)) {\n resultSoFar = [];\n }\n if (!isNullish(ctx)) {\n resultSoFar.push(this.typeManager.getType(ctx.singleExpr()));\n const rest = ctx.arrayElementList();\n if (!isNullish(rest)) {\n return this.collectArrayElementTypes(rest, resultSoFar);\n }\n }\n return resultSoFar;\n };\n\n exitArrayElementList: (ctx: ArrayElementListContext) => void;\n exitVariableRef: (ctx: VariableRefContext) => void = (ctx) => {\n this.typeManager.setType(\n ctx,\n Types.or(Type.IFC_PROPERTY_REF, Type.IFC_ELEMENT_REF)\n );\n };\n}\n"]}
@@ -20,7 +20,11 @@ class PlusOrConcatExpr extends Expr2_js_1.Expr2 {
20
20
  rightResult instanceof StringValue_js_1.StringValue) {
21
21
  return StringValue_js_1.StringValue.of(leftResult.getValue() + rightResult.getValue());
22
22
  }
23
- return new ExprEvalResult_js_1.ExprEvalTypeErrorObj(ExprKind_js_1.ExprKind.FUNCTION, "Operator '+' requires the operands to be either both of type numeric or both of type string, but they are not.", [leftResult, rightResult]);
23
+ return new ExprEvalResult_js_1.ExprEvalTypeErrorObj(ExprKind_js_1.ExprKind.FUNCTION, `Operator '+' requires the operands to be either both of type numeric or both of type string, but they are '${leftResult
24
+ .getType()
25
+ .getName()}' (left operand) and '${rightResult
26
+ .getType()
27
+ .getName()}' (right operand)`, [leftResult, rightResult]);
24
28
  }
25
29
  toExprString() {
26
30
  return `${this.left.toExprString()} + ${this.right.toExprString()}`;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expression/poly/PlusOrConcatExpr.ts"],"names":[],"mappings":";;;AAAA,0CAAoC;AAGpC,iEAA2D;AAC3D,gDAA0C;AAC1C,+DAAyD;AACzD,4DAA2E;AAC3E,kDAAkD;AAGlD,MAAa,gBAAiB,SAAQ,gBAIrC;IACC,YACE,IAAsC,EACtC,KAAuC;QAEvC,KAAK,CAAC,sBAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,eAAe,CACb,GAAyB,EACzB,QAA0B,EAC1B,UAAsC,EACtC,WAAuC;QAEvC,IACE,UAAU,YAAY,8BAAY;YAClC,WAAW,YAAY,8BAAY,EACnC;YACA,OAAO,8BAAY,CAAC,EAAE,CACpB,UAAU,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CACnD,CAAC;SACH;aAAM,IACL,UAAU,YAAY,4BAAW;YACjC,WAAW,YAAY,4BAAW,EAClC;YACA,OAAO,4BAAW,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;SACvE;QACD,OAAO,IAAI,wCAAoB,CAC7B,sBAAQ,CAAC,QAAQ,EACjB,gHAAgH,EAChH,CAAC,UAAU,EAAE,WAAW,CAAC,CAC1B,CAAC;IACJ,CAAC;IAED,YAAY;QACV,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,CAAC;IACtE,CAAC;IAED,OAAO;QACL,OAAO,gBAAK,CAAC,EAAE,CAAC,eAAI,CAAC,OAAO,EAAE,eAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACF;AA7CD,4CA6CC","file":"expression/poly/PlusOrConcatExpr.js","sourcesContent":["import { Expr2 } from \"../Expr2.js\";\nimport { Expr } from \"../Expr.js\";\nimport { IfcExpressionContext } from \"../../context/IfcExpressionContext.js\";\nimport { NumericValue } from \"../../value/NumericValue.js\";\nimport { ExprKind } from \"../ExprKind.js\";\nimport { StringValue } from \"../../value/StringValue.js\";\nimport { ExprEvalError, ExprEvalTypeErrorObj } from \"../ExprEvalResult.js\";\nimport { Type, Types } from \"../../type/Types.js\";\nimport { ExprType } from \"../../type/ExprType.js\";\n\nexport class PlusOrConcatExpr extends Expr2<\n NumericValue | StringValue,\n NumericValue | StringValue,\n NumericValue | StringValue\n> {\n constructor(\n left: Expr<NumericValue | StringValue>,\n right: Expr<NumericValue | StringValue>\n ) {\n super(ExprKind.NUM_PLUS, left, right);\n }\n\n calculateResult(\n ctx: IfcExpressionContext,\n localCtx: Map<string, any>,\n leftResult: NumericValue | StringValue,\n rightResult: NumericValue | StringValue\n ): NumericValue | StringValue | ExprEvalError {\n if (\n leftResult instanceof NumericValue &&\n rightResult instanceof NumericValue\n ) {\n return NumericValue.of(\n leftResult.getValue().plus(rightResult.getValue())\n );\n } else if (\n leftResult instanceof StringValue &&\n rightResult instanceof StringValue\n ) {\n return StringValue.of(leftResult.getValue() + rightResult.getValue());\n }\n return new ExprEvalTypeErrorObj(\n ExprKind.FUNCTION,\n \"Operator '+' requires the operands to be either both of type numeric or both of type string, but they are not.\",\n [leftResult, rightResult]\n );\n }\n\n toExprString(): string {\n return `${this.left.toExprString()} + ${this.right.toExprString()}`;\n }\n\n getType(): ExprType {\n return Types.or(Type.NUMERIC, Type.STRING);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/expression/poly/PlusOrConcatExpr.ts"],"names":[],"mappings":";;;AAAA,0CAAoC;AAGpC,iEAA2D;AAC3D,gDAA0C;AAC1C,+DAAyD;AACzD,4DAA2E;AAC3E,kDAAkD;AAGlD,MAAa,gBAAiB,SAAQ,gBAIrC;IACC,YACE,IAAsC,EACtC,KAAuC;QAEvC,KAAK,CAAC,sBAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,eAAe,CACb,GAAyB,EACzB,QAA0B,EAC1B,UAAsC,EACtC,WAAuC;QAEvC,IACE,UAAU,YAAY,8BAAY;YAClC,WAAW,YAAY,8BAAY,EACnC;YACA,OAAO,8BAAY,CAAC,EAAE,CACpB,UAAU,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CACnD,CAAC;SACH;aAAM,IACL,UAAU,YAAY,4BAAW;YACjC,WAAW,YAAY,4BAAW,EAClC;YACA,OAAO,4BAAW,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;SACvE;QACD,OAAO,IAAI,wCAAoB,CAC7B,sBAAQ,CAAC,QAAQ,EACjB,8GAA8G,UAAU;aACrH,OAAO,EAAE;aACT,OAAO,EAAE,yBAAyB,WAAW;aAC7C,OAAO,EAAE;aACT,OAAO,EAAE,mBAAmB,EAC/B,CAAC,UAAU,EAAE,WAAW,CAAC,CAC1B,CAAC;IACJ,CAAC;IAED,YAAY;QACV,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,CAAC;IACtE,CAAC;IAED,OAAO;QACL,OAAO,gBAAK,CAAC,EAAE,CAAC,eAAI,CAAC,OAAO,EAAE,eAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACF;AAjDD,4CAiDC","file":"expression/poly/PlusOrConcatExpr.js","sourcesContent":["import { Expr2 } from \"../Expr2.js\";\nimport { Expr } from \"../Expr.js\";\nimport { IfcExpressionContext } from \"../../context/IfcExpressionContext.js\";\nimport { NumericValue } from \"../../value/NumericValue.js\";\nimport { ExprKind } from \"../ExprKind.js\";\nimport { StringValue } from \"../../value/StringValue.js\";\nimport { ExprEvalError, ExprEvalTypeErrorObj } from \"../ExprEvalResult.js\";\nimport { Type, Types } from \"../../type/Types.js\";\nimport { ExprType } from \"../../type/ExprType.js\";\n\nexport class PlusOrConcatExpr extends Expr2<\n NumericValue | StringValue,\n NumericValue | StringValue,\n NumericValue | StringValue\n> {\n constructor(\n left: Expr<NumericValue | StringValue>,\n right: Expr<NumericValue | StringValue>\n ) {\n super(ExprKind.NUM_PLUS, left, right);\n }\n\n calculateResult(\n ctx: IfcExpressionContext,\n localCtx: Map<string, any>,\n leftResult: NumericValue | StringValue,\n rightResult: NumericValue | StringValue\n ): NumericValue | StringValue | ExprEvalError {\n if (\n leftResult instanceof NumericValue &&\n rightResult instanceof NumericValue\n ) {\n return NumericValue.of(\n leftResult.getValue().plus(rightResult.getValue())\n );\n } else if (\n leftResult instanceof StringValue &&\n rightResult instanceof StringValue\n ) {\n return StringValue.of(leftResult.getValue() + rightResult.getValue());\n }\n return new ExprEvalTypeErrorObj(\n ExprKind.FUNCTION,\n `Operator '+' requires the operands to be either both of type numeric or both of type string, but they are '${leftResult\n .getType()\n .getName()}' (left operand) and '${rightResult\n .getType()\n .getName()}' (right operand)`,\n [leftResult, rightResult]\n );\n }\n\n toExprString(): string {\n return `${this.left.toExprString()} + ${this.right.toExprString()}`;\n }\n\n getType(): ExprType {\n return Types.or(Type.NUMERIC, Type.STRING);\n }\n}\n"]}
@@ -37,15 +37,27 @@ class TypeManager {
37
37
  isType(type, ...ctxs) {
38
38
  return ctxs.every((ctx) => Types_js_1.Types.isType(this.types.get(ctx), type));
39
39
  }
40
+ overlapsWith(type, ...ctxs) {
41
+ return ctxs.every((ctx) => type.overlapsWith(this.types.get(ctx)));
42
+ }
40
43
  isString(...ctxs) {
41
44
  return this.isType(Types_js_1.Type.STRING, ...ctxs);
42
45
  }
46
+ overlapsWithString(...ctxs) {
47
+ return this.overlapsWith(Types_js_1.Type.STRING, ...ctxs);
48
+ }
43
49
  isBoolean(...ctxs) {
44
50
  return this.isType(Types_js_1.Type.BOOLEAN, ...ctxs);
45
51
  }
52
+ overlapsWithBoolean(...ctxs) {
53
+ return this.overlapsWith(Types_js_1.Type.BOOLEAN, ...ctxs);
54
+ }
46
55
  isNumeric(...ctxs) {
47
56
  return this.isType(Types_js_1.Type.NUMERIC, ...ctxs);
48
57
  }
58
+ overlapsWithNumeric(...ctxs) {
59
+ return this.overlapsWith(Types_js_1.Type.NUMERIC, ...ctxs);
60
+ }
49
61
  }
50
62
  exports.TypeManager = TypeManager;
51
63
  //# sourceMappingURL=TypeManager.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/type/TypeManager.ts"],"names":[],"mappings":";;;AACA,yCAAyC;AACzC,4EAAsE;AAGtE,MAAa,WAAW;IAGtB;QAFiB,UAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEjD,CAAC;IAET,OAAO,CAAC,iBAAoC,EAAE,IAAc;QACjE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,iB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I,4CAAmB,CACrB,yCAAyC,UAAU,CAAC,OAAO,EAAE,EAAE,EAC/D,GAAG,CACJ,CACJ,CAAC;IACJ,CAAC;IAEM,mBAAmB,CAAC,IAAuB,EAAE,IAAuB;QACzE,gBAAK,CAAC,mBAAmB,CACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EACpB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EACpB,GAAG,EAAE,CACH,IAAI,4CAAmB,CACrB,SAAS,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,IAAI,CAAC,KAAK;aACtD,GAAG,CAAC,IAAI,CAAC;aACT,OAAO,EAAE,0CAA0C,EACtD,IAAI,CACL,CACJ,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,IAAc,EAAE,GAAG,IAAI;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,QAAQ,CAAC,GAAG,IAAI;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3C,CAAC;IAEM,SAAS,CAAC,GAAG,IAAI;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEM,SAAS,CAAC,GAAG,IAAI;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;CACF;AAtFD,kCAsFC","file":"type/TypeManager.js","sourcesContent":["import { ParserRuleContext } from \"antlr4\";\nimport { Type, Types } from \"./Types.js\";\nimport { ExpressionTypeError } from \"../error/ExpressionTypeError.js\";\nimport { ExprType } from \"./ExprType.js\";\n\nexport class TypeManager {\n private readonly types = new Map<ParserRuleContext, ExprType>();\n\n constructor() {}\n\n public setType(parserRuleContext: ParserRuleContext, type: ExprType) {\n this.types.set(parserRuleContext, type);\n }\n\n public getType(parserRuleContext: ParserRuleContext): ExprType {\n return this.types.get(parserRuleContext);\n }\n\n public copyTypeFrom(ctx: ParserRuleContext, from: ParserRuleContext) {\n const theType = this.types.get(from as ParserRuleContext);\n this.types.set(ctx, theType);\n }\n\n public requireString(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.STRING,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type string, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireBoolean(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.BOOLEAN,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type boolean, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireNumeric(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.NUMERIC,\n actualType,\n () =>\n new ExpressionTypeError(\n `expected type numeric, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireTypesOverlap(ctxA: ParserRuleContext, ctxB: ParserRuleContext) {\n Types.requireTypesOverlap(\n this.types.get(ctxA),\n this.types.get(ctxB),\n () =>\n new ExpressionTypeError(\n `Types ${this.types.get(ctxA).getName()} and ${this.types\n .get(ctxB)\n .getName()} are required to overlap but they don't.`,\n ctxA\n )\n );\n }\n\n public isType(type: ExprType, ...ctxs) {\n return ctxs.every((ctx) => Types.isType(this.types.get(ctx), type));\n }\n\n public isString(...ctxs) {\n return this.isType(Type.STRING, ...ctxs);\n }\n\n public isBoolean(...ctxs) {\n return this.isType(Type.BOOLEAN, ...ctxs);\n }\n\n public isNumeric(...ctxs) {\n return this.isType(Type.NUMERIC, ...ctxs);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/type/TypeManager.ts"],"names":[],"mappings":";;;AACA,yCAAyC;AACzC,4EAAsE;AAGtE,MAAa,WAAW;IAGtB;QAFiB,UAAK,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEjD,CAAC;IAET,OAAO,CAAC,iBAAoC,EAAE,IAAc;QACjE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAEM,OAAO,CAAC,iBAAoC;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC3C,CAAC;IAEM,YAAY,CAAC,GAAsB,EAAE,IAAuB;QACjE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAyB,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAEM,aAAa,CAAC,GAAsB;QACzC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAwB,CAAC,CAAC;QAC5D,gBAAK,CAAC,2BAA2B,CAC/B,eAAI,CAAC,MAAM,EACX,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAwB,CAAC,EACxC,GAAG,EAAE,CACH,IAAI,4CAAmB,CACrB,wCAAwC,UAAU,CAAC,OAAO,EAAE,EAAE,EAC9D,GAAG,CACJ,CACJ,CAAC;IACJ,CAAC;IAEM,cAAc,CAAC,GAAsB;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAwB,CAAC,CAAC;QAC5D,gBAAK,CAAC,2BAA2B,CAC/B,eAAI,CAAC,OAAO,EACZ,IAAI,CAA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AAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAEM,QAAQ,CAAC,GAAG,IAAI;QACrB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3C,CAAC;IAEM,kBAAkB,CAAC,GAAG,IAAI;QAC/B,OAAO,IAAI,CAAC,YAAY,CAAC,eAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;IAEM,SAAS,CAAC,GAAG,IAAI;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEM,mBAAmB,CAAC,GAAG,IAAI;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,CAAC;IAEM,SAAS,CAAC,GAAG,IAAI;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEM,mBAAmB,CAAC,GAAG,IAAI;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAtGD,kCAsGC","file":"type/TypeManager.js","sourcesContent":["import { ParserRuleContext } from \"antlr4\";\nimport { Type, Types } from \"./Types.js\";\nimport { ExpressionTypeError } from \"../error/ExpressionTypeError.js\";\nimport { ExprType } from \"./ExprType.js\";\n\nexport class TypeManager {\n private readonly types = new Map<ParserRuleContext, ExprType>();\n\n constructor() {}\n\n public setType(parserRuleContext: ParserRuleContext, type: ExprType) {\n this.types.set(parserRuleContext, type);\n }\n\n public getType(parserRuleContext: ParserRuleContext): ExprType {\n return this.types.get(parserRuleContext);\n }\n\n public copyTypeFrom(ctx: ParserRuleContext, from: ParserRuleContext) {\n const theType = this.types.get(from as ParserRuleContext);\n this.types.set(ctx, theType);\n }\n\n public requireString(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.STRING,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type string, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireBoolean(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.BOOLEAN,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type boolean, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireNumeric(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.NUMERIC,\n actualType,\n () =>\n new ExpressionTypeError(\n `expected type numeric, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireTypesOverlap(ctxA: ParserRuleContext, ctxB: ParserRuleContext) {\n Types.requireTypesOverlap(\n this.types.get(ctxA),\n this.types.get(ctxB),\n () =>\n new ExpressionTypeError(\n `Types ${this.types.get(ctxA).getName()} and ${this.types\n .get(ctxB)\n .getName()} are required to overlap but they don't.`,\n ctxA\n )\n );\n }\n\n public isType(type: ExprType, ...ctxs) {\n return ctxs.every((ctx) => Types.isType(this.types.get(ctx), type));\n }\n\n public overlapsWith(type: ExprType, ...ctxs) {\n return ctxs.every((ctx) => type.overlapsWith(this.types.get(ctx)));\n }\n\n public isString(...ctxs) {\n return this.isType(Type.STRING, ...ctxs);\n }\n\n public overlapsWithString(...ctxs) {\n return this.overlapsWith(Type.STRING, ...ctxs);\n }\n\n public isBoolean(...ctxs) {\n return this.isType(Type.BOOLEAN, ...ctxs);\n }\n\n public overlapsWithBoolean(...ctxs) {\n return this.overlapsWith(Type.BOOLEAN, ...ctxs);\n }\n\n public isNumeric(...ctxs) {\n return this.isType(Type.NUMERIC, ...ctxs);\n }\n\n public overlapsWithNumeric(...ctxs) {\n return this.overlapsWith(Type.NUMERIC, ...ctxs);\n }\n}\n"]}
@@ -11,7 +11,8 @@ exports.Type = Type;
11
11
  Type.ANY = new SimpleType_js_1.SimpleType("any");
12
12
  Type.NUMERIC = new SimpleType_js_1.SimpleType("numeric");
13
13
  Type.STRING = new SimpleType_js_1.SimpleType("string");
14
- Type.BOOLEAN = new SimpleType_js_1.SimpleType("boolean");
14
+ Type.LOGICAL = new SimpleType_js_1.SimpleType("logical");
15
+ Type.BOOLEAN = new SimpleType_js_1.SimpleType("boolean", Type.LOGICAL);
15
16
  Type.IFC_OBJECT_REF = new SimpleType_js_1.SimpleType("ifcObjectRef");
16
17
  Type.IFC_ELEMENT_REF = new SimpleType_js_1.SimpleType("ifcElementRef", Type.IFC_OBJECT_REF);
17
18
  Type.IFC_PROPERTY_REF = new SimpleType_js_1.SimpleType("ifcPropertyRef", Type.IFC_OBJECT_REF);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/type/Types.ts"],"names":[],"mappings":";;;AACA,mDAA6C;AAC7C,6DAAuD;AAEvD,iDAA2C;AAC3C,iDAA2C;AAE3C,MAAa,IAAI;;AAAjB,oBAuBC;AAtBiB,QAAG,GAAG,IAAI,0BAAU,CAAC,KAAK,CAAC,CAAC;AAC5B,YAAO,GAAG,IAAI,0BAAU,CAAC,SAAS,CAAC,CAAC;AACpC,WAAM,GAAG,IAAI,0BAAU,CAAC,QAAQ,CAAC,CAAC;AAClC,YAAO,GAAG,IAAI,0BAAU,CAAC,SAAS,CAAC,CAAC;AACpC,mBAAc,GAAG,IAAI,0BAAU,CAAC,cAAc,CAAC,CAAC;AAChD,oBAAe,GAAG,IAAI,0BAAU,CAC9C,eAAe,EACf,IAAI,CAAC,cAAc,CACpB,CAAC;AACc,qBAAgB,GAAG,IAAI,0BAAU,CAC/C,gBAAgB,EAChB,IAAI,CAAC,cAAc,CACpB,CAAC;AAC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,CAAC;IACtB,CAAC;IACM,MAAM,CAAC,YAAY;QACxB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,MAAM,CAAC,uBAAuB,CACnC,YAAsB,EACtB,UAAoB,EACpB,iBAA4C;QAE5C,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE;YAC9C,MAAM,iBAAiB,EAAE,CAAC;SAC3B;IACH,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,2BAA2B,CACvC,YAAsB,EACtB,UAAoB,EACpB,iBAA4C;QAE5C,IAAI,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE;YAC7C,OAAO;SACR;QACD,IAAI,UAAU,YAAY,oCAAe,EAAE;YACzC,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;gBACzC,OAAO;aACR;SACF;QACD,IAAI,UAAU,YAAY,wBAAS,EAAE;YACnC,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACnE,IAAI,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE;gBAC7C,OAAO;aACR;SACF;QACD,MAAM,iBAAiB,EAAE,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,mBAAmB,CACxB,UAAoB,EACpB,WAAqB,EACrB,iBAA4C;QAE5C,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;YACzC,MAAM,iBAAiB,EAAE,CAAC;SAC3B;IACH,CAAC;CACF;AAlFD,sBAkFC","file":"type/Types.js","sourcesContent":["import { ExpressionTypeError } from \"../error/ExpressionTypeError.js\";\nimport { SimpleType } from \"./SimpleType.js\";\nimport { TypeDisjunction } from \"./TypeDisjunction.js\";\nimport { ExprType } from \"./ExprType.js\";\nimport { ArrayType } from \"./ArrayType.js\";\nimport { TupleType } from \"./TupleType.js\";\n\nexport class Type {\n static readonly ANY = new SimpleType(\"any\");\n static readonly NUMERIC = new SimpleType(\"numeric\");\n static readonly STRING = new SimpleType(\"string\");\n static readonly BOOLEAN = new SimpleType(\"boolean\");\n static readonly IFC_OBJECT_REF = new SimpleType(\"ifcObjectRef\");\n static readonly IFC_ELEMENT_REF = new SimpleType(\n \"ifcElementRef\",\n Type.IFC_OBJECT_REF\n );\n static readonly IFC_PROPERTY_REF = new SimpleType(\n \"ifcPropertyRef\",\n Type.IFC_OBJECT_REF\n );\n static readonly IFC_PROPERTY_SET_REF = new SimpleType(\n \"ifcPropertySetRef\",\n Type.IFC_OBJECT_REF\n );\n static readonly IFC_TYPE_OBJECT_REF = new SimpleType(\n \"ifcTypeObjectRef\",\n Type.IFC_OBJECT_REF\n );\n static readonly ARRAY = new SimpleType(\"array\");\n}\n\nexport class Types {\n public static or(...types: Array<ExprType>) {\n return new TypeDisjunction(...types);\n }\n public static array(elementType: ExprType): ArrayType {\n return new ArrayType(elementType);\n }\n public static tuple(...types: Array<ExprType>): TupleType {\n return new TupleType(...types);\n }\n public static isNumeric(actualType: ExprType) {\n return this.isType(actualType, Type.NUMERIC);\n }\n public static isBoolean(actualType: ExprType) {\n return this.isType(actualType, Type.BOOLEAN);\n }\n public static isString(actualType: ExprType) {\n return this.isType(actualType, Type.STRING);\n }\n public static isType(actualType: ExprType, type: ExprType) {\n return actualType === type;\n }\n public static boolean() {\n return Type.BOOLEAN;\n }\n public static string() {\n return Type.STRING;\n }\n public static numeric() {\n return Type.NUMERIC;\n }\n public static ifcObjectRef() {\n return Type.IFC_OBJECT_REF;\n }\n\n public static requireIsAssignableFrom(\n expectedType: ExprType,\n actualType: ExprType,\n exceptionProducer: () => ExpressionTypeError\n ) {\n if (!expectedType.isAssignableFrom(actualType)) {\n throw exceptionProducer();\n }\n }\n\n /**\n * Requires overlap if actual is a disjunction, assignable from if it is a type\n * @param expectedType\n * @param actualType\n * @param exceptionProducer\n */\n public static requireWeakIsAssignableFrom(\n expectedType: ExprType,\n actualType: ExprType,\n exceptionProducer: () => ExpressionTypeError\n ) {\n if (expectedType.isAssignableFrom(actualType)) {\n return;\n }\n if (actualType instanceof TypeDisjunction) {\n if (expectedType.overlapsWith(actualType)) {\n return;\n }\n }\n if (actualType instanceof TupleType) {\n const weakerType = Types.array(Types.or(...actualType.getTypes()));\n if (expectedType.isAssignableFrom(weakerType)) {\n return;\n }\n }\n throw exceptionProducer();\n }\n\n static requireTypesOverlap(\n actualType: ExprType,\n actualType2: ExprType,\n exceptionProducer: () => ExpressionTypeError\n ) {\n if (!actualType.overlapsWith(actualType2)) {\n throw exceptionProducer();\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/type/Types.ts"],"names":[],"mappings":";;;AACA,mDAA6C;AAC7C,6DAAuD;AAEvD,iDAA2C;AAC3C,iDAA2C;AAE3C,MAAa,IAAI;;AAAjB,oBAwBC;AAvBiB,QAAG,GAAG,IAAI,0BAAU,CAAC,KAAK,CAAC,CAAC;AAC5B,YAAO,GAAG,IAAI,0BAAU,CAAC,SAAS,CAAC,CAAC;AACpC,WAAM,GAAG,IAAI,0BAAU,CAAC,QAAQ,CAAC,CAAC;AAClC,YAAO,GAAG,IAAI,0BAAU,CAAC,SAAS,CAAC,CAAC;AACpC,YAAO,GAAG,IAAI,0BAAU,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AAClD,mBAAc,GAAG,IAAI,0BAAU,CAAC,cAAc,CAAC,CAAC;AAChD,oBAAe,GAAG,IAAI,0BAAU,CAC9C,eAAe,EACf,IAAI,CAAC,cAAc,CACpB,CAAC;AACc,qBAAgB,GAAG,IAAI,0BAAU,CAC/C,gBAAgB,EAChB,IAAI,CAAC,cAAc,CACpB,CAAC;AACc,yBAAoB,GAAG,IAAI,0BAAU,CACnD,mBAAmB,EACnB,IAAI,CAAC,cAAc,CACpB,CAAC;AACc,wBAAmB,GAAG,IAAI,0BAAU,CAClD,kBAAkB,EAClB,IAAI,CAAC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EACpB,iBAA4C;QAE5C,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE;YAC9C,MAAM,iBAAiB,EAAE,CAAC;SAC3B;IACH,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,2BAA2B,CACvC,YAAsB,EACtB,UAAoB,EACpB,iBAA4C;QAE5C,IAAI,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE;YAC7C,OAAO;SACR;QACD,IAAI,UAAU,YAAY,oCAAe,EAAE;YACzC,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;gBACzC,OAAO;aACR;SACF;QACD,IAAI,UAAU,YAAY,wBAAS,EAAE;YACnC,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACnE,IAAI,YAAY,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE;gBAC7C,OAAO;aACR;SACF;QACD,MAAM,iBAAiB,EAAE,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,mBAAmB,CACxB,UAAoB,EACpB,WAAqB,EACrB,iBAA4C;QAE5C,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;YACzC,MAAM,iBAAiB,EAAE,CAAC;SAC3B;IACH,CAAC;CACF;AAlFD,sBAkFC","file":"type/Types.js","sourcesContent":["import { ExpressionTypeError } from \"../error/ExpressionTypeError.js\";\nimport { SimpleType } from \"./SimpleType.js\";\nimport { TypeDisjunction } from \"./TypeDisjunction.js\";\nimport { ExprType } from \"./ExprType.js\";\nimport { ArrayType } from \"./ArrayType.js\";\nimport { TupleType } from \"./TupleType.js\";\n\nexport class Type {\n static readonly ANY = new SimpleType(\"any\");\n static readonly NUMERIC = new SimpleType(\"numeric\");\n static readonly STRING = new SimpleType(\"string\");\n static readonly LOGICAL = new SimpleType(\"logical\");\n static readonly BOOLEAN = new SimpleType(\"boolean\", Type.LOGICAL);\n static readonly IFC_OBJECT_REF = new SimpleType(\"ifcObjectRef\");\n static readonly IFC_ELEMENT_REF = new SimpleType(\n \"ifcElementRef\",\n Type.IFC_OBJECT_REF\n );\n static readonly IFC_PROPERTY_REF = new SimpleType(\n \"ifcPropertyRef\",\n Type.IFC_OBJECT_REF\n );\n static readonly IFC_PROPERTY_SET_REF = new SimpleType(\n \"ifcPropertySetRef\",\n Type.IFC_OBJECT_REF\n );\n static readonly IFC_TYPE_OBJECT_REF = new SimpleType(\n \"ifcTypeObjectRef\",\n Type.IFC_OBJECT_REF\n );\n static readonly ARRAY = new SimpleType(\"array\");\n}\n\nexport class Types {\n public static or(...types: Array<ExprType>) {\n return new TypeDisjunction(...types);\n }\n public static array(elementType: ExprType): ArrayType {\n return new ArrayType(elementType);\n }\n public static tuple(...types: Array<ExprType>): TupleType {\n return new TupleType(...types);\n }\n public static isNumeric(actualType: ExprType) {\n return this.isType(actualType, Type.NUMERIC);\n }\n public static isBoolean(actualType: ExprType) {\n return this.isType(actualType, Type.BOOLEAN);\n }\n public static isString(actualType: ExprType) {\n return this.isType(actualType, Type.STRING);\n }\n public static isType(actualType: ExprType, type: ExprType) {\n return actualType === type;\n }\n public static boolean() {\n return Type.BOOLEAN;\n }\n public static string() {\n return Type.STRING;\n }\n public static numeric() {\n return Type.NUMERIC;\n }\n public static ifcObjectRef() {\n return Type.IFC_OBJECT_REF;\n }\n\n public static requireIsAssignableFrom(\n expectedType: ExprType,\n actualType: ExprType,\n exceptionProducer: () => ExpressionTypeError\n ) {\n if (!expectedType.isAssignableFrom(actualType)) {\n throw exceptionProducer();\n }\n }\n\n /**\n * Requires overlap if actual is a disjunction, assignable from if it is a type\n * @param expectedType\n * @param actualType\n * @param exceptionProducer\n */\n public static requireWeakIsAssignableFrom(\n expectedType: ExprType,\n actualType: ExprType,\n exceptionProducer: () => ExpressionTypeError\n ) {\n if (expectedType.isAssignableFrom(actualType)) {\n return;\n }\n if (actualType instanceof TypeDisjunction) {\n if (expectedType.overlapsWith(actualType)) {\n return;\n }\n }\n if (actualType instanceof TupleType) {\n const weakerType = Types.array(Types.or(...actualType.getTypes()));\n if (expectedType.isAssignableFrom(weakerType)) {\n return;\n }\n }\n throw exceptionProducer();\n }\n\n static requireTypesOverlap(\n actualType: ExprType,\n actualType2: ExprType,\n exceptionProducer: () => ExpressionTypeError\n ) {\n if (!actualType.overlapsWith(actualType2)) {\n throw exceptionProducer();\n }\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArrayValue = void 0;
4
+ const Types_js_1 = require("../type/Types.js");
4
5
  class ArrayValue {
5
6
  constructor(value) {
6
7
  this.arrayValue = value;
@@ -11,6 +12,9 @@ class ArrayValue {
11
12
  getValue() {
12
13
  return this.arrayValue;
13
14
  }
15
+ getType() {
16
+ return Types_js_1.Type.ARRAY;
17
+ }
14
18
  equals(other) {
15
19
  return (ArrayValue.isArrayValueType(other) &&
16
20
  other.arrayValue.every((val, ind) => val.equals(this.arrayValue[ind])));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/value/ArrayValue.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAGrB,YAAY,KAAwB;QAClC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAwB;QACvC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAClC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CACvE,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,CACL,GAAG;YACH,IAAI,CAAC,UAAU;iBACZ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACT,IAAI,OAAO,CAAC,CAAC,UAAU,CAAC,KAAK,UAAU,EAAE;oBACvC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;iBACrB;qBAAM;oBACL,OAAO,EAAE,GAAG,CAAC,CAAC;iBACf;YACH,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC;YACb,GAAG,CACJ,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,GAAQ;QACrC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACF;AAzCD,gCAyCC","file":"value/ArrayValue.js","sourcesContent":["import { Value } from \"./Value.js\";\n\nexport class ArrayValue implements Value<Array<Value<any>>> {\n private readonly arrayValue: Array<Value<any>>;\n\n constructor(value: Array<Value<any>>) {\n this.arrayValue = value;\n }\n\n public static of(value: Array<Value<any>>): ArrayValue {\n return new ArrayValue(value);\n }\n\n getValue(): Array<Value<any>> {\n return this.arrayValue;\n }\n\n equals(other: Value<any>): boolean {\n return (\n ArrayValue.isArrayValueType(other) &&\n other.arrayValue.every((val, ind) => val.equals(this.arrayValue[ind]))\n );\n }\n\n toString(): string {\n return (\n \"[\" +\n this.arrayValue\n .map((e) => {\n if (typeof e[\"toString\"] === \"function\") {\n return e.toString();\n } else {\n return \"\" + e;\n }\n })\n .join(\", \") +\n \"]\"\n );\n }\n\n public static isArrayValueType(arg: any): arg is ArrayValueType {\n return Array.isArray(arg.arrayValue);\n }\n}\n\nexport type ArrayValueType = {\n arrayValue: Array<Value<any>>;\n};\n"]}
1
+ {"version":3,"sources":["../../src/value/ArrayValue.ts"],"names":[],"mappings":";;;AAEA,+CAAwC;AAExC,MAAa,UAAU;IAGrB,YAAY,KAAwB;QAClC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAwB;QACvC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,OAAO;QACL,OAAO,eAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAClC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CACvE,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,CACL,GAAG;YACH,IAAI,CAAC,UAAU;iBACZ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACT,IAAI,OAAO,CAAC,CAAC,UAAU,CAAC,KAAK,UAAU,EAAE;oBACvC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;iBACrB;qBAAM;oBACL,OAAO,EAAE,GAAG,CAAC,CAAC;iBACf;YACH,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC;YACb,GAAG,CACJ,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,GAAQ;QACrC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACF;AA7CD,gCA6CC","file":"value/ArrayValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\n\nexport class ArrayValue implements Value<Array<Value<any>>> {\n private readonly arrayValue: Array<Value<any>>;\n\n constructor(value: Array<Value<any>>) {\n this.arrayValue = value;\n }\n\n public static of(value: Array<Value<any>>): ArrayValue {\n return new ArrayValue(value);\n }\n\n getValue(): Array<Value<any>> {\n return this.arrayValue;\n }\n\n getType(): ExprType {\n return Type.ARRAY;\n }\n\n equals(other: Value<any>): boolean {\n return (\n ArrayValue.isArrayValueType(other) &&\n other.arrayValue.every((val, ind) => val.equals(this.arrayValue[ind]))\n );\n }\n\n toString(): string {\n return (\n \"[\" +\n this.arrayValue\n .map((e) => {\n if (typeof e[\"toString\"] === \"function\") {\n return e.toString();\n } else {\n return \"\" + e;\n }\n })\n .join(\", \") +\n \"]\"\n );\n }\n\n public static isArrayValueType(arg: any): arg is ArrayValueType {\n return Array.isArray(arg.arrayValue);\n }\n}\n\nexport type ArrayValueType = {\n arrayValue: Array<Value<any>>;\n};\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BooleanValue = void 0;
4
+ const Types_js_1 = require("../type/Types.js");
4
5
  class BooleanValue {
5
6
  constructor(value) {
6
7
  this.booleanValue = value;
@@ -11,6 +12,9 @@ class BooleanValue {
11
12
  getValue() {
12
13
  return this.booleanValue;
13
14
  }
15
+ getType() {
16
+ return Types_js_1.Type.BOOLEAN;
17
+ }
14
18
  equals(other) {
15
19
  return (BooleanValue.isBooleanValueType(other) &&
16
20
  other.booleanValue === this.booleanValue);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/value/BooleanValue.ts"],"names":[],"mappings":";;;AAGA,MAAa,YAAY;IAGvB,YAAY,KAAc;QACxB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAc;QAC7B,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC;YACtC,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC,YAAY,CACzC,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,KAAmB;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAQ;QAChC,OAAO,OAAO,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC;IAC/C,CAAC;CACF;AAjCD,oCAiCC","file":"value/BooleanValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\n\nexport class BooleanValue implements Value<boolean>, Comparable<BooleanValue> {\n private readonly booleanValue: boolean;\n\n constructor(value: boolean) {\n this.booleanValue = value;\n }\n\n public static of(value: boolean): BooleanValue {\n return new BooleanValue(value);\n }\n\n getValue(): boolean {\n return this.booleanValue;\n }\n\n equals(other: Value<any>): boolean {\n return (\n BooleanValue.isBooleanValueType(other) &&\n other.booleanValue === this.booleanValue\n );\n }\n\n compareTo(other: BooleanValue): number {\n return this.booleanValue ? (other.booleanValue ? 0 : 1) : -1;\n }\n\n toString(): string {\n return this.booleanValue ? \"TRUE\" : \"FALSE\";\n }\n\n static isBooleanValueType(arg: any): arg is BooleanValueType {\n return typeof arg.booleanValue === \"boolean\";\n }\n}\n\nexport type BooleanValueType = {\n booleanValue: boolean;\n};\n"]}
1
+ {"version":3,"sources":["../../src/value/BooleanValue.ts"],"names":[],"mappings":";;;AAGA,+CAAwC;AAExC,MAAa,YAAY;IAGvB,YAAY,KAAc;QACxB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAc;QAC7B,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,OAAO;QACL,OAAO,eAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC;YACtC,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC,YAAY,CACzC,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,KAAmB;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAQ;QAChC,OAAO,OAAO,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC;IAC/C,CAAC;CACF;AArCD,oCAqCC","file":"value/BooleanValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\n\nexport class BooleanValue implements Value<boolean>, Comparable<BooleanValue> {\n private readonly booleanValue: boolean;\n\n constructor(value: boolean) {\n this.booleanValue = value;\n }\n\n public static of(value: boolean): BooleanValue {\n return new BooleanValue(value);\n }\n\n getValue(): boolean {\n return this.booleanValue;\n }\n\n getType(): ExprType {\n return Type.BOOLEAN;\n }\n\n equals(other: Value<any>): boolean {\n return (\n BooleanValue.isBooleanValueType(other) &&\n other.booleanValue === this.booleanValue\n );\n }\n\n compareTo(other: BooleanValue): number {\n return this.booleanValue ? (other.booleanValue ? 0 : 1) : -1;\n }\n\n toString(): string {\n return this.booleanValue ? \"TRUE\" : \"FALSE\";\n }\n\n static isBooleanValueType(arg: any): arg is BooleanValueType {\n return typeof arg.booleanValue === \"boolean\";\n }\n}\n\nexport type BooleanValueType = {\n booleanValue: boolean;\n};\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LogicalValue = void 0;
4
+ const Types_js_1 = require("../type/Types.js");
4
5
  class LogicalValue {
5
6
  constructor(value) {
6
7
  this.logicalValue = value;
@@ -15,6 +16,9 @@ class LogicalValue {
15
16
  return (LogicalValue.isLogicalValueType(other) &&
16
17
  other.logicalValue === this.logicalValue);
17
18
  }
19
+ getType() {
20
+ return Types_js_1.Type.LOGICAL;
21
+ }
18
22
  toString() {
19
23
  return this.logicalValue === "UNKNOWN"
20
24
  ? "UNKNOWN"
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/value/LogicalValue.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;IAGvB,YAAY,KAA0B;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAA0B;QACzC,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC;YACtC,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC,YAAY,CACzC,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,KAAK,SAAS;YACpC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,IAAI,CAAC,YAAY;gBACnB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,OAAO,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAAC,GAAQ;QACvC,OAAO,CACL,CAAC,OAAO,GAAG,CAAC,YAAY,KAAK,WAAW;YACtC,OAAO,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC;YACxC,GAAG,CAAC,YAAY,KAAK,SAAS,CAC/B,CAAC;IACJ,CAAC;CACF;AArCD,oCAqCC","file":"value/LogicalValue.js","sourcesContent":["import { Value } from \"./Value.js\";\n\nexport class LogicalValue implements Value<boolean | \"UNKNOWN\"> {\n private readonly logicalValue: boolean | \"UNKNOWN\";\n\n constructor(value: boolean | \"UNKNOWN\") {\n this.logicalValue = value;\n }\n\n public static of(value: boolean | \"UNKNOWN\"): LogicalValue {\n return new LogicalValue(value);\n }\n\n getValue(): boolean | \"UNKNOWN\" {\n return this.logicalValue;\n }\n\n equals(other: Value<any>): boolean {\n return (\n LogicalValue.isLogicalValueType(other) &&\n other.logicalValue === this.logicalValue\n );\n }\n\n toString(): string {\n return this.logicalValue === \"UNKNOWN\"\n ? \"UNKNOWN\"\n : this.logicalValue\n ? \"TRUE\"\n : \"FALSE\";\n }\n\n public static isLogicalValueType(arg: any): arg is LogicalValueType {\n return (\n (typeof arg.logicalValue !== \"undefined\" &&\n typeof arg.logicalValue === \"boolean\") ||\n arg.logicalValue === \"UNKNOWN\"\n );\n }\n}\n\nexport type LogicalValueType = {\n logicalValue: boolean | \"UNKNOWN\";\n};\n"]}
1
+ {"version":3,"sources":["../../src/value/LogicalValue.ts"],"names":[],"mappings":";;;AAEA,+CAAwC;AAExC,MAAa,YAAY;IAGvB,YAAY,KAA0B;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAA0B;QACzC,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC;YACtC,KAAK,CAAC,YAAY,KAAK,IAAI,CAAC,YAAY,CACzC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,eAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,KAAK,SAAS;YACpC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,IAAI,CAAC,YAAY;gBACnB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,OAAO,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAAC,GAAQ;QACvC,OAAO,CACL,CAAC,OAAO,GAAG,CAAC,YAAY,KAAK,WAAW;YACtC,OAAO,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC;YACxC,GAAG,CAAC,YAAY,KAAK,SAAS,CAC/B,CAAC;IACJ,CAAC;CACF;AAzCD,oCAyCC","file":"value/LogicalValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\n\nexport class LogicalValue implements Value<boolean | \"UNKNOWN\"> {\n private readonly logicalValue: boolean | \"UNKNOWN\";\n\n constructor(value: boolean | \"UNKNOWN\") {\n this.logicalValue = value;\n }\n\n public static of(value: boolean | \"UNKNOWN\"): LogicalValue {\n return new LogicalValue(value);\n }\n\n getValue(): boolean | \"UNKNOWN\" {\n return this.logicalValue;\n }\n\n equals(other: Value<any>): boolean {\n return (\n LogicalValue.isLogicalValueType(other) &&\n other.logicalValue === this.logicalValue\n );\n }\n\n getType(): ExprType {\n return Type.LOGICAL;\n }\n\n toString(): string {\n return this.logicalValue === \"UNKNOWN\"\n ? \"UNKNOWN\"\n : this.logicalValue\n ? \"TRUE\"\n : \"FALSE\";\n }\n\n public static isLogicalValueType(arg: any): arg is LogicalValueType {\n return (\n (typeof arg.logicalValue !== \"undefined\" &&\n typeof arg.logicalValue === \"boolean\") ||\n arg.logicalValue === \"UNKNOWN\"\n );\n }\n}\n\nexport type LogicalValueType = {\n logicalValue: boolean | \"UNKNOWN\";\n};\n"]}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NumericValue = void 0;
4
4
  const decimal_js_1 = require("decimal.js");
5
+ const Types_js_1 = require("../type/Types.js");
5
6
  class NumericValue {
6
7
  constructor(value) {
7
8
  if (decimal_js_1.Decimal.isDecimal(value)) {
@@ -15,6 +16,9 @@ class NumericValue {
15
16
  getValue() {
16
17
  return this.numericValue;
17
18
  }
19
+ getType() {
20
+ return Types_js_1.Type.NUMERIC;
21
+ }
18
22
  static isNumericValueType(arg) {
19
23
  return decimal_js_1.Decimal.isDecimal(arg.numericValue);
20
24
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/value/NumericValue.ts"],"names":[],"mappings":";;;AAAA,2CAAqC;AAIrC,MAAa,YAAY;IAGvB,YAAY,KAAgC;QAC1C,IAAI,oBAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAC5B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;SAC3B;QACD,IAAI,CAAC,YAAY,GAAG,IAAI,oBAAO,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAgC;QAC/C,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAQ;QAChC,OAAO,oBAAO,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC;YACtC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CACzC,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED,SAAS,CAAC,KAAmB;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;CACF;AApCD,oCAoCC","file":"value/NumericValue.js","sourcesContent":["import { Decimal } from \"decimal.js\";\nimport { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\n\nexport class NumericValue implements Value<Decimal>, Comparable<NumericValue> {\n private readonly numericValue: Decimal;\n\n constructor(value: Decimal | string | number) {\n if (Decimal.isDecimal(value)) {\n this.numericValue = value;\n }\n this.numericValue = new Decimal(value);\n }\n\n public static of(value: Decimal | string | number): NumericValue {\n return new NumericValue(value);\n }\n\n getValue(): Decimal {\n return this.numericValue;\n }\n\n static isNumericValueType(arg: any): arg is NumericValueType {\n return Decimal.isDecimal(arg.numericValue);\n }\n\n equals(other: Value<any>): boolean {\n return (\n NumericValue.isNumericValueType(other) &&\n this.numericValue.eq(other.numericValue)\n );\n }\n\n toString(): string {\n return this.numericValue.toString();\n }\n\n compareTo(other: NumericValue): number {\n return this.numericValue.comparedTo(other.numericValue);\n }\n}\n\nexport type NumericValueType = {\n numericValue: Decimal;\n};\n"]}
1
+ {"version":3,"sources":["../../src/value/NumericValue.ts"],"names":[],"mappings":";;;AAAA,2CAAqC;AAIrC,+CAAwC;AAExC,MAAa,YAAY;IAGvB,YAAY,KAAgC;QAC1C,IAAI,oBAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAC5B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;SAC3B;QACD,IAAI,CAAC,YAAY,GAAG,IAAI,oBAAO,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAgC;QAC/C,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,OAAO;QACL,OAAO,eAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAQ;QAChC,OAAO,oBAAO,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC;YACtC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CACzC,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;IAED,SAAS,CAAC,KAAmB;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;CACF;AAxCD,oCAwCC","file":"value/NumericValue.js","sourcesContent":["import { Decimal } from \"decimal.js\";\nimport { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\n\nexport class NumericValue implements Value<Decimal>, Comparable<NumericValue> {\n private readonly numericValue: Decimal;\n\n constructor(value: Decimal | string | number) {\n if (Decimal.isDecimal(value)) {\n this.numericValue = value;\n }\n this.numericValue = new Decimal(value);\n }\n\n public static of(value: Decimal | string | number): NumericValue {\n return new NumericValue(value);\n }\n\n getValue(): Decimal {\n return this.numericValue;\n }\n\n getType(): ExprType {\n return Type.NUMERIC;\n }\n\n static isNumericValueType(arg: any): arg is NumericValueType {\n return Decimal.isDecimal(arg.numericValue);\n }\n\n equals(other: Value<any>): boolean {\n return (\n NumericValue.isNumericValueType(other) &&\n this.numericValue.eq(other.numericValue)\n );\n }\n\n toString(): string {\n return this.numericValue.toString();\n }\n\n compareTo(other: NumericValue): number {\n return this.numericValue.comparedTo(other.numericValue);\n }\n}\n\nexport type NumericValueType = {\n numericValue: Decimal;\n};\n"]}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectAccessorValue = void 0;
4
4
  const IfcExpressionUtils_js_1 = require("../IfcExpressionUtils.js");
5
+ const Types_js_1 = require("../type/Types.js");
5
6
  class ObjectAccessorValue {
6
7
  constructor(objectAccessorValue) {
7
8
  this.objectAccessorValue = objectAccessorValue;
@@ -18,6 +19,9 @@ class ObjectAccessorValue {
18
19
  toString() {
19
20
  return "[Accessor for something in an IFC model]";
20
21
  }
22
+ getType() {
23
+ return Types_js_1.Type.IFC_OBJECT_REF;
24
+ }
21
25
  static isObjectAccessorValueType(arg) {
22
26
  return (!(0, IfcExpressionUtils_js_1.isNullish)(arg) &&
23
27
  !(0, IfcExpressionUtils_js_1.isNullish)(arg.objectAccessorValue) &&
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/value/ObjectAccessorValue.ts"],"names":[],"mappings":";;;AAEA,oEAAqD;AAErD,MAAa,mBAAmB;IAG9B,YAAY,mBAAmC;QAC7C,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAqB;QACpC,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,IAAI,CAAC,mBAAmB,KAAK,KAAK,EAAE,QAAQ,EAAE,CAAC;IACxD,CAAC;IAED,QAAQ;QACN,OAAO,0CAA0C,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,GAAQ;QACvC,OAAO,CACL,CAAC,IAAA,iCAAS,EAAC,GAAG,CAAC;YACf,CAAC,IAAA,iCAAS,EAAC,GAAG,CAAC,mBAAmB,CAAC;YACnC,GAAG,CAAC,mBAAmB,YAAY,mBAAmB,CACvD,CAAC;IACJ,CAAC;CACF;AA9BD,kDA8BC","file":"value/ObjectAccessorValue.js","sourcesContent":["import { ObjectAccessor } from \"../context/ObjectAccessor.js\";\nimport { Value } from \"./Value.js\";\nimport { isNullish } from \"../IfcExpressionUtils.js\";\n\nexport class ObjectAccessorValue implements Value<ObjectAccessor> {\n private readonly objectAccessorValue: ObjectAccessor;\n\n constructor(objectAccessorValue: ObjectAccessor) {\n this.objectAccessorValue = objectAccessorValue;\n }\n\n public static of(value: ObjectAccessor): ObjectAccessorValue {\n return new ObjectAccessorValue(value);\n }\n\n getValue(): ObjectAccessor {\n return this.objectAccessorValue;\n }\n\n equals(other: Value<any>): boolean {\n return this.objectAccessorValue === other?.getValue();\n }\n\n toString(): string {\n return \"[Accessor for something in an IFC model]\";\n }\n\n static isObjectAccessorValueType(arg: any): arg is ObjectAccessorValue {\n return (\n !isNullish(arg) &&\n !isNullish(arg.objectAccessorValue) &&\n arg.objectAccessorValue instanceof ObjectAccessorValue\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/value/ObjectAccessorValue.ts"],"names":[],"mappings":";;;AAEA,oEAAqD;AAErD,+CAAwC;AAExC,MAAa,mBAAmB;IAG9B,YAAY,mBAAmC;QAC7C,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAqB;QACpC,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,IAAI,CAAC,mBAAmB,KAAK,KAAK,EAAE,QAAQ,EAAE,CAAC;IACxD,CAAC;IAED,QAAQ;QACN,OAAO,0CAA0C,CAAC;IACpD,CAAC;IAED,OAAO;QACL,OAAO,eAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,GAAQ;QACvC,OAAO,CACL,CAAC,IAAA,iCAAS,EAAC,GAAG,CAAC;YACf,CAAC,IAAA,iCAAS,EAAC,GAAG,CAAC,mBAAmB,CAAC;YACnC,GAAG,CAAC,mBAAmB,YAAY,mBAAmB,CACvD,CAAC;IACJ,CAAC;CACF;AAlCD,kDAkCC","file":"value/ObjectAccessorValue.js","sourcesContent":["import { ObjectAccessor } from \"../context/ObjectAccessor.js\";\nimport { Value } from \"./Value.js\";\nimport { isNullish } from \"../IfcExpressionUtils.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\n\nexport class ObjectAccessorValue implements Value<ObjectAccessor> {\n private readonly objectAccessorValue: ObjectAccessor;\n\n constructor(objectAccessorValue: ObjectAccessor) {\n this.objectAccessorValue = objectAccessorValue;\n }\n\n public static of(value: ObjectAccessor): ObjectAccessorValue {\n return new ObjectAccessorValue(value);\n }\n\n getValue(): ObjectAccessor {\n return this.objectAccessorValue;\n }\n\n equals(other: Value<any>): boolean {\n return this.objectAccessorValue === other?.getValue();\n }\n\n toString(): string {\n return \"[Accessor for something in an IFC model]\";\n }\n\n getType(): ExprType {\n return Type.IFC_OBJECT_REF;\n }\n\n static isObjectAccessorValueType(arg: any): arg is ObjectAccessorValue {\n return (\n !isNullish(arg) &&\n !isNullish(arg.objectAccessorValue) &&\n arg.objectAccessorValue instanceof ObjectAccessorValue\n );\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReferenceValue = void 0;
4
+ const Types_js_1 = require("../type/Types.js");
4
5
  class ReferenceValue {
5
6
  constructor(value) {
6
7
  this.referenceValue = value;
@@ -11,6 +12,9 @@ class ReferenceValue {
11
12
  getValue() {
12
13
  return this.referenceValue;
13
14
  }
15
+ getType() {
16
+ return Types_js_1.Type.STRING;
17
+ }
14
18
  equals(other) {
15
19
  return (ReferenceValue.isReferenceValueType(other) &&
16
20
  other.referenceValue === this.referenceValue);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/value/ReferenceValue.ts"],"names":[],"mappings":";;;AAEA,MAAa,cAAc;IAGzB,YAAY,KAAa;QACvB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAa;QAC5B,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,cAAc,CAAC,oBAAoB,CAAC,KAAK,CAAC;YAC1C,KAAK,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,CAC7C,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,oBAAoB,CAAC,GAAQ;QAClC,OAAO,OAAO,GAAG,CAAC,cAAc,KAAK,QAAQ,CAAC;IAChD,CAAC;CACF;AA7BD,wCA6BC","file":"value/ReferenceValue.js","sourcesContent":["import { Value } from \"./Value.js\";\n\nexport class ReferenceValue implements Value<string> {\n private readonly referenceValue: string;\n\n constructor(value: string) {\n this.referenceValue = value;\n }\n\n public static of(value: string): ReferenceValue {\n return new ReferenceValue(value);\n }\n\n getValue(): string {\n return this.referenceValue;\n }\n\n equals(other: Value<any>): boolean {\n return (\n ReferenceValue.isReferenceValueType(other) &&\n other.referenceValue === this.referenceValue\n );\n }\n\n toString(): string {\n return this.referenceValue;\n }\n\n static isReferenceValueType(arg: any): arg is ReferenceValueType {\n return typeof arg.referenceValue === \"string\";\n }\n}\n\nexport type ReferenceValueType = {\n referenceValue: string;\n};\n"]}
1
+ {"version":3,"sources":["../../src/value/ReferenceValue.ts"],"names":[],"mappings":";;;AAEA,+CAAwC;AAExC,MAAa,cAAc;IAGzB,YAAY,KAAa;QACvB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAa;QAC5B,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO,eAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,cAAc,CAAC,oBAAoB,CAAC,KAAK,CAAC;YAC1C,KAAK,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,CAC7C,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,oBAAoB,CAAC,GAAQ;QAClC,OAAO,OAAO,GAAG,CAAC,cAAc,KAAK,QAAQ,CAAC;IAChD,CAAC;CACF;AAjCD,wCAiCC","file":"value/ReferenceValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\n\nexport class ReferenceValue implements Value<string> {\n private readonly referenceValue: string;\n\n constructor(value: string) {\n this.referenceValue = value;\n }\n\n public static of(value: string): ReferenceValue {\n return new ReferenceValue(value);\n }\n\n getValue(): string {\n return this.referenceValue;\n }\n\n getType(): ExprType {\n return Type.STRING;\n }\n\n equals(other: Value<any>): boolean {\n return (\n ReferenceValue.isReferenceValueType(other) &&\n other.referenceValue === this.referenceValue\n );\n }\n\n toString(): string {\n return this.referenceValue;\n }\n\n static isReferenceValueType(arg: any): arg is ReferenceValueType {\n return typeof arg.referenceValue === \"string\";\n }\n}\n\nexport type ReferenceValueType = {\n referenceValue: string;\n};\n"]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StringValue = void 0;
4
+ const Types_js_1 = require("../type/Types.js");
4
5
  class StringValue {
5
6
  constructor(value) {
6
7
  this.stringValue = value;
@@ -21,6 +22,9 @@ class StringValue {
21
22
  compareTo(other) {
22
23
  return StringValue.collator.compare(this.stringValue, other.stringValue);
23
24
  }
25
+ getType() {
26
+ return Types_js_1.Type.STRING;
27
+ }
24
28
  static isStringValueType(arg) {
25
29
  return typeof arg.stringValue === "string";
26
30
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/value/StringValue.ts"],"names":[],"mappings":";;;AAGA,MAAa,WAAW;IAItB,YAAY,KAAa;QACvB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAa;QAC5B,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,WAAW,CAAC,iBAAiB,CAAC,KAAK,CAAC;YACpC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CACvC,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,KAAkB;QAC1B,OAAO,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,GAAQ;QAC/B,OAAO,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ,CAAC;IAC7C,CAAC;;AAjCH,kCAkCC;AAhCgB,oBAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC","file":"value/StringValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\n\nexport class StringValue implements Value<string>, Comparable<StringValue> {\n private readonly stringValue: string;\n private static collator = new Intl.Collator();\n\n constructor(value: string) {\n this.stringValue = value;\n }\n\n public static of(value: string): StringValue {\n return new StringValue(value);\n }\n\n getValue(): string {\n return this.stringValue;\n }\n\n toString(): string {\n return this.stringValue;\n }\n\n equals(other: Value<any>): boolean {\n return (\n StringValue.isStringValueType(other) &&\n other.stringValue === this.stringValue\n );\n }\n\n compareTo(other: StringValue): number {\n return StringValue.collator.compare(this.stringValue, other.stringValue);\n }\n\n static isStringValueType(arg: any): arg is StringValueType {\n return typeof arg.stringValue === \"string\";\n }\n}\n\nexport type StringValueType = {\n stringValue: string;\n};\n"]}
1
+ {"version":3,"sources":["../../src/value/StringValue.ts"],"names":[],"mappings":";;;AAEA,+CAAwC;AAGxC,MAAa,WAAW;IAItB,YAAY,KAAa;QACvB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,EAAE,CAAC,KAAa;QAC5B,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,WAAW,CAAC,iBAAiB,CAAC,KAAK,CAAC;YACpC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CACvC,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,KAAkB;QAC1B,OAAO,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,OAAO,eAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,GAAQ;QAC/B,OAAO,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ,CAAC;IAC7C,CAAC;;AArCH,kCAsCC;AApCgB,oBAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC","file":"value/StringValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { Type } from \"../type/Types.js\";\nimport { ExprType } from \"../type/ExprType.js\";\n\nexport class StringValue implements Value<string>, Comparable<StringValue> {\n private readonly stringValue: string;\n private static collator = new Intl.Collator();\n\n constructor(value: string) {\n this.stringValue = value;\n }\n\n public static of(value: string): StringValue {\n return new StringValue(value);\n }\n\n getValue(): string {\n return this.stringValue;\n }\n\n toString(): string {\n return this.stringValue;\n }\n\n equals(other: Value<any>): boolean {\n return (\n StringValue.isStringValueType(other) &&\n other.stringValue === this.stringValue\n );\n }\n\n compareTo(other: StringValue): number {\n return StringValue.collator.compare(this.stringValue, other.stringValue);\n }\n\n getType(): ExprType {\n return Type.STRING;\n }\n\n static isStringValueType(arg: any): arg is StringValueType {\n return typeof arg.stringValue === \"string\";\n }\n}\n\nexport type StringValueType = {\n stringValue: string;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/value/Value.ts"],"names":[],"mappings":"","file":"value/Value.js","sourcesContent":["import { BoxedValueTypes } from \"./BoxedValueTypes.js\";\n\nexport interface Value<\n T extends\n | BoxedValueTypes\n | Array<Value<BoxedValueTypes | Array<Value<BoxedValueTypes>>>>\n> {\n getValue(): T;\n equals(other: Value<any>): boolean;\n toString();\n}\n"]}
1
+ {"version":3,"sources":["../../src/value/Value.ts"],"names":[],"mappings":"","file":"value/Value.js","sourcesContent":["import { BoxedValueTypes } from \"./BoxedValueTypes.js\";\nimport { ExprType } from \"../type/ExprType.js\";\n\nexport interface Value<\n T extends\n | BoxedValueTypes\n | Array<Value<BoxedValueTypes | Array<Value<BoxedValueTypes>>>>\n> {\n getValue(): T;\n equals(other: Value<any>): boolean;\n toString();\n getType(): ExprType;\n}\n"]}
@@ -224,8 +224,8 @@ export class ExprVisitor extends IfcExpressionVisitor {
224
224
  if (this.typeManager.isString(ctx._left, ctx._right)) {
225
225
  return new StringConcatExpr(this.visit(ctx._left), this.visit(ctx._right));
226
226
  }
227
- if (this.typeManager.isString(ctx._left, ctx._right) ||
228
- this.typeManager.isNumeric(ctx._left, ctx._right)) {
227
+ if (this.typeManager.overlapsWithString(ctx._left, ctx._right) ||
228
+ this.typeManager.overlapsWithNumeric(ctx._left, ctx._right)) {
229
229
  return new PlusOrConcatExpr(this.visit(ctx._left), this.visit(ctx._right));
230
230
  }
231
231
  throw new ExpressionTypeError("Operator '+' requires the operands to be either both of type numeric or both of type string, but they are not.", ctx);