private SObject ExecuteExecutable(ScriptStatement statement) { if (statement.IsCompoundStatement) { ScriptProcessor processor = new ScriptProcessor(Context); // Remove { and }: string code = statement.Code.Remove(0, 1); code = code.Remove(code.Length - 1, 1); var returnObject = processor.Run(code); _breakIssued = processor._breakIssued; _continueIssued = processor._continueIssued; _returnIssued = processor._returnIssued; return returnObject; } else { string exp = ResolveParentheses(statement.Code).Trim(); #region QuickConvert // have quick conversions for small statements here // parameter statements are much faster that way: if (exp == SObject.LITERAL_BOOL_TRUE) { return CreateBool(true); } else if (exp == SObject.LITERAL_BOOL_FALSE) { return CreateBool(false); } else if (exp == SObject.LITERAL_UNDEFINED) { return Undefined; } else if (exp == SObject.LITERAL_NULL) { return Null; } else if (exp.StartsWith("\"") && exp.EndsWith("\"") && !exp.Remove(exp.Length - 1, 1).Remove(0, 1).Contains("\"")) { return CreateString(exp.Remove(exp.Length - 1, 1).Remove(0, 1)); } #endregion if (exp.Contains(".")) exp = EvaluateOperatorLeftToRight(exp, "."); if (exp.Contains("++")) exp = EvaluateOperatorLeftToRight(exp, "++"); if (exp.Contains("--")) exp = EvaluateOperatorLeftToRight(exp, "--"); if (exp.Contains("**")) exp = EvaluateOperatorLeftToRight(exp, "**"); if (exp.Contains("*")) exp = EvaluateOperatorLeftToRight(exp, "*"); if (exp.Contains("/")) exp = EvaluateOperatorLeftToRight(exp, "/"); if (exp.Contains("%")) exp = EvaluateOperatorLeftToRight(exp, "%"); if (exp.Contains("+")) exp = EvaluateOperatorLeftToRight(exp, "+"); if (exp.Contains("-")) exp = EvaluateOperatorLeftToRight(exp, "-"); if (exp.Contains("<=")) exp = EvaluateOperatorLeftToRight(exp, "<="); if (exp.Contains(">=")) exp = EvaluateOperatorLeftToRight(exp, ">="); if (exp.Contains("<")) exp = EvaluateOperatorLeftToRight(exp, "<"); if (exp.Contains(">")) exp = EvaluateOperatorLeftToRight(exp, ">"); if (exp.Contains("===")) exp = EvaluateOperatorLeftToRight(exp, "==="); if (exp.Contains("!==")) exp = EvaluateOperatorLeftToRight(exp, "!=="); if (exp.Contains("==")) exp = EvaluateOperatorLeftToRight(exp, "=="); if (exp.Contains("!=")) exp = EvaluateOperatorLeftToRight(exp, "!="); if (exp.Contains("&&")) exp = EvaluateOperatorLeftToRight(exp, "&&"); if (exp.Contains("||")) exp = EvaluateOperatorLeftToRight(exp, "||"); return ToScriptObject(exp); } }
internal SObject ExecuteStatement(ScriptStatement statement) { switch (statement.StatementType) { case StatementType.Executable: return ExecuteExecutable(statement); case StatementType.If: break; case StatementType.Else: break; case StatementType.ElseIf: break; case StatementType.Using: break; case StatementType.Var: break; case StatementType.While: break; case StatementType.Return: break; case StatementType.Assignment: break; case StatementType.For: break; case StatementType.Function: break; case StatementType.Class: break; case StatementType.Link: break; case StatementType.Continue: break; case StatementType.Break: break; case StatementType.Throw: break; case StatementType.Try: break; case StatementType.Catch: break; case StatementType.Finally: break; default: break; } return null; }