public void SetOptionsForTarget([NotNull] IWorkSession session, [NotNull] string target) { var outputKind = target != TargetNames.Run ? PeachpieRoslyn.OutputKind.DynamicallyLinkedLibrary : PeachpieRoslyn.OutputKind.ConsoleApplication; IPhpSession php = session.Php(); var compilation = php.Compilation; php.Compilation = (PhpCompilation)compilation.WithOptions(compilation.Options.WithOutputKind(outputKind)); }
public void SetOptimize([NotNull] IWorkSession session, [NotNull] string optimize) { var optimizationLevel = (optimize == Optimize.Debug) ? PeachpieRoslyn.OptimizationLevel.Debug : PeachpieRoslyn.OptimizationLevel.Release; IPhpSession php = session.Php(); var compilation = php.Compilation; php.Compilation = (PhpCompilation)compilation.WithOptions(compilation.Options.WithOptimizationLevel(optimizationLevel)); }
private bool TryCompilePhpToStreamAsync(MemoryStream assemblyStream, MemoryStream symbolStream, IWorkSession session, IList <Diagnostic> diagnostics) { var compilation = session.Php().Compilation; var emitResult = compilation.Emit(assemblyStream, symbolStream); if (!emitResult.Success) { foreach (var diagnostic in emitResult.Diagnostics) { diagnostics.Add(diagnostic.ToStandardRoslyn()); } return(false); } return(true); }
public Task <object> GetAstAsync(IWorkSession session, CancellationToken cancellationToken) { var syntaxRoot = session.Php().Compilation.SyntaxTrees.Single().Root; return(Task.FromResult <object>(syntaxRoot)); }