Exemplo n.º 1
0
            public static QsCompilation Apply(QsCompilation compilation, bool keepAllIntrinsics)
            {
                var globals = compilation.Namespaces.GlobalCallableResolutions();
                var augmentedEntryPoints = BuiltIn.AllBuiltIns
                                           .Where(bi => bi.Kind != BuiltInKind.Attribute && globals.ContainsKey(bi.FullName))
                                           .Select(bi => bi.FullName)
                                           .Concat(compilation.EntryPoints)
                                           .Distinct()
                                           .ToImmutableArray();
                var compilationWithBuiltIns = new QsCompilation(compilation.Namespaces, augmentedEntryPoints);
                var callablesToKeep         = new CallGraph(compilationWithBuiltIns, true).Nodes.Select(node => node.CallableName).ToImmutableHashSet();

                // ToDo: convert to using ternary operator, when target-type
                // conditional expressions are supported in C#
                Func <QsNamespaceElement, bool> filter = elem => Filter(elem, callablesToKeep);

                if (keepAllIntrinsics)
                {
                    filter = elem => FilterWithIntrinsics(elem, callablesToKeep);
                }

                var transformed = new TrimTree(filter).OnCompilation(compilation);

                return(new QsCompilation(transformed.Namespaces.Where(ns => ns.Elements.Any()).ToImmutableArray(), transformed.EntryPoints));
            }
Exemplo n.º 2
0
 public static QsCompilation Apply(QsCompilation compilation, bool keepAllIntrinsics)
 {
     return(TrimTree.Apply(compilation, keepAllIntrinsics));
 }