예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
        public Task <object> GetAstAsync(IWorkSession session, CancellationToken cancellationToken)
        {
            var syntaxRoot = session.Php().Compilation.SyntaxTrees.Single().Root;

            return(Task.FromResult <object>(syntaxRoot));
        }