1010using ToolGood . Algorithm . LitJson ;
1111using ToolGood . Algorithm . MathNet . Numerics ;
1212
13- namespace ToolGood . Algorithm
13+ namespace ToolGood . Algorithm . Internals
1414{
1515 class MathVisitor : AbstractParseTreeVisitor < Operand > , ImathVisitor < Operand >
1616 {
@@ -58,7 +58,7 @@ public Operand VisitMulDiv_fun(mathParser.MulDiv_funContext context)
5858 if ( a . IsError == false ) secondValue = a ;
5959 }
6060 }
61- if ( t == "*" ) {
61+ if ( CharUtil . Equals ( t , "*" ) ) {
6262 if ( secondValue . Type == OperandType . BOOLEAN ) {
6363 if ( secondValue . BooleanValue )
6464 return firstValue ;
@@ -86,7 +86,7 @@ public Operand VisitMulDiv_fun(mathParser.MulDiv_funContext context)
8686 secondValue = secondValue . ToNumber ( $ "Function '{ t } ' parameter 2 is error!") ;
8787 if ( secondValue . IsError ) { return secondValue ; }
8888 return Operand . Create ( firstValue . NumberValue * secondValue . NumberValue ) ;
89- } else if ( t == "/" ) {
89+ } else if ( CharUtil . Equals ( t , "/" ) ) {
9090 if ( firstValue . Type == OperandType . DATE ) {
9191 return Operand . Create ( firstValue . DateValue / secondValue . NumberValue ) ;
9292 }
@@ -99,7 +99,7 @@ public Operand VisitMulDiv_fun(mathParser.MulDiv_funContext context)
9999 return Operand . Error ( $ "Function '{ t } ' parameter 2 is error!") ;
100100 }
101101 return Operand . Create ( firstValue . NumberValue / secondValue . NumberValue ) ;
102- } else if ( t == "%" ) {
102+ } else if ( CharUtil . Equals ( t , "%" ) ) {
103103 firstValue = firstValue . ToNumber ( "% fun right value" ) ;
104104 if ( firstValue . IsError ) { return firstValue ; }
105105 secondValue = secondValue . ToNumber ( "% fun right value" ) ;
@@ -121,7 +121,7 @@ public Operand VisitAddSub_fun(mathParser.AddSub_funContext context)
121121 var secondValue = args [ 1 ] ;
122122 var t = context . op . Text ;
123123
124- if ( t == "&" ) {
124+ if ( CharUtil . Equals ( t , "&" ) ) {
125125 if ( firstValue . IsNull && secondValue . IsNull ) {
126126 return firstValue ;
127127 } else if ( firstValue . IsNull ) {
@@ -156,7 +156,7 @@ public Operand VisitAddSub_fun(mathParser.AddSub_funContext context)
156156 if ( a . IsError == false ) secondValue = a ;
157157 }
158158 }
159- if ( t == "+" ) {
159+ if ( CharUtil . Equals ( t , "+" ) ) {
160160 if ( firstValue . Type == OperandType . DATE && secondValue . Type == OperandType . DATE ) {
161161 return Operand . Create ( firstValue . DateValue + secondValue . DateValue ) ;
162162 } else if ( firstValue . Type == OperandType . DATE ) {
@@ -173,7 +173,7 @@ public Operand VisitAddSub_fun(mathParser.AddSub_funContext context)
173173 secondValue = secondValue . ToNumber ( $ "Function '{ t } ' parameter 2 is error!") ;
174174 if ( secondValue . IsError ) { return secondValue ; }
175175 return Operand . Create ( firstValue . NumberValue + secondValue . NumberValue ) ;
176- } else if ( t == "-" ) {
176+ } else if ( CharUtil . Equals ( t , "-" ) ) {
177177 if ( firstValue . Type == OperandType . DATE && secondValue . Type == OperandType . DATE ) {
178178 return Operand . Create ( firstValue . DateValue - secondValue . DateValue ) ;
179179 } else if ( firstValue . Type == OperandType . DATE ) {
@@ -204,14 +204,14 @@ public Operand VisitJudge_fun(mathParser.Judge_funContext context)
204204 string type = context . op . Text ;
205205
206206 if ( firstValue . IsNull ) {
207- if ( secondValue . IsNull && ( type == "==" || type == " =") ) {
207+ if ( secondValue . IsNull && CharUtil . Equals ( type , "=" , "==" , "== =") ) {
208208 return Operand . True ;
209- } else if ( secondValue . IsNull == false && ( type == "<>" || type == "!=" ) ) {
209+ } else if ( secondValue . IsNull == false && CharUtil . Equals ( type , "<>" , "!=" ) ) {
210210 return Operand . True ;
211211 }
212212 return Operand . False ;
213213 } else if ( secondValue . IsNull ) {
214- if ( type == "==" || type == "=" ) {
214+ if ( CharUtil . Equals ( type , "=" , "==" , "===" ) ) {
215215 return Operand . False ;
216216 }
217217 return Operand . True ;
@@ -264,15 +264,15 @@ public Operand VisitJudge_fun(mathParser.Judge_funContext context)
264264
265265 r = Compare ( firstValue . NumberValue , secondValue . NumberValue ) ;
266266 }
267- if ( type == "<" ) {
267+ if ( CharUtil . Equals ( type , "<" ) ) {
268268 return Operand . Create ( r == - 1 ) ;
269- } else if ( type == "<=" ) {
269+ } else if ( CharUtil . Equals ( type , "<=" ) ) {
270270 return Operand . Create ( r <= 0 ) ;
271- } else if ( type == ">" ) {
271+ } else if ( CharUtil . Equals ( type , ">" ) ) {
272272 return Operand . Create ( r == 1 ) ;
273- } else if ( type == ">=" ) {
273+ } else if ( CharUtil . Equals ( type , ">=" ) ) {
274274 return Operand . Create ( r >= 0 ) ;
275- } else if ( type == "=" || type == "==" ) {
275+ } else if ( CharUtil . Equals ( type , "=" , "==" , "===" ) ) {
276276 return Operand . Create ( r == 0 ) ;
277277 }
278278 return Operand . Create ( r != 0 ) ;
@@ -298,7 +298,7 @@ public Operand VisitAndOr_fun(mathParser.AndOr_funContext context)
298298 var t = context . op . Text ;
299299 var first = this . Visit ( context . expr ( 0 ) ) . ToBoolean ( $ "Function '{ t } ' parameter 1 is error!") ;
300300 if ( first . IsError ) { return first ; }
301- if ( t == "&&" || t . Equals ( "and" , StringComparison . OrdinalIgnoreCase ) ) {
301+ if ( CharUtil . Equals ( t , "&&" ) || t . Equals ( "and" , StringComparison . OrdinalIgnoreCase ) ) {
302302 if ( first . BooleanValue == false ) return Operand . False ;
303303 } else {
304304 if ( first . BooleanValue ) return Operand . True ;
0 commit comments