From 6322f06bee3a214f62074e4198d8175cf8c770e6 Mon Sep 17 00:00:00 2001 From: "SAPIENT\\akesar" Date: Thu, 23 Mar 2017 00:27:18 +0530 Subject: [PATCH 1/2] Added Logical operators to the list of supported operators. --- lib/conditionHandler.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/conditionHandler.js b/lib/conditionHandler.js index 27a31f1..ca3ed9f 100644 --- a/lib/conditionHandler.js +++ b/lib/conditionHandler.js @@ -28,6 +28,12 @@ var ConditionHandler; return this.evaluateExpression(parent, mexp.property); case 'Literal': return exp.value; + case 'LogicalExpression': + var lexp = exp; + var value1 = this.evaluateExpression(object, lexp.left); + var value2 = this.evaluateExpression(object, lexp.right); + var b = this.calculateExpression(lexp.operator, value1, value2); + return b; default: throw new Error('condition type ' + exp.type + ' is not recognized'); } @@ -66,6 +72,10 @@ var ConditionHandler; return value1 / value2; case '%': return value1 % value2; + case '&&': + return value1 && value2; + case '||': + return value1 || value2; default: break; } From 4f306839b5f424acff395fbac7289c13efc3e0ae Mon Sep 17 00:00:00 2001 From: "SAPIENT\\akesar" Date: Thu, 23 Mar 2017 00:31:50 +0530 Subject: [PATCH 2/2] Added logical operator and expression --- lib/conditionHandler.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/conditionHandler.js b/lib/conditionHandler.js index ca3ed9f..d0d6003 100644 --- a/lib/conditionHandler.js +++ b/lib/conditionHandler.js @@ -28,7 +28,8 @@ var ConditionHandler; return this.evaluateExpression(parent, mexp.property); case 'Literal': return exp.value; - case 'LogicalExpression': + //added Logical Expression + case 'LogicalExpression': var lexp = exp; var value1 = this.evaluateExpression(object, lexp.left); var value2 = this.evaluateExpression(object, lexp.right); @@ -72,6 +73,7 @@ var ConditionHandler; return value1 / value2; case '%': return value1 % value2; + //added logical operators case '&&': return value1 && value2; case '||':