@@ -418,7 +418,8 @@ private bool EvaluateNumber(string restOfExpression, Stack<object> stack, ref in
418
418
string type = numberMatch . Groups [ "type" ] . Value . ToLower ( ) ;
419
419
string numberNoType = numberMatch . Value . Replace ( type , string . Empty ) ;
420
420
421
- if ( numberSuffixToParse . TryGetValue ( type , out Func < string , object > parseFunc ) )
421
+ Func < string , object > parseFunc = null ;
422
+ if ( numberSuffixToParse . TryGetValue ( type , out parseFunc ) )
422
423
{
423
424
stack . Push ( parseFunc ( numberNoType ) ) ;
424
425
}
@@ -454,6 +455,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
454
455
if ( varFuncMatch . Groups [ "isfunction" ] . Success )
455
456
{
456
457
List < string > funcArgs = GetExpressionsBetweenParenthis ( expr , ref i , true ) ;
458
+ object funcResult = null ;
457
459
if ( varFuncMatch . Groups [ "inObject" ] . Success )
458
460
{
459
461
if ( stack . Count == 0 || stack . Peek ( ) is ExpressionOperator )
@@ -515,7 +517,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
515
517
516
518
}
517
519
}
518
- else if ( DefaultFunctions ( varFuncMatch . Groups [ "name" ] . Value . ToLower ( ) , funcArgs , out object funcResult ) )
520
+ else if ( DefaultFunctions ( varFuncMatch . Groups [ "name" ] . Value . ToLower ( ) , funcArgs , out funcResult ) )
519
521
{
520
522
stack . Push ( funcResult ) ;
521
523
}
@@ -540,11 +542,13 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
540
542
string completeVar = varFuncMatch . Groups [ "name" ] . Value ;
541
543
string var = completeVar . ToLower ( ) ;
542
544
543
- if ( defaultVariables . TryGetValue ( var , out object varValueToPush ) )
545
+ object varValueToPush = null ;
546
+ object cusVarValueToPush = null ;
547
+ if ( defaultVariables . TryGetValue ( var , out varValueToPush ) )
544
548
{
545
549
stack . Push ( varValueToPush ) ;
546
550
}
547
- else if ( Variables . TryGetValue ( var , out object cusVarValueToPush ) )
551
+ else if ( Variables . TryGetValue ( var , out cusVarValueToPush ) )
548
552
{
549
553
stack . Push ( cusVarValueToPush ) ;
550
554
}
@@ -816,7 +820,8 @@ private bool EvaluateString(string expr, string s, string restOfExpression, Stac
816
820
{
817
821
i ++ ;
818
822
819
- if ( stringEscapedCharDict . TryGetValue ( expr . Substring ( i , expr . Length - i ) [ 0 ] , out string escapedString ) )
823
+ string escapedString = null ;
824
+ if ( stringEscapedCharDict . TryGetValue ( expr . Substring ( i , expr . Length - i ) [ 0 ] , out escapedString ) )
820
825
{
821
826
resultString += escapedString ;
822
827
i ++ ;
@@ -1115,15 +1120,18 @@ private bool DefaultFunctions(string name, List<string> args, out object result)
1115
1120
{
1116
1121
bool functionExists = true ;
1117
1122
1118
- if ( simpleDoubleMathFuncsDictionary . TryGetValue ( name , out Func < double , double > func ) )
1123
+ Func < double , double > func = null ;
1124
+ Func < double , double , double > func2 = null ;
1125
+ Func < ExpressionEvaluator , List < string > , object > complexFunc = null ;
1126
+ if ( simpleDoubleMathFuncsDictionary . TryGetValue ( name , out func ) )
1119
1127
{
1120
1128
result = func ( Convert . ToDouble ( Evaluate ( args [ 0 ] ) ) ) ;
1121
1129
}
1122
- else if ( doubleDoubleMathFuncsDictionary . TryGetValue ( name , out Func < double , double , double > func2 ) )
1130
+ else if ( doubleDoubleMathFuncsDictionary . TryGetValue ( name , out func2 ) )
1123
1131
{
1124
1132
result = func2 ( Convert . ToDouble ( Evaluate ( args [ 0 ] ) ) , Convert . ToDouble ( Evaluate ( args [ 1 ] ) ) ) ;
1125
1133
}
1126
- else if ( complexStandardFuncsDictionary . TryGetValue ( name , out Func < ExpressionEvaluator , List < string > , object > complexFunc ) )
1134
+ else if ( complexStandardFuncsDictionary . TryGetValue ( name , out complexFunc ) )
1127
1135
{
1128
1136
result = complexFunc ( this , args ) ;
1129
1137
}
0 commit comments