Exemple #1
0
 private void OnError(ScriptError error) {
     _scriptresults.Add(error);
     Logger.LogScriptError(error);
     if (_debug) {
         ScriptDebugger.Debug(_scriptcontrol, true);
     }
 }
 private void OnError(ScriptError error) {
     this.Results.Add(error);
     error.Script.Succeed = false;
     StdInOut.LogScriptError(error.SourceName, error.ToString());
     if (_debug)
         Debugger.Debug(_compiler);
 }
Exemple #3
0
 private void OnError_Event() {
     if (_error == null)
         _error = new ScriptError(_script, _procedure, _compiler.Error.Description);
     var line = _compiler.Error.Line;
     if (_script != null && line != 0 && line != _err_line)
         _error.StackTrace.Add(_script.GetTraceLineAt(line));
     _err_line = line;
 }
 private void OnError_Event() {
     var err = _msc_compiler.Error;
     try {
         if (ExitException.Is(err)) {
             if (ExitException.ExitCode(err) == 0 || _error != null)
                 return;
         }
         if (_error == null) {
             _error = new ScriptError(_script, _procedure, err.Description);
         }
         var line = err.Line;
         if (_script != null && line != 0 && line != _err_line)
             _error.AddTrace(_script.GetTraceLineAt(line));
         _err_line = line;
     } finally {
         err.Clear();
     }
 }
Exemple #5
0
 internal static void LogScriptError(ScriptError error) {
     StringBuilder sb = new StringBuilder();
     sb.Append("[Fail] ").Append(error.Source).AppendLine();
     sb.AppendLine(SEPARATOR_LINE_DASH);
     sb.AppendLine(error.ToString().CleanEnd());
     Write(sb);
 }
Exemple #6
0
 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 ProcedureList ListProcedures(Script script, Regex pattern) {
     var procedures = new ProcedureList();
     foreach(Module _mod in _compiler.Modules){
         foreach (IScriptProcedure proc in _mod.Procedures) {
         var proc_name = proc.Name;
         switch (proc_name.ToLower()) {
             case "initialize": procedures.ProcInitialize = new ProcedureItem(_mod, proc_name); break;
             case "terminate": procedures.ProcTerminate = new ProcedureItem(_mod, proc_name); break;
             case "setup": procedures.ProcSetup = new ProcedureItem(_mod, proc_name); break;
             case "teardown": procedures.ProcTearDown = new ProcedureItem(_mod, proc_name); break;
             case "onerror": procedures.ProcOnError = new ProcedureItem(_mod, proc_name); break;
             case "iif": break;
             default:
                 if (proc.HasReturnValue) continue;
                 if (!pattern.IsMatch(proc_name)) continue;
                 ProcedureStringParams proc_params_str;
                 if (script.ProceduresParams.TryGetValue(proc_name, out proc_params_str)) {
                     if (!_compiler.Eval("Array(" + proc_params_str.Params + ')')) {
                         var error = new ScriptError(script, new ProcedureItem(_mod, proc_name), "Invalide array: " + proc_params_str.Params);
                         error.AddTraceLine(script, proc_params_str.Line);
                         OnError(error);
                         continue;
                     }
                     var proc_params = (object[])_compiler.Result;
                     foreach (var p in proc_params) {
                         var proc_args = p is object[] ? (object[])p : new object[1]{ p };
                         if (proc_args.Length == proc.NumArgs) {
                             procedures.Add(_mod, proc_name, proc_args);
                         } else {
                             var error = new ScriptError(script, new ProcedureItem(_mod, proc_name), string.Format("Procedure {0} requires {1} argument(s). {2} provied.", proc_name, proc.NumArgs, proc_args.Length));
                             error.AddTraceLine(script, script.TextFormated.GetLineNumber("(Sub|Function).\b" + proc_name + "\b"));
                             OnError(error);
                             break;
                         }
                     }
                 } else if (proc.NumArgs == 0) {
                     procedures.Add(_mod, proc_name, new object[0]);
                 }
                 break;
             }
         }
     }
     return procedures;
 }
Exemple #8
0
 private void Clear() {
     _error = null;
     _err_line = 0;
     _procedure = null;
     _result = null;
 }
        private ProcedureList ListProcedures(Script script, Regex pattern)
        {
            var procedures = new ProcedureList();

            foreach (Module _mod in _compiler.Modules)
            {
                foreach (IScriptProcedure proc in _mod.Procedures)
                {
                    var proc_name = proc.Name;
                    switch (proc_name.ToLower())
                    {
                    case "initialize": procedures.ProcInitialize = new ProcedureItem(_mod, proc_name); break;

                    case "terminate": procedures.ProcTerminate = new ProcedureItem(_mod, proc_name); break;

                    case "setup": procedures.ProcSetup = new ProcedureItem(_mod, proc_name); break;

                    case "teardown": procedures.ProcTearDown = new ProcedureItem(_mod, proc_name); break;

                    case "onerror": procedures.ProcOnError = new ProcedureItem(_mod, proc_name); break;

                    case "iif": break;

                    default:
                        if (proc.HasReturnValue)
                        {
                            continue;
                        }
                        if (!pattern.IsMatch(proc_name))
                        {
                            continue;
                        }
                        ProcedureStringParams proc_params_str;
                        if (script.ProceduresParams.TryGetValue(proc_name, out proc_params_str))
                        {
                            if (!_compiler.Eval("Array(" + proc_params_str.Params + ')'))
                            {
                                var error = new ScriptError(script, new ProcedureItem(_mod, proc_name), "Invalide array: " + proc_params_str.Params);
                                error.AddTraceLine(script, proc_params_str.Line);
                                OnError(error);
                                continue;
                            }
                            var proc_params = (object[])_compiler.Result;
                            foreach (var p in proc_params)
                            {
                                var proc_args = p is object[] ? (object[])p : new object[1] {
                                    p
                                };
                                if (proc_args.Length == proc.NumArgs)
                                {
                                    procedures.Add(_mod, proc_name, proc_args);
                                }
                                else
                                {
                                    var error = new ScriptError(script, new ProcedureItem(_mod, proc_name), string.Format("Procedure {0} requires {1} argument(s). {2} provied.", proc_name, proc.NumArgs, proc_args.Length));
                                    error.AddTraceLine(script, script.TextFormated.GetLineNumber("(Sub|Function).\b" + proc_name + "\b"));
                                    OnError(error);
                                    break;
                                }
                            }
                        }
                        else if (proc.NumArgs == 0)
                        {
                            procedures.Add(_mod, proc_name, new object[0]);
                        }
                        break;
                    }
                }
            }
            return(procedures);
        }
Exemple #10
0
        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);
        }