internal static void CompileSources( PhpCompilation compilation, PEModuleBuilder moduleBuilder, bool emittingPdb, bool hasDeclarationErrors, DiagnosticBag diagnostics, CancellationToken cancellationToken) { Debug.Assert(moduleBuilder != null); // ensure flow analysis and collect diagnostics var declarationDiagnostics = compilation.GetDeclarationDiagnostics(cancellationToken); diagnostics.AddRange(declarationDiagnostics); if (hasDeclarationErrors |= declarationDiagnostics.HasAnyErrors() || cancellationToken.IsCancellationRequested) { // cancel the operation if there are errors return; } // var compiler = new PhylSourceRoutinesCompiler(compilation, moduleBuilder, emittingPdb, diagnostics, cancellationToken); // Emit method bodies // a. declared routines // b. synthesized symbols compiler.EmitMethodBodies(); compiler.EmitSynthesized(); compiler.CompileReflectionEnumerators(); // Entry Point (.exe) compiler.CompileEntryPoint(); }
protected bool BindandAnalyzeCFG() { using (Operation engineOp = L.Begin("Binding types to symbols and analyzing control-flow")) { SourceRoutinesCompiler = new PhylSourceRoutinesCompiler(this, Compiler.PhpCompilation, CancellationToken.None); BindAndAnalyzeDiagnostics = SourceRoutinesCompiler.BindAndAnalyzeCFG()?.ToArray(); if (BindAndAnalyzeDiagnostics != null && BindAndAnalyzeDiagnostics.Length > 0) { L.Info("{0} warnings from bind and analyze phase.", BindAndAnalyzeDiagnostics.Count()); if (ShowCompileWarnings) { foreach (Diagnostic d in BindAndAnalyzeDiagnostics) { L.Warn($"{d}"); } } } engineOp.Complete(); return(true); } }