Ejemplo n.º 1
0
        public override void Build(BuildItems items)
        {
            items.SchemaProvider = new TransitionSchemaProvider(items.SchemaProvider);

            var queryTree = items.RawQueryTree;

            var metadataInferer          = new BuildMetadataAndInferTypeVisitor(items.SchemaProvider);
            var metadataInfererTraverser = new BuildMetadataAndInferTypeTraverseVisitor(metadataInferer);

            queryTree.Accept(metadataInfererTraverser);

            queryTree = metadataInferer.Root;

            var rewriter         = new RewriteQueryVisitor();
            var rewriteTraverser = new RewriteQueryTraverseVisitor(rewriter, new ScopeWalker(metadataInfererTraverser.Scope));

            queryTree.Accept(rewriteTraverser);

            queryTree = rewriter.RootScript;

            var csharpRewriter         = new ToCSharpRewriteTreeVisitor(metadataInferer.Assemblies, metadataInferer.SetOperatorFieldPositions, metadataInferer.InferredColumns);
            var csharpRewriteTraverser = new ToCSharpRewriteTreeTraverseVisitor(csharpRewriter, new ScopeWalker(metadataInfererTraverser.Scope));

            queryTree.Accept(csharpRewriteTraverser);

            items.TransformedQueryTree = queryTree;
            items.Compilation          = csharpRewriter.Compilation;
            items.AccessToClassPath    = csharpRewriter.AccessToClassPath;

            Successor?.Build(items);
        }
Ejemplo n.º 2
0
        public override void Build(BuildItems items)
        {
            using (var dllStream = new MemoryStream())
            {
                using (var pdbStream = new MemoryStream())
                {
#if DEBUG
                    var result = items.Compilation.Emit(dllStream, pdbStream, options: new Microsoft.CodeAnalysis.Emit.EmitOptions(false, Microsoft.CodeAnalysis.Emit.DebugInformationFormat.PortablePdb));
#else
                    var result = items.Compilation.Emit(dllStream, pdbStream);
#endif

                    items.EmitResult = result;
                    if (!result.Success)
                    {
                        var all = new StringBuilder();

                        foreach (var diagnostic in result.Diagnostics)
                        {
                            all.Append(diagnostic);
                        }

                        items.DllFile = null;
                        items.PdbFile = null;

                        throw new CompilationException(all.ToString());
                    }

                    items.DllFile = dllStream.ToArray();
                    items.PdbFile = pdbStream.ToArray();
                }
            }

            Successor?.Build(items);
        }
Ejemplo n.º 3
0
        public override void Build(BuildItems items)
        {
            var lexer  = new Lexer(items.RawQuery, true);
            var parser = new FqlParser(lexer);

            items.RawQueryTree = parser.ComposeAll();

            Successor?.Build(items);
        }
Ejemplo n.º 4
0
        public override void Build(BuildItems items)
        {
            using (var dllStream = new MemoryStream())
            {
                using (var pdbStream = new MemoryStream())
                {
                    var result = items.Compilation.Emit(dllStream, pdbStream);

                    items.EmitResult = result;
                    if (!result.Success)
                    {
                        var all = new StringBuilder();

                        foreach (var diagnostic in result.Diagnostics)
                        {
                            all.Append(diagnostic);
                        }

                        items.CompiledQuery = null;
                        items.DllFile       = null;
                        items.PdbFile       = null;

                        throw new CompilationException(all.ToString());
                    }

                    var dllBytesArray = dllStream.ToArray();
                    var pdbBytesArray = pdbStream.ToArray();

                    var assembly = Assembly.Load(dllBytesArray, pdbBytesArray);

                    var type = assembly.GetType(items.AccessToClassPath);

                    var runnable = (IRunnable)Activator.CreateInstance(type);
                    runnable.Provider = items.SchemaProvider;

                    items.CompiledQuery = runnable;
                    items.DllFile       = dllBytesArray;
                    items.PdbFile       = pdbBytesArray;
                }
            }

            Successor?.Build(items);
        }