private static void Check(ICompileResult results, Func <ICheckPass> pass) { if (!results.HasErrors) { pass().Check(); } }
public CSharpExecuteResult(long time, string stdout, object returnVal, ICompileResult cResult, Exception exception) { Time = time; ConsoleOutput = stdout; ReturnValue = returnVal; CompileResult = cResult; Exception = exception; Success = exception == null; }
private static T?Build <T>(ICompileResult results, Func <T> newPass) where T : class, IBuildPass { if (!results.HasErrors) { var pass = newPass(); pass.Build(); return(pass); } return(null); }
public static ISource?FromFile(ICompileResult result, FileRef sourceFile) { try { return(new Source(sourceFile.FileName, sourceFile.GetContent())); } catch (FileNotFoundException) { result.AddError(new MessageError(MessageCode.SourceFileNotFound, sourceFile)); } return(null); }
public static IEnumerable <Inline> BuildRuns(ICompileResult result) { string nl = Environment.NewLine; if (result.Success) { //Compile: SUCCESS List <Inline> items = new List <Inline> { new Run($"Compilation successful! (Took {result.Time}ms){nl}") { Foreground = Brushes.Green, FontWeight = FontWeights.Bold, FontSize = 15 } }; if (result.Diagnostics?.Any() == true) { items.Add(new Run("Diagnostics:\n")); items.AddRange(BuildDiagnostics(result.Diagnostics, " ")); } return(items); } else { //Compile: FAIL List <Inline> items = new List <Inline> { new Run($"Compilation failed!{nl}") { Foreground = Brushes.Red, FontWeight = FontWeights.Bold, FontSize = 15 } }; if (result.Diagnostics?.Any() == true) { //DIAGNOSTICS items.Add(new Run("Diagnostics:\n")); items.AddRange(BuildDiagnostics(result.Diagnostics, " ")); } return(items); } }
public Semantic(ICompileResult results) { Results = results; }