Skip to content

Commit cbd84ee

Browse files
committed
Remove C# 6.0 features to please Mono version on macOS Travis.
1 parent 430bbdb commit cbd84ee

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/Generator/Utils/ExpressionEvaluator.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ private bool EvaluateNumber(string restOfExpression, Stack<object> stack, ref in
418418
string type = numberMatch.Groups["type"].Value.ToLower();
419419
string numberNoType = numberMatch.Value.Replace(type, string.Empty);
420420

421-
if (numberSuffixToParse.TryGetValue(type, out Func<string, object> parseFunc))
421+
Func<string, object> parseFunc = null;
422+
if (numberSuffixToParse.TryGetValue(type, out parseFunc))
422423
{
423424
stack.Push(parseFunc(numberNoType));
424425
}
@@ -454,6 +455,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
454455
if (varFuncMatch.Groups["isfunction"].Success)
455456
{
456457
List<string> funcArgs = GetExpressionsBetweenParenthis(expr, ref i, true);
458+
object funcResult = null;
457459
if (varFuncMatch.Groups["inObject"].Success)
458460
{
459461
if (stack.Count == 0 || stack.Peek() is ExpressionOperator)
@@ -515,7 +517,7 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
515517

516518
}
517519
}
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))
519521
{
520522
stack.Push(funcResult);
521523
}
@@ -540,11 +542,13 @@ private bool EvaluateVarOrFunc(string expr, string restOfExpression, Stack<objec
540542
string completeVar = varFuncMatch.Groups["name"].Value;
541543
string var = completeVar.ToLower();
542544

543-
if (defaultVariables.TryGetValue(var, out object varValueToPush))
545+
object varValueToPush = null;
546+
object cusVarValueToPush = null;
547+
if (defaultVariables.TryGetValue(var, out varValueToPush))
544548
{
545549
stack.Push(varValueToPush);
546550
}
547-
else if (Variables.TryGetValue(var, out object cusVarValueToPush))
551+
else if (Variables.TryGetValue(var, out cusVarValueToPush))
548552
{
549553
stack.Push(cusVarValueToPush);
550554
}
@@ -816,7 +820,8 @@ private bool EvaluateString(string expr, string s, string restOfExpression, Stac
816820
{
817821
i++;
818822

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))
820825
{
821826
resultString += escapedString;
822827
i++;
@@ -1115,15 +1120,18 @@ private bool DefaultFunctions(string name, List<string> args, out object result)
11151120
{
11161121
bool functionExists = true;
11171122

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))
11191127
{
11201128
result = func(Convert.ToDouble(Evaluate(args[0])));
11211129
}
1122-
else if (doubleDoubleMathFuncsDictionary.TryGetValue(name, out Func<double, double, double> func2))
1130+
else if (doubleDoubleMathFuncsDictionary.TryGetValue(name, out func2))
11231131
{
11241132
result = func2(Convert.ToDouble(Evaluate(args[0])), Convert.ToDouble(Evaluate(args[1])));
11251133
}
1126-
else if (complexStandardFuncsDictionary.TryGetValue(name, out Func<ExpressionEvaluator, List<string>, object> complexFunc))
1134+
else if (complexStandardFuncsDictionary.TryGetValue(name, out complexFunc))
11271135
{
11281136
result = complexFunc(this, args);
11291137
}

0 commit comments

Comments
 (0)