private ScriptProcedures ListProcedures(Script script, Regex pattern) { ScriptProcedures procedures = new ScriptProcedures(); foreach (IMSScriptModule msc_module in _scriptcontrol.Modules) { ScriptModule module = new ScriptModule(msc_module); foreach (IMSScriptProcedure msc_procedure in msc_module.Procedures) { var proc_name = msc_procedure.Name; ScriptProcedure procedure = new ScriptProcedure(module, proc_name); switch (proc_name.ToLower()) { case "initialize": procedures.ProcInitialize = procedure; break; case "terminate": procedures.ProcTerminate = procedure; break; case "setup": procedures.ProcSetup = procedure; break; case "teardown": procedures.ProcTearDown = procedure; break; case "onerror": procedures.ProcOnError = procedure; break; case "iif": break; default: if (msc_procedure.HasReturnValue) continue; if (!pattern.IsMatch(proc_name)) continue; WithParams proc_params_str; if (script.ScriptWithParams.TryGetValue(proc_name, out proc_params_str)) { if (!_scriptcontrol.Eval("Array(" + proc_params_str.Params + ')')) { var error = new ScriptError(script, procedure, "Invalide array: " + proc_params_str.Params); error.AddTrace(script, proc_params_str.Line); OnError(error); continue; } var proc_params = (object[])_scriptcontrol.Result; foreach (var proc_param in proc_params) { object[] args = CastToArray(proc_param); if (args.Length == 0) { var error = new ScriptError(script, procedure, string.Format( "Procedure {0} requires {1} argument(s). {2} provied.", proc_name, msc_procedure.NumArgs, args.Length)); error.AddTrace(script, script.TextFormated.GetLineNumber("(Sub|Function).\b" + proc_name + "\b")); OnError(error); break; } procedure = new ScriptProcedure(module, proc_name, args); procedures.Add(procedure); } } else if (msc_procedure.NumArgs == 0) { procedures.Add(procedure); } break; } } } return procedures; }
private ScriptProcedures ListProcedures(Script script, Regex pattern) { ScriptProcedures procedures = new ScriptProcedures(); foreach (IMSScriptModule msc_module in _scriptcontrol.Modules) { ScriptModule module = new ScriptModule(msc_module); foreach (IMSScriptProcedure msc_procedure in msc_module.Procedures) { var proc_name = msc_procedure.Name; ScriptProcedure procedure = new ScriptProcedure(module, proc_name); switch (proc_name.ToLower()) { case "initialize": procedures.ProcInitialize = procedure; break; case "terminate": procedures.ProcTerminate = procedure; break; case "setup": procedures.ProcSetup = procedure; break; case "teardown": procedures.ProcTearDown = procedure; break; case "onerror": procedures.ProcOnError = procedure; break; case "iif": break; default: if (msc_procedure.HasReturnValue) { continue; } if (!pattern.IsMatch(proc_name)) { continue; } WithParams proc_params_str; if (script.ScriptWithParams.TryGetValue(proc_name, out proc_params_str)) { if (!_scriptcontrol.Eval("Array(" + proc_params_str.Params + ')')) { var error = new ScriptError(script, procedure, "Invalide array: " + proc_params_str.Params); error.AddTrace(script, proc_params_str.Line); OnError(error); continue; } var proc_params = (object[])_scriptcontrol.Result; foreach (var proc_param in proc_params) { object[] args = CastToArray(proc_param); if (args.Length == 0) { var error = new ScriptError(script, procedure, string.Format( "Procedure {0} requires {1} argument(s). {2} provied.", proc_name, msc_procedure.NumArgs, args.Length)); error.AddTrace(script, script.TextFormated.GetLineNumber("(Sub|Function).\b" + proc_name + "\b")); OnError(error); break; } procedure = new ScriptProcedure(module, proc_name, args); procedures.Add(procedure); } } else if (msc_procedure.NumArgs == 0) { procedures.Add(procedure); } break; } } } return(procedures); }