static bool UpdateIfTernary(ParsingScript script, string token, char ch, List <Variable> listInput, Action <List <Variable> > listToMerge) { if (listInput.Count < 1 || ch != Constants.TERNARY_OPERATOR || token.Length > 0) { return(false); } Variable result; Variable arg1 = MergeList(listInput, script); script.MoveForwardIf(Constants.TERNARY_OPERATOR); double condition = arg1.AsDouble(); if (condition != 0) { result = script.Execute(Constants.TERNARY_SEPARATOR); script.MoveForwardIf(Constants.TERNARY_SEPARATOR); Utils.SkipRestExpr(script, Constants.END_STATEMENT); } else { Utils.SkipRestExpr(script, Constants.TERNARY_SEPARATOR[0]); script.MoveForwardIf(Constants.TERNARY_SEPARATOR); result = script.Execute(Constants.NEXT_OR_END_ARRAY); } listInput.Clear(); listInput.Add(result); listToMerge(listInput); return(true); }
protected override Variable Evaluate(ParsingScript script) { List <Variable> args = script.GetFunctionArgs(); Utils.CheckArgs(args.Count, 1, m_name, true); string filename = args[0].AsString(); string pathname = script.GetFilePath(filename); EncodeFileFunction.EncodeDecode(pathname, false); ParsingScript tempScript = script.GetIncludeFileScript(filename); string includeScript = tempScript.String; EncodeFileFunction.EncodeDecode(pathname, true); Variable result = null; if (script.Debugger != null) { result = script.Debugger.StepInIncludeIfNeeded(tempScript).Result; } while (tempScript.Pointer < includeScript.Length) { result = tempScript.Execute(); tempScript.GoToNextStatement(); } return(result == null ? Variable.EmptyInstance : result); }
public static Variable RunString(string str) { ParsingScript tempScript = new ParsingScript(str); Variable result = tempScript.Execute(); return(result); }
public static GetVarFunction ExtractArrayElement(string token) { if (!token.Contains(Constants.START_ARRAY)) { return(null); } ParsingScript tempScript = new ParsingScript(token); Variable result = tempScript.Execute(); return(new GetVarFunction(result)); }
public static async Task<Variable> Execute(ParsingScript script) { char[] toArray = Constants.END_PARSE_ARRAY; Variable result = null; Exception exception = null; #if UNITY_EDITOR || UNITY_STANDALONE || MAIN_THREAD_CHECK // Do nothing: already on the main thread #elif __ANDROID__ scripting.Droid.MainActivity.TheView.RunOnUiThread(() => { #elif __IOS__ scripting.iOS.AppDelegate.GetCurrentController().InvokeOnMainThread(() => { #else #endif try { #if __IOS__ || __ANDROID__ result = script.Execute(toArray); #else result = await script.ExecuteAsync(toArray); #endif } catch (ParsingException exc) { exception = exc; } #if UNITY_EDITOR || UNITY_STANDALONE || MAIN_THREAD_CHECK // Do nothing: already on the main thread or main thread is not required #elif __ANDROID__ || __IOS__ }); #endif if (exception != null) { throw exception; } return result; } }