Пример #1
0
        /// <inheritdoc/>
        public bool Transformation(QsCompilation compilation, out QsCompilation transformed)
        {
            // random "diagnostic" to check if diagnostics loading works
            this.GeneratedDiagnostics = new List <IRewriteStep.Diagnostic>()
            {
                new IRewriteStep.Diagnostic
                {
                    Severity = CodeAnalysis.DiagnosticSeverity.Info,
                    Message  = "Invokation of the Q# compiler extension for C# generation to demonstrate execution on the simulation framework.",
                }
            };

            var success      = true;
            var outputFolder = this.AssemblyConstants.TryGetValue(ReservedKeywords.AssemblyConstants.OutputPath, out var path) ? path : null;
            var allSources   = GetSourceFiles.Apply(compilation.Namespaces) // also generate the code for referenced libraries...
                                                                            // ... except when they are one of the packages that currently still already contains the C# code (temporary workaround):
                               .Where(s => !Path.GetFileName(s).StartsWith("Microsoft.Quantum"));

            foreach (var source in allSources)
            {
                var content = SimulationCode.generate(source, CodegenContext.Create(compilation.Namespaces));
                try
                {
                    CompilationLoader.GeneratedFile(source, outputFolder ?? this.Name, ".g.cs", content);
                }
                catch
                {
                    success = false;
                }
            }
            transformed = compilation;
            return(success);
        }
Пример #2
0
        public bool Transformation(QsCompilation compilation, out QsCompilation transformed)
        {
            var success    = true;
            var allSources = GetSourceFiles.Apply(compilation.Namespaces) // also generate the code for referenced libraries...
                                                                          // ... except when they are one of the packages that currently still already contains the C# code (temporary workaround):
                             .Where(s => !Path.GetFileName(s.Value).StartsWith("Microsoft.Quantum"));

            foreach (var source in allSources)
            {
                var content = SimulationCode.generate(source, compilation.Namespaces);
                try { CompilationLoader.GeneratedFile(source, this.OutputFolder ?? this.Name, ".g.cs", content); }
                catch { success = false; }
            }
            transformed = compilation;
            return(success);
        }
Пример #3
0
 public bool PostconditionVerification(QsCompilation compilation) =>
 throw new System.NotImplementedException();
Пример #4
0
 public bool PreconditionVerification(QsCompilation compilation) =>
 // todo: we should implement this and check for conjugations and invalid pieces
 throw new System.NotImplementedException();