Переглянути джерело

Move __INLINEIF function to Functions.cs

Bepis 6 роки тому
батько
коміт
6b3b6bbf8e

+ 9 - 0
NTERA.Engine/Runtime/Base/Functions.cs

@@ -45,6 +45,15 @@ namespace NTERA.Engine.Runtime.Base
 			return parameters[0].Value.String.PadLeft((int)parameters[1].Value.Real);
 		}
 
+		[Function("__INLINEIF")]
+		public static Value InlineIf(EraRuntime runtime, StackFrame context, IList<Parameter> parameters)
+		{
+			// For syntax like \@THIRD_PERSON?Third Person#Second Person\@
+			return parameters[0].Value
+				? parameters[1].Value
+				: parameters[2].Value;
+		}
+
 		[Function("TOSTR")]
 		public static Value ToStr(EraRuntime runtime, StackFrame context, IList<Parameter> parameters)
 		{

+ 1 - 9
NTERA.Engine/Runtime/EraRuntime.cs

@@ -376,15 +376,7 @@ namespace NTERA.Engine.Runtime
 
 				case "call":
 					string functionName = expressionNode["target"];
-					if (functionName == "__INLINEIF") {
-						// For syntax like \@THIRD_PERSON?Third Person#Second Person\@
-						var node = expressionNode.GetSubtype("parameters");
-						bool condition = ComputeExpression(context, node[0]).Real != 0;
-						if (condition)
-							return ComputeExpression(context, node[1]);
-						else
-							return ComputeExpression(context, node[2]);
-					}
+					
 					var function = TotalProcedureDefinitions.FirstOrDefault(func => func.IsReturnFunction && func.Name.Equals(functionName, StringComparison.OrdinalIgnoreCase));
 
 					if (function == null)