Example #1
0
 private static void Check(ICompileResult results, Func <ICheckPass> pass)
 {
     if (!results.HasErrors)
     {
         pass().Check();
     }
 }
Example #2
0
 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;
 }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
            }
        }
Example #6
0
 public Semantic(ICompileResult results)
 {
     Results = results;
 }