/// <summary> /// Find useful information from the compilation diagnotics /// </summary> private CompilationOutput AnalyseDiagnostics(ImmutableArray <Diagnostic> diagnostics) { List <string> output = new List <string>(); int warningCount = 0; int errorCount = 0; foreach (var diagnostic in diagnostics) { output.Add(diagnostic.ToString()); if (diagnostic.Severity == DiagnosticSeverity.Warning) { warningCount++; } else if (diagnostic.Severity == DiagnosticSeverity.Error) { errorCount++; } } var compilationResults = new CompilationOutput( warningCount: warningCount, errorCount: errorCount, messages: output.ToArray()); return(compilationResults); }
/// <summary> /// Initialise /// </summary> /// <param name="script">A compiled script</param> /// <param name="diagnostics">Compilation diagnostics</param> internal CompiledScript( Script script, ImmutableArray <Diagnostic> diagnostics) { ActualScript = script; CompilationOutput = AnalyseDiagnostics(diagnostics); }
/// <summary> /// Initialise /// </summary> private EasyScript( CompilationOutput compilationOutput, ReturnType scriptResults, Exception runtimeException) { CompilationOutput = compilationOutput; ScriptResults = scriptResults; RuntimeException = runtimeException; }