public string Run() { _host.ClearOutput(); var res = _host.Execute(this.Text); this.Output = _host.GetOutput(); return(this.Output); }
private void RunScript() { ClearOutput(); string script = this.Script; var res = _host.Execute(script); _output.Text = _host.GetOutput(); }
private void RunScript() { try { _output.Text = null; _scriptHost.ClearOutput(); _scriptHost.Execute(_script.Text); _output.Text = _scriptHost.GetOutput(); } catch (Exception ex) { _output.Text = ex.ToString(); } }
public static ExecutionResult Execute(string code, ScriptHost host) { var tree = SyntaxTree.Parse(code); Assert.Empty(tree.Diagnostics); var compilation = host.Compile(tree); var executionResult = host.Execute(compilation); Assert.Empty(executionResult.Diagnostics); return(executionResult); }
protected override void Executed(Params args, IConsoleOutput target) { ScriptHost host = null; try { host = ScriptHost.FromFile(args.JoinEnd(0)); } catch (ArgumentNullException) { ThrowGenericError("Path was empty", ErrorCode.ARGUMENT_NULL); } catch (ArgumentException) { ThrowArgumentError("Path was invalid", ErrorCode.ARGUMENT_INVALID); } catch (System.IO.FileNotFoundException) { ThrowGenericError("File not found", ErrorCode.FILE_NOT_FOUND); } catch (System.IO.PathTooLongException) { ThrowGenericError("Path was too long", ErrorCode.ARGUMENT_INVALID); } catch (System.IO.DirectoryNotFoundException) { ThrowGenericError("Parts of the specified path was not found", ErrorCode.DIRECTORY_NOT_FOUND); } catch (System.IO.IOException) { ThrowGenericError("Unexpected error opening script", ErrorCode.IO_ERROR); } catch (UnauthorizedAccessException) { ThrowGenericError("Access denied", ErrorCode.FILE_ACCESS_DENIED); } catch (NotSupportedException) { ThrowGenericError("Unexpected error opening script", ErrorCode.IO_ERROR); } catch (System.Security.SecurityException) { ThrowGenericError("Access denied", ErrorCode.FILE_ACCESS_DENIED); } host.Execute(target); }
public static void AssertHasDiagnostics( string text, string diagnosticText, [CallerMemberName] string?testName = null ) { var annotatedText = AnnotatedText.Parse(text); var syntaxTree = SyntaxTree.Parse(annotatedText.Text); using var scriptHost = new ScriptHost(AssembliesWithStdLib, testName ?? "test"); var result = scriptHost.Execute(syntaxTree); var diagnostics = result.Diagnostics; AssertDiagnostics(diagnosticText, annotatedText, diagnostics); }