コード例 #1
0
        private QsCompilation?UpdateCompilation(
            ImmutableDictionary <Uri, string> sources,
            QsReferences references,
            QSharpLogger?logger                 = null,
            bool compileAsExecutable            = false,
            string?executionTarget              = null,
            RuntimeCapability?runtimeCapability = null)
        {
            var loadOptions = new CompilationLoader.Configuration
            {
                GenerateFunctorSupport = true,
                IsExecutable           = compileAsExecutable,
                AssemblyConstants      = new Dictionary <string, string> {
                    [AssemblyConstants.ProcessorArchitecture] = executionTarget ?? string.Empty
                },
                RuntimeCapability = runtimeCapability ?? RuntimeCapability.FullComputation
            };
            var loaded = new CompilationLoader(_ => sources, _ => references, loadOptions, logger);

            return(loaded.CompilationOutput);
        }
コード例 #2
0
ファイル: CompilerService.cs プロジェクト: sergiobat/iqsharp
        private QsCompilation?UpdateCompilation(
            ImmutableDictionary <Uri, string> sources,
            QsReferences references,
            QSharpLogger?logger                 = null,
            bool compileAsExecutable            = false,
            string?executionTarget              = null,
            RuntimeCapability?runtimeCapability = null)
        {
            var loadOptions = new CompilationLoader.Configuration
            {
                GenerateFunctorSupport = true,
                LoadReferencesBasedOnGeneratedCsharp = string.IsNullOrEmpty(executionTarget), // deserialization of resources in references is only needed if there is an execution target
                IsExecutable      = compileAsExecutable,
                AssemblyConstants = new Dictionary <string, string> {
                    [AssemblyConstants.ProcessorArchitecture] = executionTarget ?? string.Empty
                },
                RuntimeCapability = runtimeCapability ?? RuntimeCapability.FullComputation
            };
            var loaded = new CompilationLoader(_ => sources, _ => references, loadOptions, logger);

            return(loaded.CompilationOutput);
        }
コード例 #3
0
ファイル: CompilerService.cs プロジェクト: deadmau6/iqsharp
        /// <summary>
        /// Builds the Q# syntax tree from the given files/source paris.
        /// </summary>
        private static QsCompiler.SyntaxTree.QsNamespace[] BuildQsSyntaxTree(ImmutableDictionary <Uri, string> sources, QsReferences references, QSharpLogger logger)
        {
            var loadOptions = new QsCompiler.CompilationLoader.Configuration {
                GenerateFunctorSupport = true
            };
            var loaded = new QsCompiler.CompilationLoader(_ => sources, _ => references, loadOptions, logger);

            return(loaded.GeneratedSyntaxTree?.ToArray());
        }
コード例 #4
0
ファイル: CompilerService.cs プロジェクト: deadmau6/iqsharp
        /// <summary>
        /// Builds the Q# syntax tree from the given files.
        /// The files are given as a list of filenames, as per the format expected by
        /// the <see cref="Microsoft.Quantum.QsCompiler.CompilationBuilder.ProjectManager.LoadSourceFiles(IEnumerable{string}, Action{VisualStudio.LanguageServer.Protocol.Diagnostic}, Action{Exception})" />
        /// method.
        /// </summary>
        private static QsCompiler.SyntaxTree.QsNamespace[] BuildQsSyntaxTree(string[] files, QsReferences references, QSharpLogger logger)
        {
            var sources = ProjectManager.LoadSourceFiles(files, d => logger?.Log(d), ex => logger?.Log(ex));

            return(BuildQsSyntaxTree(sources, references, logger));
        }
コード例 #5
0
ファイル: CompilerMetadata.cs プロジェクト: deadmau6/iqsharp
 private CompilerMetadata(IEnumerable <String> paths, IEnumerable <MetadataReference> roslyn, QsReferences qsharp)
 {
     Paths           = paths;
     RoslynMetadatas = roslyn;
     QsMetadatas     = qsharp;
 }
コード例 #6
0
ファイル: CompilerMetadata.cs プロジェクト: deadmau6/iqsharp
 public CompilerMetadata(IEnumerable <AssemblyInfo> assemblies)
 {
     Paths           = PathsInit(assemblies);
     RoslynMetadatas = RoslynInit(Paths);
     QsMetadatas     = QsInit(Paths);
 }
コード例 #7
0
ファイル: CompilerService.cs プロジェクト: yazici/iqsharp
        /// <summary>
        /// Compiles the given Q# code and returns the list of elements found in it.
        /// Removes all currently tracked source files in the CompilationManager and replaces them with the given ones.
        /// The compiler does this on a best effort, so it will return the elements even if the compilation fails.
        /// If the given references are not null, reloads the references loaded in by the CompilationManager
        /// if the keys of the given references differ from the currently loaded ones.
        /// Returns an enumerable of all namespaces, including the content from both source files and references.
        /// </summary>
        private QsCompilation UpdateCompilation(ImmutableDictionary <Uri, string> sources, QsReferences references = null, QSharpLogger logger = null)
        {
            var loadOptions = new CompilationLoader.Configuration
            {
                GenerateFunctorSupport = true,
            };
            var loaded = new CompilationLoader(_ => sources, _ => references, loadOptions, logger);

            return(loaded.CompilationOutput);
        }