diff --git a/src/QsCompiler/BondSchemas/BondSchemas.csproj b/src/QsCompiler/BondSchemas/BondSchemas.csproj index 387e0ae6e8..0020dee504 100644 --- a/src/QsCompiler/BondSchemas/BondSchemas.csproj +++ b/src/QsCompiler/BondSchemas/BondSchemas.csproj @@ -1,4 +1,4 @@ - + @@ -9,7 +9,7 @@ - + diff --git a/src/QsCompiler/BondSchemas/Protocols.cs b/src/QsCompiler/BondSchemas/Protocols.cs index 061f2cbac8..9bb6f0b4d8 100644 --- a/src/QsCompiler/BondSchemas/Protocols.cs +++ b/src/QsCompiler/BondSchemas/Protocols.cs @@ -2,7 +2,9 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Bond; @@ -11,6 +13,7 @@ namespace Microsoft.Quantum.QsCompiler.BondSchemas { + using BondQsCompilation = V2.QsCompilation; using SimpleBinaryDeserializer = Deserializer>; using SimpleBinarySerializer = Serializer>; @@ -23,27 +26,36 @@ public static class Protocols /// Provides thread-safe access to the members and methods of this class. /// private static readonly object BondSharedDataStructuresLock = new object(); - private static Task? simpleBinaryDeserializerInitialization = null; - private static Task? simpleBinarySerializerInitialization = null; + private static readonly IDictionary?> DeserializerInitializations = + new Dictionary?>() + { +#pragma warning disable IDE0001 // Simplify Names + { typeof(V1.QsCompilation), null }, + { typeof(V2.QsCompilation), null } +#pragma warning restore IDE0001 // Simplify Names + }; + + private static Task? serializerInitialization = null; /// /// Deserializes a Q# compilation object from its Bond simple binary representation. /// /// Bond simple binary representation of a Q# compilation object. /// This method waits for s to complete and may deadlock if invoked through a . + // N.B. Consider adding an options argument to this method to allow for selection of payload to deserialize. public static SyntaxTree.QsCompilation? DeserializeQsCompilationFromSimpleBinary( - byte[] byteArray) + byte[] byteArray, + Type bondSchemaType) { - QsCompilation? bondCompilation = null; + object? bondCompilation = null; var inputBuffer = new InputBuffer(byteArray); var reader = new SimpleBinaryReader(inputBuffer); lock (BondSharedDataStructuresLock) { - var deserializer = GetSimpleBinaryDeserializer(); - bondCompilation = deserializer.Deserialize(reader); + bondCompilation = DeserializeBondSchemaFromSimpleBinary(reader, bondSchemaType); } - return CompilerObjectTranslator.CreateQsCompilation(bondCompilation); + return Translators.FromBondSchemaToSyntaxTree(bondCompilation); } /// @@ -54,15 +66,8 @@ public static void Initialize() { lock (BondSharedDataStructuresLock) { - if (simpleBinaryDeserializerInitialization == null) - { - simpleBinaryDeserializerInitialization = QueueSimpleBinaryDeserializerInitialization(); - } - - if (simpleBinarySerializerInitialization == null) - { - simpleBinarySerializerInitialization = QueueSimpleBinarySerializerInitialization(); - } + TryInitializeDeserializers(); + _ = TryInitializeSerializer(); } } @@ -74,10 +79,7 @@ public static void InitializeDeserializer() { lock (BondSharedDataStructuresLock) { - if (simpleBinaryDeserializerInitialization == null) - { - simpleBinaryDeserializerInitialization = QueueSimpleBinaryDeserializerInitialization(); - } + TryInitializeDeserializers(); } } @@ -89,10 +91,7 @@ public static void InitializeSerializer() { lock (BondSharedDataStructuresLock) { - if (simpleBinarySerializerInitialization == null) - { - simpleBinarySerializerInitialization = QueueSimpleBinarySerializerInitialization(); - } + _ = TryInitializeSerializer(); } } @@ -108,7 +107,7 @@ public static void SerializeQsCompilationToSimpleBinary( { var outputBuffer = new OutputBuffer(); var writer = new SimpleBinaryWriter(outputBuffer); - var bondCompilation = BondSchemaTranslator.CreateBondCompilation(qsCompilation); + var bondCompilation = Translators.FromSyntaxTreeToBondSchema(qsCompilation); lock (BondSharedDataStructuresLock) { var serializer = GetSimpleBinarySerializer(); @@ -120,38 +119,53 @@ public static void SerializeQsCompilationToSimpleBinary( stream.Position = 0; } - private static SimpleBinaryDeserializer GetSimpleBinaryDeserializer() + private static object DeserializeBondSchemaFromSimpleBinary( + SimpleBinaryReader reader, + Type bondSchemaType) { - VerifyLockAcquired(BondSharedDataStructuresLock); - if (simpleBinaryDeserializerInitialization == null) + var deserializer = GetSimpleBinaryDeserializer(bondSchemaType); +#pragma warning disable IDE0001 // Simplify Names + if (bondSchemaType == typeof(V1.QsCompilation)) + { + return deserializer.Deserialize(reader); + } + else if (bondSchemaType == typeof(V2.QsCompilation)) { - simpleBinaryDeserializerInitialization = QueueSimpleBinaryDeserializerInitialization(); + return deserializer.Deserialize(reader); } +#pragma warning restore IDE0001 // Simplify Names + + throw new ArgumentException($"Unknown Bond schema type '{bondSchemaType}'"); + } - simpleBinaryDeserializerInitialization.Wait(); - return simpleBinaryDeserializerInitialization.Result; + private static SimpleBinaryDeserializer GetSimpleBinaryDeserializer(Type bondSchemaType) + { + VerifyLockAcquired(BondSharedDataStructuresLock); + var deserializerInitialization = TryInitializeDeserializer(bondSchemaType); + deserializerInitialization.Wait(); + return deserializerInitialization.Result; } private static SimpleBinarySerializer GetSimpleBinarySerializer() { VerifyLockAcquired(BondSharedDataStructuresLock); - if (simpleBinarySerializerInitialization == null) + if (serializerInitialization == null) { - simpleBinarySerializerInitialization = QueueSimpleBinarySerializerInitialization(); + serializerInitialization = QueueSimpleBinarySerializerInitialization(); } - simpleBinarySerializerInitialization.Wait(); - return simpleBinarySerializerInitialization.Result; + serializerInitialization.Wait(); + return serializerInitialization.Result; } - private static Task QueueSimpleBinaryDeserializerInitialization() + private static Task QueueSimpleBinaryDeserializerInitialization(Type deserializerType) { VerifyLockAcquired(BondSharedDataStructuresLock); // inlineNested is false in order to decrease the time needed to initialize the deserializer. // While this setting may also increase deserialization time, we did not notice any performance drawbacks with our Bond schemas. return Task.Run(() => new SimpleBinaryDeserializer( - type: typeof(QsCompilation), + type: deserializerType, factory: (Factory?)null, inlineNested: false)); } @@ -159,7 +173,43 @@ private static Task QueueSimpleBinaryDeserializerIniti private static Task QueueSimpleBinarySerializerInitialization() { VerifyLockAcquired(BondSharedDataStructuresLock); - return Task.Run(() => new SimpleBinarySerializer(typeof(QsCompilation))); + return Task.Run(() => new SimpleBinarySerializer(typeof(BondQsCompilation))); + } + + private static Task TryInitializeDeserializer(Type bondSchemaType) + { + VerifyLockAcquired(BondSharedDataStructuresLock); + if (!DeserializerInitializations.TryGetValue(bondSchemaType, out var deserializerInitialization)) + { + throw new ArgumentException($"Unknown Bond schema type '{bondSchemaType}'"); + } + + if (deserializerInitialization == null) + { + deserializerInitialization = QueueSimpleBinaryDeserializerInitialization(bondSchemaType); + DeserializerInitializations[bondSchemaType] = deserializerInitialization; + } + + return deserializerInitialization; + } + + private static void TryInitializeDeserializers() + { + foreach (var bondSchemaType in DeserializerInitializations.Keys.ToList()) + { + _ = TryInitializeDeserializer(bondSchemaType); + } + } + + private static Task TryInitializeSerializer() + { + VerifyLockAcquired(BondSharedDataStructuresLock); + if (serializerInitialization == null) + { + serializerInitialization = QueueSimpleBinarySerializerInitialization(); + } + + return serializerInitialization; } private static void VerifyLockAcquired(object lockObject) diff --git a/src/QsCompiler/BondSchemas/Translators.cs b/src/QsCompiler/BondSchemas/Translators.cs new file mode 100644 index 0000000000..2561bdeb73 --- /dev/null +++ b/src/QsCompiler/BondSchemas/Translators.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System; + +namespace Microsoft.Quantum.QsCompiler.BondSchemas +{ + using BondQsCompilation = V2.QsCompilation; + + internal static class Translators + { + public static SyntaxTree.QsCompilation FromBondSchemaToSyntaxTree( + TBond bondCompilation) + { + switch (bondCompilation) + { +#pragma warning disable IDE0001 // Simplify Names + case V1.QsCompilation bondCompilationV1: + return V1.CompilerObjectTranslator.CreateQsCompilation(bondCompilationV1); + + case V2.QsCompilation bondCompilationV2: + return V2.CompilerObjectTranslator.CreateQsCompilation(bondCompilationV2); + + default: + throw new ArgumentException($"Unknown Bond schema type '{typeof(TBond)}'"); +#pragma warning restore IDE0001 // Simplify Names + } + } + + public static BondQsCompilation FromSyntaxTreeToBondSchema(SyntaxTree.QsCompilation qsCompilation) => + V2.BondSchemaTranslator.CreateBondCompilation(qsCompilation); + } +} diff --git a/src/QsCompiler/BondSchemas/BondSchemaTranslator.cs b/src/QsCompiler/BondSchemas/V1/BondSchemaTranslator.cs similarity index 89% rename from src/QsCompiler/BondSchemas/BondSchemaTranslator.cs rename to src/QsCompiler/BondSchemas/V1/BondSchemaTranslator.cs index eee0465d30..89d3ef3904 100644 --- a/src/QsCompiler/BondSchemas/BondSchemaTranslator.cs +++ b/src/QsCompiler/BondSchemas/V1/BondSchemaTranslator.cs @@ -7,7 +7,7 @@ using System.Linq; using Microsoft.Quantum.QsCompiler.DataTypes; -namespace Microsoft.Quantum.QsCompiler.BondSchemas +namespace Microsoft.Quantum.QsCompiler.BondSchemas.V1 { /// /// This class translates compiler objects to Bond schema objects. @@ -24,7 +24,7 @@ public static QsCompilation CreateBondCompilation(SyntaxTree.QsCompilation qsCom EntryPoints = qsCompilation.EntryPoints.Select(e => e.ToBondSchema()).ToList() }; - private static AccessModifier ToBondSchema(this SyntaxTokens.AccessModifier accessModifier) => + internal static AccessModifier ToBondSchema(this SyntaxTokens.AccessModifier accessModifier) => accessModifier.Tag switch { SyntaxTokens.AccessModifier.Tags.DefaultAccess => AccessModifier.DefaultAccess, @@ -32,14 +32,14 @@ private static AccessModifier ToBondSchema(this SyntaxTokens.AccessModifier acce _ => throw new ArgumentException($"Unsupported AccessModifier: {accessModifier}") }; - private static CallableInformation ToBondSchema(this SyntaxTree.CallableInformation callableInformation) => + internal static CallableInformation ToBondSchema(this SyntaxTree.CallableInformation callableInformation) => new CallableInformation { Characteristics = callableInformation.Characteristics.ToBondSchema(), InferredInformation = callableInformation.InferredInformation.ToBondSchema() }; - private static Identifier ToBondSchema(this SyntaxTree.Identifier identifier) + internal static Identifier ToBondSchema(this SyntaxTree.Identifier identifier) { string? bondLocalVariable = null; QsQualifiedName? bondGlobalCallable = null; @@ -71,33 +71,33 @@ private static Identifier ToBondSchema(this SyntaxTree.Identifier identifier) }; } - private static InferredCallableInformation ToBondSchema(this SyntaxTree.InferredCallableInformation inferredCallableInformation) => + internal static InferredCallableInformation ToBondSchema(this SyntaxTree.InferredCallableInformation inferredCallableInformation) => new InferredCallableInformation { IsSelfAdjoint = inferredCallableInformation.IsSelfAdjoint, IsIntrinsic = inferredCallableInformation.IsIntrinsic }; - private static InferredExpressionInformation ToBondSchema(this SyntaxTree.InferredExpressionInformation inferredExpressionInformation) => + internal static InferredExpressionInformation ToBondSchema(this SyntaxTree.InferredExpressionInformation inferredExpressionInformation) => new InferredExpressionInformation { IsMutable = inferredExpressionInformation.IsMutable, HasLocalQuantumDependency = inferredExpressionInformation.HasLocalQuantumDependency }; - private static LocalDeclarations ToBondSchema(this SyntaxTree.LocalDeclarations localDeclarations) => + internal static LocalDeclarations ToBondSchema(this SyntaxTree.LocalDeclarations localDeclarations) => new LocalDeclarations { Variables = localDeclarations.Variables.Select(v => v.ToBondSchemaGeneric(typeTranslator: s => s)).ToList() }; - private static Modifiers ToBondSchema(this SyntaxTokens.Modifiers modifiers) => + internal static Modifiers ToBondSchema(this SyntaxTokens.Modifiers modifiers) => new Modifiers { Access = modifiers.Access.ToBondSchema() }; - private static OpProperty ToBondSchema(this SyntaxTokens.OpProperty opProperty) => + internal static OpProperty ToBondSchema(this SyntaxTokens.OpProperty opProperty) => opProperty.Tag switch { SyntaxTokens.OpProperty.Tags.Adjointable => OpProperty.Adjointable, @@ -105,14 +105,14 @@ private static OpProperty ToBondSchema(this SyntaxTokens.OpProperty opProperty) _ => throw new ArgumentException($"Unsupported OpProperty {opProperty}") }; - private static Position ToBondSchema(this DataTypes.Position position) => + internal static Position ToBondSchema(this DataTypes.Position position) => new Position { Line = position.Line, Column = position.Column }; - private static QsBindingKind ToBondSchema(this SyntaxTree.QsBindingKind qsBindingKind) => + internal static QsBindingKind ToBondSchema(this SyntaxTree.QsBindingKind qsBindingKind) => qsBindingKind.Tag switch { SyntaxTree.QsBindingKind.Tags.ImmutableBinding => QsBindingKind.ImmutableBinding, @@ -120,7 +120,7 @@ private static QsBindingKind ToBondSchema(this SyntaxTree.QsBindingKind qsBindin _ => throw new ArgumentException($"Unsupported QsBindingKind {qsBindingKind}") }; - private static QsCallable ToBondSchema(this SyntaxTree.QsCallable qsCallable) => + internal static QsCallable ToBondSchema(this SyntaxTree.QsCallable qsCallable) => new QsCallable { Kind = qsCallable.Kind.ToBondSchema(), @@ -138,7 +138,7 @@ private static QsCallable ToBondSchema(this SyntaxTree.QsCallable qsCallable) => Comments = qsCallable.Comments.ToBondSchema() }; - private static QsCallableKind ToBondSchema(this SyntaxTree.QsCallableKind qsCallableKind) => + internal static QsCallableKind ToBondSchema(this SyntaxTree.QsCallableKind qsCallableKind) => qsCallableKind.Tag switch { SyntaxTree.QsCallableKind.Tags.Function => QsCallableKind.Function, @@ -147,14 +147,14 @@ private static QsCallableKind ToBondSchema(this SyntaxTree.QsCallableKind qsCall _ => throw new ArgumentException($"Unsupported QsCallableKind {qsCallableKind}") }; - private static QsComments ToBondSchema(this SyntaxTree.QsComments qsComments) => + internal static QsComments ToBondSchema(this SyntaxTree.QsComments qsComments) => new QsComments { OpeningComments = qsComments.OpeningComments.ToList(), ClosingComments = qsComments.ClosingComments.ToList() }; - private static QsConditionalStatement ToBondSchema(this SyntaxTree.QsConditionalStatement qsConditionalStatement) => + internal static QsConditionalStatement ToBondSchema(this SyntaxTree.QsConditionalStatement qsConditionalStatement) => new QsConditionalStatement { ConditionalBlocks = qsConditionalStatement.ConditionalBlocks.Select(c => c.ToQsConditionalBlock()).ToList(), @@ -163,14 +163,14 @@ private static QsConditionalStatement ToBondSchema(this SyntaxTree.QsConditional qsConditionalStatement.Default.Item.ToBondSchema() }; - private static QsConjugation ToBondSchema(this SyntaxTree.QsConjugation qsConjugation) => + internal static QsConjugation ToBondSchema(this SyntaxTree.QsConjugation qsConjugation) => new QsConjugation { OuterTransformation = qsConjugation.OuterTransformation.ToBondSchema(), InnerTransformation = qsConjugation.InnerTransformation.ToBondSchema() }; - private static QsCustomType ToBondSchema(this SyntaxTree.QsCustomType qsCustomType) => + internal static QsCustomType ToBondSchema(this SyntaxTree.QsCustomType qsCustomType) => new QsCustomType { FullName = qsCustomType.FullName.ToBondSchema(), @@ -186,7 +186,7 @@ private static QsCustomType ToBondSchema(this SyntaxTree.QsCustomType qsCustomTy Comments = qsCustomType.Comments.ToBondSchema() }; - private static QsDeclarationAttribute ToBondSchema(this SyntaxTree.QsDeclarationAttribute qsDeclarationAttribute) => + internal static QsDeclarationAttribute ToBondSchema(this SyntaxTree.QsDeclarationAttribute qsDeclarationAttribute) => new QsDeclarationAttribute { TypeId = qsDeclarationAttribute.TypeId.IsNull ? @@ -197,14 +197,14 @@ private static QsDeclarationAttribute ToBondSchema(this SyntaxTree.QsDeclaration Comments = qsDeclarationAttribute.Comments.ToBondSchema() }; - private static QsExpressionKindComposition ToBondSchema( + internal static QsExpressionKindComposition ToBondSchema( this SyntaxTokens.QsExpressionKind qsExpressionKind) => qsExpressionKind.ToBondSchemaGeneric( expressionTranslator: ToBondSchema, symbolTranslator: ToBondSchema, typeTranslator: ToBondSchema); - private static QsForStatement ToBondSchema(this SyntaxTree.QsForStatement qsForStatement) => + internal static QsForStatement ToBondSchema(this SyntaxTree.QsForStatement qsForStatement) => new QsForStatement { LoopItem = qsForStatement.LoopItem.ToQsLoopItem(), @@ -212,7 +212,7 @@ private static QsForStatement ToBondSchema(this SyntaxTree.QsForStatement qsForS Body = qsForStatement.Body.ToBondSchema() }; - private static QsGeneratorDirective ToBondSchema(this SyntaxTokens.QsGeneratorDirective qsGeneratorDirective) => + internal static QsGeneratorDirective ToBondSchema(this SyntaxTokens.QsGeneratorDirective qsGeneratorDirective) => qsGeneratorDirective.Tag switch { SyntaxTokens.QsGeneratorDirective.Tags.Distribute => QsGeneratorDirective.Distribute, @@ -222,14 +222,14 @@ private static QsGeneratorDirective ToBondSchema(this SyntaxTokens.QsGeneratorDi _ => throw new ArgumentException($"Unsupported QsGeneratorDirective {qsGeneratorDirective}") }; - private static QsQualifiedName ToBondSchema(this SyntaxTree.QsQualifiedName qsQualifiedName) => + internal static QsQualifiedName ToBondSchema(this SyntaxTree.QsQualifiedName qsQualifiedName) => new QsQualifiedName { Namespace = qsQualifiedName.Namespace, Name = qsQualifiedName.Name }; - private static QsLocalSymbol ToBondSchema(this SyntaxTree.QsLocalSymbol qsLocalSymbol) + internal static QsLocalSymbol ToBondSchema(this SyntaxTree.QsLocalSymbol qsLocalSymbol) { string? bondValidName = null; QsLocalSymbolKind kind; @@ -254,18 +254,18 @@ private static QsLocalSymbol ToBondSchema(this SyntaxTree.QsLocalSymbol qsLocalS }; } - private static LocalVariableDeclaration ToBondSchema( + internal static LocalVariableDeclaration ToBondSchema( this SyntaxTree.LocalVariableDeclaration localVariableDeclaration) => localVariableDeclaration.ToBondSchemaGeneric(typeTranslator: ToBondSchema); - private static QsLocation ToBondSchema(this SyntaxTree.QsLocation qsLocation) => + internal static QsLocation ToBondSchema(this SyntaxTree.QsLocation qsLocation) => new QsLocation { Offset = qsLocation.Offset.ToBondSchema(), Range = qsLocation.Range.ToBondSchema() }; - private static QsNamespace ToBondSchema(this SyntaxTree.QsNamespace qsNamespace) => + internal static QsNamespace ToBondSchema(this SyntaxTree.QsNamespace qsNamespace) => new QsNamespace { Name = qsNamespace.Name, @@ -273,7 +273,7 @@ private static QsNamespace ToBondSchema(this SyntaxTree.QsNamespace qsNamespace) Documentation = qsNamespace.Documentation.ToQsSourceFileDocumentationList() }; - private static QsNamespaceElement ToBondSchema(this SyntaxTree.QsNamespaceElement qsNamespaceElement) + internal static QsNamespaceElement ToBondSchema(this SyntaxTree.QsNamespaceElement qsNamespaceElement) { QsCallable? bondQsCallable = null; QsCustomType? bondQsCustomType = null; @@ -303,7 +303,7 @@ private static QsNamespaceElement ToBondSchema(this SyntaxTree.QsNamespaceElemen return bondQsNamespaceElement; } - private static QsPauli ToBondSchema(this SyntaxTokens.QsPauli qsPauli) => + internal static QsPauli ToBondSchema(this SyntaxTokens.QsPauli qsPauli) => qsPauli.Tag switch { SyntaxTokens.QsPauli.Tags.PauliI => QsPauli.PauliI, @@ -313,7 +313,7 @@ private static QsPauli ToBondSchema(this SyntaxTokens.QsPauli qsPauli) => _ => throw new ArgumentException($"Unsupported ") }; - private static QsPositionedBlock ToBondSchema(this SyntaxTree.QsPositionedBlock qsPositionedBlock) => + internal static QsPositionedBlock ToBondSchema(this SyntaxTree.QsPositionedBlock qsPositionedBlock) => new QsPositionedBlock { Body = qsPositionedBlock.Body.ToBondSchema(), @@ -323,7 +323,7 @@ private static QsPositionedBlock ToBondSchema(this SyntaxTree.QsPositionedBlock Comments = qsPositionedBlock.Comments.ToBondSchema() }; - private static QsQubitScope ToBondSchema(this SyntaxTree.QsQubitScope qsQubitScope) => + internal static QsQubitScope ToBondSchema(this SyntaxTree.QsQubitScope qsQubitScope) => new QsQubitScope { Kind = qsQubitScope.Kind.ToBondSchema(), @@ -331,7 +331,7 @@ private static QsQubitScope ToBondSchema(this SyntaxTree.QsQubitScope qsQubitSco Body = qsQubitScope.Body.ToBondSchema() }; - private static QsQubitScopeKind ToBondSchema(this SyntaxTree.QsQubitScopeKind qsQubitScopeKind) => + internal static QsQubitScopeKind ToBondSchema(this SyntaxTree.QsQubitScopeKind qsQubitScopeKind) => qsQubitScopeKind.Tag switch { SyntaxTree.QsQubitScopeKind.Tags.Allocate => QsQubitScopeKind.Allocate, @@ -339,7 +339,7 @@ private static QsQubitScopeKind ToBondSchema(this SyntaxTree.QsQubitScopeKind qs _ => throw new ArgumentException($"Unsupported QsQubitScopeKind {qsQubitScopeKind}") }; - private static QsRepeatStatement ToBondSchema(this SyntaxTree.QsRepeatStatement qsRepeatStatement) => + internal static QsRepeatStatement ToBondSchema(this SyntaxTree.QsRepeatStatement qsRepeatStatement) => new QsRepeatStatement { RepeatBlock = qsRepeatStatement.RepeatBlock.ToBondSchema(), @@ -347,7 +347,7 @@ private static QsRepeatStatement ToBondSchema(this SyntaxTree.QsRepeatStatement FixupBlock = qsRepeatStatement.FixupBlock.ToBondSchema() }; - private static QsResult ToBondSchema(this SyntaxTokens.QsResult qsResult) => + internal static QsResult ToBondSchema(this SyntaxTokens.QsResult qsResult) => qsResult.Tag switch { SyntaxTokens.QsResult.Tags.Zero => QsResult.Zero, @@ -355,14 +355,14 @@ private static QsResult ToBondSchema(this SyntaxTokens.QsResult qsResult) => _ => throw new ArgumentException($"Unsupported QsResult {qsResult}") }; - private static QsScope ToBondSchema(this SyntaxTree.QsScope qsScope) => + internal static QsScope ToBondSchema(this SyntaxTree.QsScope qsScope) => new QsScope { Statements = qsScope.Statements.Select(s => s.ToBondSchema()).ToList(), KnownSymbols = qsScope.KnownSymbols.ToBondSchema() }; - private static QsSpecialization ToBondSchema(this SyntaxTree.QsSpecialization qsSpecialization) => + internal static QsSpecialization ToBondSchema(this SyntaxTree.QsSpecialization qsSpecialization) => new QsSpecialization { Kind = qsSpecialization.Kind.ToBondSchema(), @@ -381,7 +381,7 @@ private static QsSpecialization ToBondSchema(this SyntaxTree.QsSpecialization qs Comments = qsSpecialization.Comments.ToBondSchema() }; - private static QsSpecializationKind ToBondSchema(this SyntaxTree.QsSpecializationKind qsSpecializationKind) => + internal static QsSpecializationKind ToBondSchema(this SyntaxTree.QsSpecializationKind qsSpecializationKind) => qsSpecializationKind.Tag switch { SyntaxTree.QsSpecializationKind.Tags.QsAdjoint => QsSpecializationKind.QsAdjoint, @@ -391,7 +391,7 @@ private static QsSpecializationKind ToBondSchema(this SyntaxTree.QsSpecializatio _ => throw new ArgumentException($"Unsupported QsSpecializationKind {qsSpecializationKind}") }; - private static QsStatement ToBondSchema(this SyntaxTree.QsStatement qsStatement) => + internal static QsStatement ToBondSchema(this SyntaxTree.QsStatement qsStatement) => new QsStatement { Statement = qsStatement.Statement.ToBondSchema(), @@ -402,7 +402,7 @@ private static QsStatement ToBondSchema(this SyntaxTree.QsStatement qsStatement) Comments = qsStatement.Comments.ToBondSchema() }; - private static QsStatementKindComposition ToBondSchema(this SyntaxTree.QsStatementKind qsStatementKind) + internal static QsStatementKindComposition ToBondSchema(this SyntaxTree.QsStatementKind qsStatementKind) { TypedExpression? bondTypedExpression = null; QsBinding? bondVariableDeclaration = null; @@ -493,15 +493,15 @@ private static QsStatementKindComposition ToBondSchema(this SyntaxTree.QsStateme }; } - private static QsTuple> ToBondSchema( + internal static QsTuple> ToBondSchema( this SyntaxTokens.QsTuple> localVariableDeclaration) => localVariableDeclaration.ToBondSchemaGeneric(typeTranslator: ToBondSchema); - private static QsTuple ToBondSchema( + internal static QsTuple ToBondSchema( this SyntaxTokens.QsTuple qsTypeItem) => qsTypeItem.ToBondSchemaGeneric(typeTranslator: ToBondSchema); - private static QsTypeKindComposition ToBondSchema( + internal static QsTypeKindComposition ToBondSchema( this SyntaxTokens.QsTypeKind qsTypeKind) => qsTypeKind.ToBondSchemaGeneric( dataTranslator: ToBondSchema, @@ -509,7 +509,7 @@ private static QsTypeKindComposition? bondNamed = null; @@ -537,7 +537,7 @@ private static QsTypeItem ToBondSchema(this SyntaxTree.QsTypeItem qsTypeItem) }; } - private static QsTypeParameter ToBondSchema(this SyntaxTree.QsTypeParameter qsTypeParameter) => + internal static QsTypeParameter ToBondSchema(this SyntaxTree.QsTypeParameter qsTypeParameter) => new QsTypeParameter { Origin = qsTypeParameter.Origin.ToBondSchema(), @@ -547,34 +547,34 @@ private static QsTypeParameter ToBondSchema(this SyntaxTree.QsTypeParameter qsTy qsTypeParameter.Range.Item.ToBondSchema() }; - private static QsValueUpdate ToBondSchema(this SyntaxTree.QsValueUpdate valueUpdate) => + internal static QsValueUpdate ToBondSchema(this SyntaxTree.QsValueUpdate valueUpdate) => new QsValueUpdate { Lhs = valueUpdate.Lhs.ToBondSchema(), Rhs = valueUpdate.Rhs.ToBondSchema() }; - private static QsWhileStatement ToBondSchema(this SyntaxTree.QsWhileStatement qsWhileStatement) => + internal static QsWhileStatement ToBondSchema(this SyntaxTree.QsWhileStatement qsWhileStatement) => new QsWhileStatement { Condition = qsWhileStatement.Condition.ToBondSchema(), Body = qsWhileStatement.Body.ToBondSchema() }; - private static Range ToBondSchema(this DataTypes.Range range) => + internal static Range ToBondSchema(this DataTypes.Range range) => new Range { Start = range.Start.ToBondSchema(), End = range.End.ToBondSchema() }; - private static ResolvedCharacteristics ToBondSchema(this SyntaxTree.ResolvedCharacteristics resolvedCharacteristics) => + internal static ResolvedCharacteristics ToBondSchema(this SyntaxTree.ResolvedCharacteristics resolvedCharacteristics) => new ResolvedCharacteristics { Expression = resolvedCharacteristics.Expression.ToBondSchemaGeneric(typeTranslator: ToBondSchema) }; - private static ResolvedInitializer ToBondSchema(this SyntaxTree.ResolvedInitializer resolvedInitializer) => + internal static ResolvedInitializer ToBondSchema(this SyntaxTree.ResolvedInitializer resolvedInitializer) => new ResolvedInitializer { Initializer = resolvedInitializer.Resolution.ToBondSchemaGeneric( @@ -583,7 +583,7 @@ private static ResolvedInitializer ToBondSchema(this SyntaxTree.ResolvedInitiali ResolvedType = resolvedInitializer.Type.ToBondSchema() }; - private static ResolvedSignature ToBondSchema(this SyntaxTree.ResolvedSignature resolvedSignature) => + internal static ResolvedSignature ToBondSchema(this SyntaxTree.ResolvedSignature resolvedSignature) => new ResolvedSignature { TypeParameters = resolvedSignature.TypeParameters.Select(tp => tp.ToBondSchema()).ToList(), @@ -592,13 +592,13 @@ private static ResolvedSignature ToBondSchema(this SyntaxTree.ResolvedSignature Information = resolvedSignature.Information.ToBondSchema() }; - private static ResolvedType ToBondSchema(this SyntaxTree.ResolvedType resolvedType) => + internal static ResolvedType ToBondSchema(this SyntaxTree.ResolvedType resolvedType) => new ResolvedType { TypeKind = resolvedType.Resolution.ToBondSchema() }; - private static SpecializationImplementation ToBondSchema(this SyntaxTree.SpecializationImplementation specializationImplementation) + internal static SpecializationImplementation ToBondSchema(this SyntaxTree.SpecializationImplementation specializationImplementation) { QsGeneratorDirective? bondGenerated = null; SpecializationImplementationKindProvided? bondProvided = null; @@ -631,7 +631,7 @@ private static SpecializationImplementation ToBondSchema(this SyntaxTree.Special }; } - private static SymbolTuple ToBondSchema(this SyntaxTree.SymbolTuple symbolTuple) + internal static SymbolTuple ToBondSchema(this SyntaxTree.SymbolTuple symbolTuple) { string? bondVariableName = null; List? bondVariableNameTuple = null; @@ -664,7 +664,7 @@ private static SymbolTuple ToBondSchema(this SyntaxTree.SymbolTuple symbolTuple) }; } - private static TypedExpression ToBondSchema(this SyntaxTree.TypedExpression typedExpression) => + internal static TypedExpression ToBondSchema(this SyntaxTree.TypedExpression typedExpression) => new TypedExpression { Expression = typedExpression.Expression.ToBondSchema(), @@ -676,7 +676,7 @@ private static TypedExpression ToBondSchema(this SyntaxTree.TypedExpression type typedExpression.Range.Item.ToBondSchema() }; - private static UserDefinedType ToBondSchema(this SyntaxTree.UserDefinedType userDefinedType) => + internal static UserDefinedType ToBondSchema(this SyntaxTree.UserDefinedType userDefinedType) => new UserDefinedType { Namespace = userDefinedType.Namespace, @@ -686,7 +686,7 @@ private static UserDefinedType ToBondSchema(this SyntaxTree.UserDefinedType user userDefinedType.Range.Item.ToBondSchema() }; - private static CharacteristicsKindComposition ToBondSchemaGeneric( + internal static CharacteristicsKindComposition ToBondSchemaGeneric( this SyntaxTokens.CharacteristicsKind characteristicsKind, Func typeTranslator) where TBond : class @@ -734,7 +734,7 @@ private static CharacteristicsKindComposition ToBondSchemaGeneric ToBondSchemaGeneric( + internal static LocalVariableDeclaration ToBondSchemaGeneric( this SyntaxTree.LocalVariableDeclaration localVariableDeclaration, Func typeTranslator) => new LocalVariableDeclaration @@ -748,7 +748,7 @@ private static LocalVariableDeclaration ToBondSchemaGeneric ToBondSchemaGeneric( + internal static QsBinding ToBondSchemaGeneric( this SyntaxTree.QsBinding qsBinding, Func typeTranslator) => new QsBinding @@ -758,7 +758,7 @@ private static QsBinding ToBondSchemaGeneric( Rhs = typeTranslator(qsBinding.Rhs) }; - private static QsExpressionKindComposition ToBondSchemaGeneric< + internal static QsExpressionKindComposition ToBondSchemaGeneric< TBondExpression, TBondSymbol, TBondType, @@ -1121,7 +1121,7 @@ private static QsExpressionKindComposition ToBondSchemaGeneric< + internal static QsInitializerKindComposition ToBondSchemaGeneric< TBondInitializer, TBondExpression, TCompilerInitializer, @@ -1165,7 +1165,7 @@ private static QsInitializerKindComposition T }; } - private static QsTuple ToBondSchemaGeneric( + internal static QsTuple ToBondSchemaGeneric( this SyntaxTokens.QsTuple qsTuple, Func typeTranslator) where TBond : class @@ -1197,7 +1197,7 @@ private static QsTuple ToBondSchemaGeneric( }; } - private static QsTypeKindComposition ToBondSchemaGeneric + internal static QsTypeKindComposition ToBondSchemaGeneric ToCharacteristicsKindSetOperationGeneric( + internal static CharacteristicsKindSetOperation ToCharacteristicsKindSetOperationGeneric( TCompiler set1, TCompiler set2, Func typeTranslator) => @@ -1306,14 +1306,14 @@ private static CharacteristicsKindSetOperation ToCharacteristicsKindSetOp Set2 = typeTranslator(set2) }; - private static QsConditionalBlock ToQsConditionalBlock(this Tuple qsConditionalBlock) => + internal static QsConditionalBlock ToQsConditionalBlock(this Tuple qsConditionalBlock) => new QsConditionalBlock { Expression = qsConditionalBlock.Item1.ToBondSchema(), Block = qsConditionalBlock.Item2.ToBondSchema() }; - private static QsExpressionKindExpressionDouble ToQsExpressionKindExpressionDoubleGeneric( + internal static QsExpressionKindExpressionDouble ToQsExpressionKindExpressionDoubleGeneric( TCompiler expression1, TCompiler expression2, Func typeTranslator) => @@ -1323,7 +1323,7 @@ private static QsExpressionKindExpressionDouble ToQsExpressionKindExpress Expression2 = typeTranslator(expression2) }; - private static QsExpressionKindExpressionTriple ToQsExpressionKindExpressionTripleGeneric( + internal static QsExpressionKindExpressionTriple ToQsExpressionKindExpressionTripleGeneric( TCompiler expression1, TCompiler expression2, TCompiler expression3, @@ -1335,7 +1335,7 @@ private static QsExpressionKindExpressionTriple ToQsExpressionKindExpress Expression3 = typeTranslator(expression3) }; - private static QsExpressionKindIdentifier ToQsExpressionKindIdentifierGeneric< + internal static QsExpressionKindIdentifier ToQsExpressionKindIdentifierGeneric< TBondSymbol, TBondType, TCompilerSymbol, @@ -1350,7 +1350,7 @@ private static QsExpressionKindIdentifier ToQsExpression Types = types.IsNull ? null : types.Item.Select(t => typeTranslator(t)).ToList() }; - private static QsExpressionKindNamedItem ToQsExpressionKindNamedItemGeneric< + internal static QsExpressionKindNamedItem ToQsExpressionKindNamedItemGeneric< TBondExpression, TBondSymbol, TCompilerExpression, @@ -1365,7 +1365,7 @@ private static QsExpressionKindNamedItem ToQsExpre Symbol = symbolTranslator(symbol) }; - private static QsExpressionKindNewArray ToQsExpressionKindNewArrayGeneric< + internal static QsExpressionKindNewArray ToQsExpressionKindNewArrayGeneric< TBondExpression, TBondType, TCompilerExpression, @@ -1380,7 +1380,7 @@ private static QsExpressionKindNewArray ToQsExpressi Expression = expressionTranslator(expression) }; - private static QsExpressionKindStringLiteral ToQsExpressionKindStringLiteralGeneric( + internal static QsExpressionKindStringLiteral ToQsExpressionKindStringLiteralGeneric( string stringLiteral, ImmutableArray expressions, Func typeTranslator) => @@ -1390,14 +1390,14 @@ private static QsExpressionKindStringLiteral ToQsExpressionKindStringLite Expressions = expressions.Select(e => typeTranslator(e)).ToList() }; - private static QsLoopItem ToQsLoopItem(this Tuple loopItem) => + internal static QsLoopItem ToQsLoopItem(this Tuple loopItem) => new QsLoopItem { SymbolTuple = loopItem.Item1.ToBondSchema(), ResolvedType = loopItem.Item2.ToBondSchema() }; - private static LinkedList ToQsSourceFileDocumentationList( + internal static LinkedList ToQsSourceFileDocumentationList( this ILookup> qsDocumentation) { var documentationList = new LinkedList(); @@ -1418,7 +1418,7 @@ private static LinkedList ToQsSourceFileDocumentation return documentationList; } - private static QsTypeKindFunction ToQsTypeKindFunctionGeneric( + internal static QsTypeKindFunction ToQsTypeKindFunctionGeneric( TCompiler type1, TCompiler type2, Func typeTranslator) => @@ -1428,7 +1428,7 @@ private static QsTypeKindFunction ToQsTypeKindFunctionGeneric ToQsTypeKindOperationGeneric< + internal static QsTypeKindOperation ToQsTypeKindOperationGeneric< TBondType, TBondCharacteristics, TCompilerData, @@ -1444,7 +1444,7 @@ private static QsTypeKindOperation ToQsTypeKind Characteristics = characteristicsTranslator(charateristics) }; - private static SpecializationImplementationKindProvided ToSpecializationImplementationKindProvided( + internal static SpecializationImplementationKindProvided ToSpecializationImplementationKindProvided( SyntaxTokens.QsTuple> tuple, SyntaxTree.QsScope implementation) => new SpecializationImplementationKindProvided @@ -1453,7 +1453,7 @@ private static SpecializationImplementationKindProvided ToSpecializationImplemen Implementation = implementation.ToBondSchema() }; - private static TypedArgument ToTypedArgument( + internal static TypedArgument ToTypedArgument( this Tuple typedArgumet) => new TypedArgument { diff --git a/src/QsCompiler/BondSchemas/CompilerDataStructures.bond b/src/QsCompiler/BondSchemas/V1/CompilerDataStructuresV1.bond similarity index 99% rename from src/QsCompiler/BondSchemas/CompilerDataStructures.bond rename to src/QsCompiler/BondSchemas/V1/CompilerDataStructuresV1.bond index e078be7987..15e5a1fb07 100644 --- a/src/QsCompiler/BondSchemas/CompilerDataStructures.bond +++ b/src/QsCompiler/BondSchemas/V1/CompilerDataStructuresV1.bond @@ -1,10 +1,10 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. // This schema corresponds to the C# code at Generated/CompilerDataStructures.cs // N.B Whenever this schema changes, C# code must be generated again. -namespace Microsoft.Quantum.QsCompiler.BondSchemas; +namespace Microsoft.Quantum.QsCompiler.BondSchemas.V1; // Data structures from DataTypes.fs diff --git a/src/QsCompiler/BondSchemas/Generated/CompilerDataStructures.cs b/src/QsCompiler/BondSchemas/V1/CompilerDataStructuresV1.cs similarity index 78% rename from src/QsCompiler/BondSchemas/Generated/CompilerDataStructures.cs rename to src/QsCompiler/BondSchemas/V1/CompilerDataStructuresV1.cs index af43d722b2..82c4ce958d 100644 --- a/src/QsCompiler/BondSchemas/Generated/CompilerDataStructures.cs +++ b/src/QsCompiler/BondSchemas/V1/CompilerDataStructuresV1.cs @@ -1,10 +1,10 @@ - + //------------------------------------------------------------------------------ // This code was generated by a tool. // -// Tool : Bond Compiler 0.12.0.0 -// Input filename: CompilerDataStructures.bond -// Output filename: CompilerDataStructures_types.cs +// Tool : Bond Compiler 0.12.1.0 +// Input filename: C:\Microsoft\ReposB\qsharp-compiler\src\QsCompiler\BondSchemas\V1\CompilerDataStructuresV1.bond +// Output filename: CompilerDataStructuresV1_types.cs // // Changes to this file may cause incorrect behavior and will be lost when // the code is regenerated. @@ -25,12 +25,12 @@ // ReSharper disable RedundantUsingDirective #endregion -namespace Microsoft.Quantum.QsCompiler.BondSchemas +namespace Microsoft.Quantum.QsCompiler.BondSchemas.V1 { using System.Collections.Generic; [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class Position { [global::Bond.Id(5)] @@ -40,17 +40,17 @@ public partial class Position public int Column { get; set; } public Position() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.Position", "Position") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.Position", "Position") + {} protected Position(string fullName, string name) { - + } } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class Range { [global::Bond.Id(5)] @@ -60,8 +60,8 @@ public partial class Range public Position End { get; set; } public Range() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.Range", "Range") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.Range", "Range") + {} protected Range(string fullName, string name) { @@ -70,7 +70,7 @@ protected Range(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum AccessModifier { DefaultAccess, @@ -78,15 +78,15 @@ public enum AccessModifier } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class Modifiers { [global::Bond.Id(5)] public AccessModifier Access { get; set; } public Modifiers() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.Modifiers", "Modifiers") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.Modifiers", "Modifiers") + {} protected Modifiers(string fullName, string name) { @@ -94,7 +94,7 @@ protected Modifiers(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsGeneratorDirective { SelfInverse, @@ -103,14 +103,14 @@ public enum QsGeneratorDirective InvalidGenerator, } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsResult { Zero, One, } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsPauli { PauliX, @@ -119,7 +119,7 @@ public enum QsPauli PauliI, } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsExpressionKind { UnitValue, @@ -170,7 +170,7 @@ public enum QsExpressionKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsExpressionKindIdentifier { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.classT))] @@ -180,8 +180,8 @@ public partial class QsExpressionKindIdentifier public List Types { get; set; } public QsExpressionKindIdentifier() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsExpressionKindIdentifier", "QsExpressionKindIdentifier") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsExpressionKindIdentifier", "QsExpressionKindIdentifier") + {} protected QsExpressionKindIdentifier(string fullName, string name) { @@ -190,7 +190,7 @@ protected QsExpressionKindIdentifier(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsExpressionKindStringLiteral { [global::Bond.Id(5)] @@ -200,8 +200,8 @@ public partial class QsExpressionKindStringLiteral public List Expressions { get; set; } public QsExpressionKindStringLiteral() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsExpressionKindStringLiteral", "QsExpressionKindStringLiteral") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsExpressionKindStringLiteral", "QsExpressionKindStringLiteral") + {} protected QsExpressionKindStringLiteral(string fullName, string name) { @@ -211,7 +211,7 @@ protected QsExpressionKindStringLiteral(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsExpressionKindExpressionDouble { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.classT))] @@ -221,8 +221,8 @@ public partial class QsExpressionKindExpressionDouble public TExpression Expression2 { get; set; } public QsExpressionKindExpressionDouble() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsExpressionKindExpressionDouble", "QsExpressionKindExpressionDouble") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsExpressionKindExpressionDouble", "QsExpressionKindExpressionDouble") + {} protected QsExpressionKindExpressionDouble(string fullName, string name) { @@ -232,7 +232,7 @@ protected QsExpressionKindExpressionDouble(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsExpressionKindExpressionTriple { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.classT))] @@ -245,8 +245,8 @@ public partial class QsExpressionKindExpressionTriple public TExpression Expression3 { get; set; } public QsExpressionKindExpressionTriple() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsExpressionKindExpressionTriple", "QsExpressionKindExpressionTriple") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsExpressionKindExpressionTriple", "QsExpressionKindExpressionTriple") + {} protected QsExpressionKindExpressionTriple(string fullName, string name) { @@ -257,7 +257,7 @@ protected QsExpressionKindExpressionTriple(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsExpressionKindNewArray { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.classT))] @@ -267,8 +267,8 @@ public partial class QsExpressionKindNewArray public TExpression Expression { get; set; } public QsExpressionKindNewArray() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsExpressionKindNewArray", "QsExpressionKindNewArray") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsExpressionKindNewArray", "QsExpressionKindNewArray") + {} protected QsExpressionKindNewArray(string fullName, string name) { @@ -278,7 +278,7 @@ protected QsExpressionKindNewArray(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsExpressionKindNamedItem { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.classT))] @@ -288,8 +288,8 @@ public partial class QsExpressionKindNamedItem public TSymbol Symbol { get; set; } public QsExpressionKindNamedItem() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsExpressionKindNamedItem", "QsExpressionKindNamedItem") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsExpressionKindNamedItem", "QsExpressionKindNamedItem") + {} protected QsExpressionKindNamedItem(string fullName, string name) { @@ -299,7 +299,7 @@ protected QsExpressionKindNamedItem(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsExpressionKindComposition { [global::Bond.Id(5), global::Bond.Required] @@ -348,8 +348,8 @@ public partial class QsExpressionKindComposition public List ExpressionArray { get; set; } public QsExpressionKindComposition() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsExpressionKindComposition", "QsExpressionKindComposition") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsExpressionKindComposition", "QsExpressionKindComposition") + {} protected QsExpressionKindComposition(string fullName, string name) { @@ -357,14 +357,14 @@ protected QsExpressionKindComposition(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsBindingKind { ImmutableBinding, MutableBinding, } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsSpecializationKind { QsBody, @@ -373,7 +373,7 @@ public enum QsSpecializationKind QsControlledAdjoint, } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsCallableKind { Operation, @@ -381,7 +381,7 @@ public enum QsCallableKind TypeConstructor, } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsQubitScopeKind { Allocate, @@ -389,7 +389,7 @@ public enum QsQubitScopeKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsQualifiedName { [global::Bond.Id(5)] @@ -399,8 +399,8 @@ public partial class QsQualifiedName public string Name { get; set; } public QsQualifiedName() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsQualifiedName", "QsQualifiedName") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsQualifiedName", "QsQualifiedName") + {} protected QsQualifiedName(string fullName, string name) { @@ -409,7 +409,7 @@ protected QsQualifiedName(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum SymbolTupleKind { InvalidItem, @@ -419,7 +419,7 @@ public enum SymbolTupleKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class SymbolTuple { [global::Bond.Id(5), global::Bond.Required] @@ -432,8 +432,8 @@ public partial class SymbolTuple public List VariableNameTuple { get; set; } public SymbolTuple() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.SymbolTuple", "SymbolTuple") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.SymbolTuple", "SymbolTuple") + {} protected SymbolTuple(string fullName, string name) { @@ -442,7 +442,7 @@ protected SymbolTuple(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsBinding { [global::Bond.Id(5)] @@ -455,8 +455,8 @@ public partial class QsBinding public T Rhs { get; set; } public QsBinding() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsBinding", "QsBinding") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsBinding", "QsBinding") + {} protected QsBinding(string fullName, string name) { @@ -466,7 +466,7 @@ protected QsBinding(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum IdentifierKind { LocalVariable, @@ -475,7 +475,7 @@ public enum IdentifierKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class Identifier { [global::Bond.Id(5), global::Bond.Required] @@ -488,8 +488,8 @@ public partial class Identifier public QsQualifiedName GlobalCallable { get; set; } public Identifier() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.Identifier", "Identifier") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.Identifier", "Identifier") + {} protected Identifier(string fullName, string name) { @@ -498,7 +498,7 @@ protected Identifier(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsLocation { [global::Bond.Id(5)] @@ -508,8 +508,8 @@ public partial class QsLocation public Range Range { get; set; } public QsLocation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsLocation", "QsLocation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsLocation", "QsLocation") + {} protected QsLocation(string fullName, string name) { @@ -519,7 +519,7 @@ protected QsLocation(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsTypeParameter { [global::Bond.Id(5)] @@ -532,8 +532,8 @@ public partial class QsTypeParameter public Range Range { get; set; } public QsTypeParameter() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsTypeParameter", "QsTypeParameter") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsTypeParameter", "QsTypeParameter") + {} protected QsTypeParameter(string fullName, string name) { @@ -543,7 +543,7 @@ protected QsTypeParameter(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class UserDefinedType { [global::Bond.Id(5)] @@ -556,8 +556,8 @@ public partial class UserDefinedType public Range Range { get; set; } public UserDefinedType() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.UserDefinedType", "UserDefinedType") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.UserDefinedType", "UserDefinedType") + {} protected UserDefinedType(string fullName, string name) { @@ -566,14 +566,14 @@ protected UserDefinedType(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum OpProperty { Adjointable, Controllable, } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum CharacteristicsKind { EmptySet, @@ -584,7 +584,7 @@ public enum CharacteristicsKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class CharacteristicsKindSetOperation { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.classT))] @@ -594,8 +594,8 @@ public partial class CharacteristicsKindSetOperation public T Set2 { get; set; } public CharacteristicsKindSetOperation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.CharacteristicsKindSetOperation", "CharacteristicsKindSetOperation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.CharacteristicsKindSetOperation", "CharacteristicsKindSetOperation") + {} protected CharacteristicsKindSetOperation(string fullName, string name) { @@ -605,7 +605,7 @@ protected CharacteristicsKindSetOperation(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class CharacteristicsKindComposition { [global::Bond.Id(5), global::Bond.Required] @@ -618,8 +618,8 @@ public partial class CharacteristicsKindComposition public CharacteristicsKindSetOperation SetOperation { get; set; } public CharacteristicsKindComposition() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.CharacteristicsKindComposition", "CharacteristicsKindComposition") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.CharacteristicsKindComposition", "CharacteristicsKindComposition") + {} protected CharacteristicsKindComposition(string fullName, string name) { @@ -628,15 +628,15 @@ protected CharacteristicsKindComposition(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class ResolvedCharacteristics { [global::Bond.Id(5)] public CharacteristicsKindComposition Expression { get; set; } public ResolvedCharacteristics() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.ResolvedCharacteristics", "ResolvedCharacteristics") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.ResolvedCharacteristics", "ResolvedCharacteristics") + {} protected ResolvedCharacteristics(string fullName, string name) { @@ -645,7 +645,7 @@ protected ResolvedCharacteristics(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class InferredCallableInformation { [global::Bond.Id(5)] @@ -655,17 +655,17 @@ public partial class InferredCallableInformation public bool IsIntrinsic { get; set; } public InferredCallableInformation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.InferredCallableInformation", "InferredCallableInformation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.InferredCallableInformation", "InferredCallableInformation") + {} protected InferredCallableInformation(string fullName, string name) { - + } } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class CallableInformation { [global::Bond.Id(5)] @@ -675,8 +675,8 @@ public partial class CallableInformation public InferredCallableInformation InferredInformation { get; set; } public CallableInformation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.CallableInformation", "CallableInformation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.CallableInformation", "CallableInformation") + {} protected CallableInformation(string fullName, string name) { @@ -685,7 +685,7 @@ protected CallableInformation(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsTypeKind { UnitType, @@ -709,7 +709,7 @@ public enum QsTypeKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsTypeKindFunction { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.classT))] @@ -719,8 +719,8 @@ public partial class QsTypeKindFunction public T Type2 { get; set; } public QsTypeKindFunction() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsTypeKindFunction", "QsTypeKindFunction") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsTypeKindFunction", "QsTypeKindFunction") + {} protected QsTypeKindFunction(string fullName, string name) { @@ -730,7 +730,7 @@ protected QsTypeKindFunction(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsTypeKindOperation { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.classT))] @@ -743,8 +743,8 @@ public partial class QsTypeKindOperation public TCharacteristics Characteristics { get; set; } public QsTypeKindOperation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsTypeKindOperation", "QsTypeKindOperation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsTypeKindOperation", "QsTypeKindOperation") + {} protected QsTypeKindOperation(string fullName, string name) { @@ -755,7 +755,7 @@ protected QsTypeKindOperation(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsTypeKindComposition { [global::Bond.Id(5), global::Bond.Required] @@ -780,8 +780,8 @@ public partial class QsTypeKindComposition Function { get; set; } public QsTypeKindComposition() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsTypeKindComposition", "QsTypeKindComposition") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsTypeKindComposition", "QsTypeKindComposition") + {} protected QsTypeKindComposition(string fullName, string name) { @@ -790,15 +790,15 @@ protected QsTypeKindComposition(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class ResolvedType { [global::Bond.Id(5)] public QsTypeKindComposition TypeKind { get; set; } public ResolvedType() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.ResolvedType", "ResolvedType") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.ResolvedType", "ResolvedType") + {} protected ResolvedType(string fullName, string name) { @@ -807,7 +807,7 @@ protected ResolvedType(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class InferredExpressionInformation { [global::Bond.Id(5)] @@ -817,17 +817,17 @@ public partial class InferredExpressionInformation public bool HasLocalQuantumDependency { get; set; } public InferredExpressionInformation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.InferredExpressionInformation", "InferredExpressionInformation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.InferredExpressionInformation", "InferredExpressionInformation") + {} protected InferredExpressionInformation(string fullName, string name) { - + } } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class TypedArgument { [global::Bond.Id(5)] @@ -840,8 +840,8 @@ public partial class TypedArgument public ResolvedType Resolution { get; set; } public TypedArgument() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.TypedArgument", "TypedArgument") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.TypedArgument", "TypedArgument") + {} protected TypedArgument(string fullName, string name) { @@ -852,7 +852,7 @@ protected TypedArgument(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class TypedExpression { [global::Bond.Id(5)] @@ -871,8 +871,8 @@ public partial class TypedExpression public Range Range { get; set; } public TypedExpression() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.TypedExpression", "TypedExpression") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.TypedExpression", "TypedExpression") + {} protected TypedExpression(string fullName, string name) { @@ -883,7 +883,7 @@ protected TypedExpression(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsInitializerKind { SingleQubitAllocation, @@ -893,7 +893,7 @@ public enum QsInitializerKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsInitializerKindComposition { [global::Bond.Id(5), global::Bond.Required] @@ -906,8 +906,8 @@ public partial class QsInitializerKindComposition public List QubitTupleAllocation { get; set; } public QsInitializerKindComposition() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsInitializerKindComposition", "QsInitializerKindComposition") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsInitializerKindComposition", "QsInitializerKindComposition") + {} protected QsInitializerKindComposition(string fullName, string name) { @@ -916,7 +916,7 @@ protected QsInitializerKindComposition(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class ResolvedInitializer { [global::Bond.Id(5)] @@ -926,8 +926,8 @@ public partial class ResolvedInitializer public ResolvedType ResolvedType { get; set; } public ResolvedInitializer() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.ResolvedInitializer", "ResolvedInitializer") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.ResolvedInitializer", "ResolvedInitializer") + {} protected ResolvedInitializer(string fullName, string name) { @@ -937,7 +937,7 @@ protected ResolvedInitializer(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class LocalVariableDeclaration { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.classT))] @@ -956,8 +956,8 @@ public partial class LocalVariableDeclaration public Range Range { get; set; } public LocalVariableDeclaration() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.LocalVariableDeclaration", "LocalVariableDeclaration") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.LocalVariableDeclaration", "LocalVariableDeclaration") + {} protected LocalVariableDeclaration(string fullName, string name) { @@ -969,15 +969,15 @@ protected LocalVariableDeclaration(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class LocalDeclarations { [global::Bond.Id(5)] public List> Variables { get; set; } public LocalDeclarations() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.LocalDeclarations", "LocalDeclarations") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.LocalDeclarations", "LocalDeclarations") + {} protected LocalDeclarations(string fullName, string name) { @@ -986,7 +986,7 @@ protected LocalDeclarations(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsValueUpdate { [global::Bond.Id(5)] @@ -996,8 +996,8 @@ public partial class QsValueUpdate public TypedExpression Rhs { get; set; } public QsValueUpdate() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsValueUpdate", "QsValueUpdate") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsValueUpdate", "QsValueUpdate") + {} protected QsValueUpdate(string fullName, string name) { @@ -1007,7 +1007,7 @@ protected QsValueUpdate(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsComments { [global::Bond.Id(5)] @@ -1017,8 +1017,8 @@ public partial class QsComments public List ClosingComments { get; set; } public QsComments() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsComments", "QsComments") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsComments", "QsComments") + {} protected QsComments(string fullName, string name) { @@ -1028,7 +1028,7 @@ protected QsComments(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsPositionedBlock { [global::Bond.Id(5)] @@ -1041,8 +1041,8 @@ public partial class QsPositionedBlock public QsComments Comments { get; set; } public QsPositionedBlock() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsPositionedBlock", "QsPositionedBlock") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsPositionedBlock", "QsPositionedBlock") + {} protected QsPositionedBlock(string fullName, string name) { @@ -1052,7 +1052,7 @@ protected QsPositionedBlock(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsConditionalBlock { [global::Bond.Id(5)] @@ -1062,8 +1062,8 @@ public partial class QsConditionalBlock public QsPositionedBlock Block { get; set; } public QsConditionalBlock() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsConditionalBlock", "QsConditionalBlock") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsConditionalBlock", "QsConditionalBlock") + {} protected QsConditionalBlock(string fullName, string name) { @@ -1073,7 +1073,7 @@ protected QsConditionalBlock(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsConditionalStatement { [global::Bond.Id(5)] @@ -1083,8 +1083,8 @@ public partial class QsConditionalStatement public QsPositionedBlock Default { get; set; } public QsConditionalStatement() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsConditionalStatement", "QsConditionalStatement") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsConditionalStatement", "QsConditionalStatement") + {} protected QsConditionalStatement(string fullName, string name) { @@ -1093,7 +1093,7 @@ protected QsConditionalStatement(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsLoopItem { [global::Bond.Id(5)] @@ -1103,8 +1103,8 @@ public partial class QsLoopItem public ResolvedType ResolvedType { get; set; } public QsLoopItem() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsLoopItem", "QsLoopItem") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsLoopItem", "QsLoopItem") + {} protected QsLoopItem(string fullName, string name) { @@ -1114,7 +1114,7 @@ protected QsLoopItem(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsForStatement { [global::Bond.Id(5)] @@ -1127,8 +1127,8 @@ public partial class QsForStatement public QsScope Body { get; set; } public QsForStatement() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsForStatement", "QsForStatement") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsForStatement", "QsForStatement") + {} protected QsForStatement(string fullName, string name) { @@ -1139,7 +1139,7 @@ protected QsForStatement(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsWhileStatement { [global::Bond.Id(5)] @@ -1149,8 +1149,8 @@ public partial class QsWhileStatement public QsScope Body { get; set; } public QsWhileStatement() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsWhileStatement", "QsWhileStatement") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsWhileStatement", "QsWhileStatement") + {} protected QsWhileStatement(string fullName, string name) { @@ -1160,7 +1160,7 @@ protected QsWhileStatement(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsRepeatStatement { [global::Bond.Id(5)] @@ -1173,8 +1173,8 @@ public partial class QsRepeatStatement public QsPositionedBlock FixupBlock { get; set; } public QsRepeatStatement() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsRepeatStatement", "QsRepeatStatement") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsRepeatStatement", "QsRepeatStatement") + {} protected QsRepeatStatement(string fullName, string name) { @@ -1185,7 +1185,7 @@ protected QsRepeatStatement(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsConjugation { [global::Bond.Id(5)] @@ -1195,8 +1195,8 @@ public partial class QsConjugation public QsPositionedBlock InnerTransformation { get; set; } public QsConjugation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsConjugation", "QsConjugation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsConjugation", "QsConjugation") + {} protected QsConjugation(string fullName, string name) { @@ -1206,7 +1206,7 @@ protected QsConjugation(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsQubitScope { [global::Bond.Id(5)] @@ -1219,8 +1219,8 @@ public partial class QsQubitScope public QsScope Body { get; set; } public QsQubitScope() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsQubitScope", "QsQubitScope") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsQubitScope", "QsQubitScope") + {} protected QsQubitScope(string fullName, string name) { @@ -1230,7 +1230,7 @@ protected QsQubitScope(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsStatementKind { QsExpressionStatement, @@ -1248,7 +1248,7 @@ public enum QsStatementKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsStatementKindComposition { [global::Bond.Id(5), global::Bond.Required] @@ -1282,8 +1282,8 @@ public partial class QsStatementKindComposition public QsQubitScope QubitScope { get; set; } public QsStatementKindComposition() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsStatementKindComposition", "QsStatementKindComposition") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsStatementKindComposition", "QsStatementKindComposition") + {} protected QsStatementKindComposition(string fullName, string name) { @@ -1292,7 +1292,7 @@ protected QsStatementKindComposition(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsStatement { [global::Bond.Id(5)] @@ -1308,8 +1308,8 @@ public partial class QsStatement public QsComments Comments { get; set; } public QsStatement() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsStatement", "QsStatement") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsStatement", "QsStatement") + {} protected QsStatement(string fullName, string name) { @@ -1320,7 +1320,7 @@ protected QsStatement(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsScope { [global::Bond.Id(5)] @@ -1330,8 +1330,8 @@ public partial class QsScope public LocalDeclarations KnownSymbols { get; set; } public QsScope() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsScope", "QsScope") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsScope", "QsScope") + {} protected QsScope(string fullName, string name) { @@ -1340,7 +1340,7 @@ protected QsScope(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsLocalSymbolKind { ValidName, @@ -1348,7 +1348,7 @@ public enum QsLocalSymbolKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsLocalSymbol { [global::Bond.Id(5), global::Bond.Required] @@ -1358,8 +1358,8 @@ public partial class QsLocalSymbol public string Name { get; set; } public QsLocalSymbol() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsLocalSymbol", "QsLocalSymbol") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsLocalSymbol", "QsLocalSymbol") + {} protected QsLocalSymbol(string fullName, string name) { @@ -1368,7 +1368,7 @@ protected QsLocalSymbol(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsDeclarationAttribute { [global::Bond.Id(5), global::Bond.Type(typeof(global::Bond.Tag.nullable))] @@ -1384,8 +1384,8 @@ public partial class QsDeclarationAttribute public QsComments Comments { get; set; } public QsDeclarationAttribute() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsDeclarationAttribute", "QsDeclarationAttribute") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsDeclarationAttribute", "QsDeclarationAttribute") + {} protected QsDeclarationAttribute(string fullName, string name) { @@ -1396,7 +1396,7 @@ protected QsDeclarationAttribute(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class ResolvedSignature { [global::Bond.Id(5)] @@ -1412,8 +1412,8 @@ public partial class ResolvedSignature public CallableInformation Information { get; set; } public ResolvedSignature() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.ResolvedSignature", "ResolvedSignature") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.ResolvedSignature", "ResolvedSignature") + {} protected ResolvedSignature(string fullName, string name) { @@ -1424,7 +1424,7 @@ protected ResolvedSignature(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsTupleKind { QsTupleItem, @@ -1432,7 +1432,7 @@ public enum QsTupleKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsTuple { [global::Bond.Id(5), global::Bond.Required] @@ -1445,8 +1445,8 @@ public partial class QsTuple public List> Items { get; set; } public QsTuple() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsTuple", "QsTuple") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsTuple", "QsTuple") + {} protected QsTuple(string fullName, string name) { @@ -1454,7 +1454,7 @@ protected QsTuple(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum SpecializationImplementationKind { Provided, @@ -1464,7 +1464,7 @@ public enum SpecializationImplementationKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class SpecializationImplementationKindProvided { [global::Bond.Id(5)] @@ -1474,8 +1474,8 @@ public partial class SpecializationImplementationKindProvided public QsScope Implementation { get; set; } public SpecializationImplementationKindProvided() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.SpecializationImplementationKindProvided", "SpecializationImplementationKindProvided") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.SpecializationImplementationKindProvided", "SpecializationImplementationKindProvided") + {} protected SpecializationImplementationKindProvided(string fullName, string name) { @@ -1485,7 +1485,7 @@ protected SpecializationImplementationKindProvided(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class SpecializationImplementation { [global::Bond.Id(5), global::Bond.Required] @@ -1498,8 +1498,8 @@ public partial class SpecializationImplementation public QsGeneratorDirective? Generated { get; set; } public SpecializationImplementation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.SpecializationImplementation", "SpecializationImplementation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.SpecializationImplementation", "SpecializationImplementation") + {} protected SpecializationImplementation(string fullName, string name) { @@ -1508,7 +1508,7 @@ protected SpecializationImplementation(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsSpecialization { [global::Bond.Id(5)] @@ -1542,8 +1542,8 @@ public partial class QsSpecialization public QsComments Comments { get; set; } public QsSpecialization() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsSpecialization", "QsSpecialization") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsSpecialization", "QsSpecialization") + {} protected QsSpecialization(string fullName, string name) { @@ -1559,7 +1559,7 @@ protected QsSpecialization(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsCallable { [global::Bond.Id(5)] @@ -1596,8 +1596,8 @@ public partial class QsCallable public QsComments Comments { get; set; } public QsCallable() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsCallable", "QsCallable") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsCallable", "QsCallable") + {} protected QsCallable(string fullName, string name) { @@ -1614,7 +1614,7 @@ protected QsCallable(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsTypeItemKind { Named, @@ -1622,7 +1622,7 @@ public enum QsTypeItemKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsTypeItem { [global::Bond.Id(5), global::Bond.Required] @@ -1635,8 +1635,8 @@ public partial class QsTypeItem public ResolvedType Anonymous { get; set; } public QsTypeItem() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsTypeItem", "QsTypeItem") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsTypeItem", "QsTypeItem") + {} protected QsTypeItem(string fullName, string name) { @@ -1645,7 +1645,7 @@ protected QsTypeItem(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsCustomType { [global::Bond.Id(5)] @@ -1676,8 +1676,8 @@ public partial class QsCustomType public QsComments Comments { get; set; } public QsCustomType() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsCustomType", "QsCustomType") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsCustomType", "QsCustomType") + {} protected QsCustomType(string fullName, string name) { @@ -1692,7 +1692,7 @@ protected QsCustomType(string fullName, string name) } } - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public enum QsNamespaceElementKind { QsCallable, @@ -1700,7 +1700,7 @@ public enum QsNamespaceElementKind } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsNamespaceElement { [global::Bond.Id(5), global::Bond.Required] @@ -1713,8 +1713,8 @@ public partial class QsNamespaceElement public QsCustomType CustomType { get; set; } public QsNamespaceElement() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsNamespaceElement", "QsNamespaceElement") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsNamespaceElement", "QsNamespaceElement") + {} protected QsNamespaceElement(string fullName, string name) { @@ -1723,7 +1723,7 @@ protected QsNamespaceElement(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsSourceFileDocumentation { [global::Bond.Id(5)] @@ -1733,8 +1733,8 @@ public partial class QsSourceFileDocumentation public List DocumentationItems { get; set; } public QsSourceFileDocumentation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsSourceFileDocumentation", "QsSourceFileDocumentation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsSourceFileDocumentation", "QsSourceFileDocumentation") + {} protected QsSourceFileDocumentation(string fullName, string name) { @@ -1744,7 +1744,7 @@ protected QsSourceFileDocumentation(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsNamespace { [global::Bond.Id(5)] @@ -1757,8 +1757,8 @@ public partial class QsNamespace public LinkedList Documentation { get; set; } public QsNamespace() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsNamespace", "QsNamespace") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsNamespace", "QsNamespace") + {} protected QsNamespace(string fullName, string name) { @@ -1769,7 +1769,7 @@ protected QsNamespace(string fullName, string name) } [global::Bond.Schema] - [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.0.0")] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] public partial class QsCompilation { [global::Bond.Id(5)] @@ -1779,8 +1779,8 @@ public partial class QsCompilation public List EntryPoints { get; set; } public QsCompilation() - : this("Microsoft.Quantum.QsCompiler.BondSchemas.QsCompilation", "QsCompilation") - { } + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V1.QsCompilation", "QsCompilation") + {} protected QsCompilation(string fullName, string name) { @@ -1788,4 +1788,4 @@ protected QsCompilation(string fullName, string name) EntryPoints = new List(); } } -} // Microsoft.Quantum.QsCompiler.BondSchemas +} // Microsoft.Quantum.QsCompiler.BondSchemas.V1 diff --git a/src/QsCompiler/BondSchemas/CompilerObjectTranslator.cs b/src/QsCompiler/BondSchemas/V1/CompilerObjectTranslator.cs similarity index 89% rename from src/QsCompiler/BondSchemas/CompilerObjectTranslator.cs rename to src/QsCompiler/BondSchemas/V1/CompilerObjectTranslator.cs index c19491cc77..2530baf139 100644 --- a/src/QsCompiler/BondSchemas/CompilerObjectTranslator.cs +++ b/src/QsCompiler/BondSchemas/V1/CompilerObjectTranslator.cs @@ -8,7 +8,7 @@ using Microsoft.Quantum.QsCompiler.DataTypes; using Microsoft.Quantum.QsCompiler.SyntaxTree; -namespace Microsoft.Quantum.QsCompiler.BondSchemas +namespace Microsoft.Quantum.QsCompiler.BondSchemas.V1 { /// /// This class translates Bond schema objects to C# compiler objects. @@ -18,28 +18,29 @@ internal static class CompilerObjectTranslator /// /// Creates a C# QsCompilation compiler object from a Bond schema QsCompilation object. /// - public static SyntaxTree.QsCompilation CreateQsCompilation(QsCompilation bondCompilation) => - new SyntaxTree.QsCompilation( - namespaces: bondCompilation.Namespaces.Select(n => n.ToCompilerObject()).ToImmutableArray(), - entryPoints: bondCompilation.EntryPoints.Select(e => e.ToCompilerObject()).ToImmutableArray()); + public static SyntaxTree.QsCompilation CreateQsCompilation( + QsCompilation bondCompilation) => + new SyntaxTree.QsCompilation( + namespaces: bondCompilation.Namespaces.Select(n => n.ToCompilerObject()).ToImmutableArray(), + entryPoints: bondCompilation.EntryPoints.Select(e => e.ToCompilerObject()).ToImmutableArray()); - private static BigInteger ToBigInteger(this ArraySegment blob) => + internal static BigInteger ToBigInteger(this ArraySegment blob) => new BigInteger(blob); - private static Source ToSource(this string sourceFile) => + internal static Source ToSource(this string sourceFile) => new Source(sourceFile, QsNullable.Null); - private static DataTypes.Position ToCompilerObject(this Position position) => + internal static DataTypes.Position ToCompilerObject(this Position position) => DataTypes.Position.Create( line: position.Line, column: position.Column); - private static DataTypes.Range ToCompilerObject(this Range range) => + internal static DataTypes.Range ToCompilerObject(this Range range) => DataTypes.Range.Create( start: range.Start.ToCompilerObject(), end: range.End.ToCompilerObject()); - private static SyntaxTokens.AccessModifier ToCompilerObject(this AccessModifier bondAccessModifier) => + internal static SyntaxTokens.AccessModifier ToCompilerObject(this AccessModifier bondAccessModifier) => bondAccessModifier switch { AccessModifier.DefaultAccess => SyntaxTokens.AccessModifier.DefaultAccess, @@ -47,18 +48,18 @@ private static SyntaxTokens.AccessModifier ToCompilerObject(this AccessModifier _ => throw new ArgumentException($"Unsupported Bond AccessModifier '{bondAccessModifier}'") }; - private static SyntaxTokens.CharacteristicsKind ToCompilerObject( + internal static SyntaxTokens.CharacteristicsKind ToCompilerObject( this CharacteristicsKindComposition bondCharacteristicsKindComposition) => bondCharacteristicsKindComposition.ToCompilerObjectGeneric(typeTranslator: ToCompilerObject); - private static SyntaxTokens.QsExpressionKind ToCompilerObject( + internal static SyntaxTokens.QsExpressionKind ToCompilerObject( this QsExpressionKindComposition bondQsExpressionKindComposition) => bondQsExpressionKindComposition.ToCompilerObjectGeneric( expressionTranslator: ToCompilerObject, symbolTranslator: ToCompilerObject, typeTranslator: ToCompilerObject); - private static SyntaxTokens.QsGeneratorDirective ToCompilerObject(this QsGeneratorDirective bondQsGeneratorDirective) => + internal static SyntaxTokens.QsGeneratorDirective ToCompilerObject(this QsGeneratorDirective bondQsGeneratorDirective) => bondQsGeneratorDirective switch { QsGeneratorDirective.Distribute => SyntaxTokens.QsGeneratorDirective.Distribute, @@ -68,17 +69,17 @@ private static SyntaxTokens.QsGeneratorDirective ToCompilerObject(this QsGenerat _ => throw new ArgumentException($"Unsupported Bond QsGeneratorDirective '{bondQsGeneratorDirective}'") }; - private static SyntaxTokens.QsInitializerKind ToCompilerObject( + internal static SyntaxTokens.QsInitializerKind ToCompilerObject( this QsInitializerKindComposition bondQsInitializerKindComposition) => bondQsInitializerKindComposition.ToCompilerObjectGeneric( initializerTranslator: ToCompilerObject, expressionTranslator: ToCompilerObject); - private static SyntaxTokens.Modifiers ToCompilerObject(this Modifiers bondModifiers) => + internal static SyntaxTokens.Modifiers ToCompilerObject(this Modifiers bondModifiers) => new SyntaxTokens.Modifiers( access: bondModifiers.Access.ToCompilerObject()); - private static SyntaxTokens.OpProperty ToCompilerObject(this OpProperty bondOpProperty) => + internal static SyntaxTokens.OpProperty ToCompilerObject(this OpProperty bondOpProperty) => bondOpProperty switch { OpProperty.Adjointable => SyntaxTokens.OpProperty.Adjointable, @@ -86,7 +87,7 @@ private static SyntaxTokens.OpProperty ToCompilerObject(this OpProperty bondOpPr _ => throw new ArgumentException($"Unsupported Bond OpProperty '{bondOpProperty}'") }; - private static SyntaxTokens.QsPauli ToCompilerObject(this QsPauli bondQsPauli) => + internal static SyntaxTokens.QsPauli ToCompilerObject(this QsPauli bondQsPauli) => bondQsPauli switch { QsPauli.PauliI => SyntaxTokens.QsPauli.PauliI, @@ -96,7 +97,7 @@ private static SyntaxTokens.QsPauli ToCompilerObject(this QsPauli bondQsPauli) = _ => throw new ArgumentException($"Unsupported Bond QsPauli '{bondQsPauli}'") }; - private static SyntaxTokens.QsResult ToCompilerObject(this QsResult bondQsResult) => + internal static SyntaxTokens.QsResult ToCompilerObject(this QsResult bondQsResult) => bondQsResult switch { QsResult.Zero => SyntaxTokens.QsResult.Zero, @@ -104,15 +105,15 @@ private static SyntaxTokens.QsResult ToCompilerObject(this QsResult bondQsResult _ => throw new ArgumentException($"Unsupported Bond QsResult '{bondQsResult}'") }; - private static SyntaxTokens.QsTuple> ToCompilerObject( + internal static SyntaxTokens.QsTuple> ToCompilerObject( this QsTuple> bondQsTuple) => bondQsTuple.ToCompilerObjectGeneric(typeTranslator: ToCompilerObject); - private static SyntaxTokens.QsTuple ToCompilerObject( + internal static SyntaxTokens.QsTuple ToCompilerObject( this QsTuple bondQsTuple) => bondQsTuple.ToCompilerObjectGeneric(typeTranslator: ToCompilerObject); - private static SyntaxTokens.QsTypeKind ToCompilerObject( + internal static SyntaxTokens.QsTypeKind ToCompilerObject( this QsTypeKindComposition bondQsTypeKindComposition) => bondQsTypeKindComposition.ToCompilerObjectGeneric( typeTranslator: ToCompilerObject, @@ -120,12 +121,12 @@ private static SyntaxTokens.QsResult ToCompilerObject(this QsResult bondQsResult paramTranslator: ToCompilerObject, characteristicsTranslator: ToCompilerObject); - private static SyntaxTree.CallableInformation ToCompilerObject(this CallableInformation bondCallableInformation) => + internal static SyntaxTree.CallableInformation ToCompilerObject(this CallableInformation bondCallableInformation) => new SyntaxTree.CallableInformation( characteristics: bondCallableInformation.Characteristics.ToCompilerObject(), inferredInformation: bondCallableInformation.InferredInformation.ToCompilerObject()); - private static SyntaxTree.Identifier ToCompilerObject(Identifier bondIdentifier) + internal static SyntaxTree.Identifier ToCompilerObject(Identifier bondIdentifier) { string UnexpectedNullFieldMessage(string fieldName) => $"Bond Identifier '{fieldName}' field is null when Kind is '{bondIdentifier.Kind}'"; @@ -152,40 +153,40 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTree.InferredCallableInformation ToCompilerObject( + internal static SyntaxTree.InferredCallableInformation ToCompilerObject( this InferredCallableInformation bondInferredCallableInformation) => new SyntaxTree.InferredCallableInformation( isSelfAdjoint: bondInferredCallableInformation.IsSelfAdjoint, isIntrinsic: bondInferredCallableInformation.IsIntrinsic); - private static SyntaxTree.InferredExpressionInformation ToCompilerObject( + internal static SyntaxTree.InferredExpressionInformation ToCompilerObject( this InferredExpressionInformation bondInferredExpressionInformation) => new SyntaxTree.InferredExpressionInformation( isMutable: bondInferredExpressionInformation.IsMutable, hasLocalQuantumDependency: bondInferredExpressionInformation.HasLocalQuantumDependency); - private static SyntaxTree.LocalDeclarations ToCompilerObject( + internal static SyntaxTree.LocalDeclarations ToCompilerObject( this LocalDeclarations bondLocalDeclarations) => new SyntaxTree.LocalDeclarations( variables: bondLocalDeclarations.Variables.Select(v => v.ToCompilerObject()).ToImmutableArray()); - private static SyntaxTree.LocalVariableDeclaration ToCompilerObject( + internal static SyntaxTree.LocalVariableDeclaration ToCompilerObject( this LocalVariableDeclaration bondLocalVariableDeclaration) => bondLocalVariableDeclaration.ToCompilerObjectGeneric(typeTranslator: s => s); - private static SyntaxTree.LocalVariableDeclaration ToCompilerObject( + internal static SyntaxTree.LocalVariableDeclaration ToCompilerObject( this LocalVariableDeclaration bondLocalVariableDeclaration) => bondLocalVariableDeclaration.ToCompilerObjectGeneric(typeTranslator: ToCompilerObject); - public static SyntaxTree.QsBinding ToCompilerObject( + internal static SyntaxTree.QsBinding ToCompilerObject( this QsBinding bondQsBinding) => bondQsBinding.ToCompilerObjectGeneric(typeTranslator: ToCompilerObject); - private static SyntaxTree.QsBinding ToCompilerObject( + internal static SyntaxTree.QsBinding ToCompilerObject( this QsBinding bondQsBinding) => bondQsBinding.ToCompilerObjectGeneric(typeTranslator: ToCompilerObject); - private static SyntaxTree.QsBindingKind ToCompilerObject(this QsBindingKind bondQsBindingKind) => + internal static SyntaxTree.QsBindingKind ToCompilerObject(this QsBindingKind bondQsBindingKind) => bondQsBindingKind switch { QsBindingKind.ImmutableBinding => SyntaxTree.QsBindingKind.ImmutableBinding, @@ -193,7 +194,7 @@ private static SyntaxTree.QsBindingKind ToCompilerObject(this QsBindingKind bond _ => throw new ArgumentException($"Unsupported Bond QsBindingKind '{bondQsBindingKind}'") }; - private static SyntaxTree.QsCallable ToCompilerObject(this QsCallable bondQsCallable) => + internal static SyntaxTree.QsCallable ToCompilerObject(this QsCallable bondQsCallable) => new SyntaxTree.QsCallable( kind: bondQsCallable.Kind.ToCompilerObject(), fullName: bondQsCallable.FullName.ToCompilerObject(), @@ -209,7 +210,7 @@ private static SyntaxTree.QsCallable ToCompilerObject(this QsCallable bondQsCall documentation: bondQsCallable.Documentation.ToImmutableArray(), comments: bondQsCallable.Comments.ToCompilerObject()); - private static SyntaxTree.QsCallableKind ToCompilerObject(this QsCallableKind bondQsCallableKind) => + internal static SyntaxTree.QsCallableKind ToCompilerObject(this QsCallableKind bondQsCallableKind) => bondQsCallableKind switch { QsCallableKind.Operation => SyntaxTree.QsCallableKind.Operation, @@ -218,24 +219,24 @@ private static SyntaxTree.QsCallableKind ToCompilerObject(this QsCallableKind bo _ => throw new ArgumentException($"Unsupported Bond QsCallableKind '{bondQsCallableKind}'") }; - private static SyntaxTree.QsComments ToCompilerObject(this QsComments bondQsComments) => + internal static SyntaxTree.QsComments ToCompilerObject(this QsComments bondQsComments) => new SyntaxTree.QsComments( openingComments: bondQsComments.OpeningComments.ToImmutableArray(), closingComments: bondQsComments.ClosingComments.ToImmutableArray()); - private static SyntaxTree.QsConditionalStatement ToCompilerObject(this QsConditionalStatement bondQsConditionalStatement) => + internal static SyntaxTree.QsConditionalStatement ToCompilerObject(this QsConditionalStatement bondQsConditionalStatement) => new SyntaxTree.QsConditionalStatement( conditionalBlocks: bondQsConditionalStatement.ConditionalBlocks.Select(c => c.ToCompilerObject()).ToImmutableArray(), @default: bondQsConditionalStatement.Default != null ? bondQsConditionalStatement.Default.ToCompilerObject().ToQsNullableGeneric() : QsNullable.Null); - private static SyntaxTree.QsConjugation ToCompilerObject(this QsConjugation bondQsConjugation) => + internal static SyntaxTree.QsConjugation ToCompilerObject(this QsConjugation bondQsConjugation) => new SyntaxTree.QsConjugation( outerTransformation: bondQsConjugation.OuterTransformation.ToCompilerObject(), innerTransformation: bondQsConjugation.InnerTransformation.ToCompilerObject()); - private static SyntaxTree.QsCustomType ToCompilerObject(this QsCustomType bondQsCustomType) => + internal static SyntaxTree.QsCustomType ToCompilerObject(this QsCustomType bondQsCustomType) => new SyntaxTree.QsCustomType( fullName: bondQsCustomType.FullName.ToCompilerObject(), attributes: bondQsCustomType.Attributes.Select(a => a.ToCompilerObject()).ToImmutableArray(), @@ -249,7 +250,7 @@ private static SyntaxTree.QsCustomType ToCompilerObject(this QsCustomType bondQs documentation: bondQsCustomType.Documentation.ToImmutableArray(), comments: bondQsCustomType.Comments.ToCompilerObject()); - private static SyntaxTree.QsDeclarationAttribute ToCompilerObject(this QsDeclarationAttribute bondQsDeclarationAttribute) => + internal static SyntaxTree.QsDeclarationAttribute ToCompilerObject(this QsDeclarationAttribute bondQsDeclarationAttribute) => new SyntaxTree.QsDeclarationAttribute( typeId: bondQsDeclarationAttribute.TypeId != null ? bondQsDeclarationAttribute.TypeId.ToCompilerObject().ToQsNullableGeneric() : @@ -258,13 +259,13 @@ private static SyntaxTree.QsDeclarationAttribute ToCompilerObject(this QsDeclara offset: bondQsDeclarationAttribute.Offset.ToCompilerObject(), comments: bondQsDeclarationAttribute.Comments.ToCompilerObject()); - private static SyntaxTree.QsForStatement ToCompilerObject(this QsForStatement bondQsForStatement) => + internal static SyntaxTree.QsForStatement ToCompilerObject(this QsForStatement bondQsForStatement) => new SyntaxTree.QsForStatement( loopItem: bondQsForStatement.LoopItem.ToCompilerObject(), iterationValues: bondQsForStatement.IterationValues.ToCompilerObject(), body: bondQsForStatement.Body.ToCompilerObject()); - private static SyntaxTree.QsLocalSymbol ToCompilerObject(this QsLocalSymbol bondQsLocalSymbol) + internal static SyntaxTree.QsLocalSymbol ToCompilerObject(this QsLocalSymbol bondQsLocalSymbol) { if (bondQsLocalSymbol.Kind == QsLocalSymbolKind.ValidName) { @@ -284,12 +285,12 @@ private static SyntaxTree.QsLocalSymbol ToCompilerObject(this QsLocalSymbol bond } } - private static SyntaxTree.QsLocation ToCompilerObject(this QsLocation bondQsLocation) => + internal static SyntaxTree.QsLocation ToCompilerObject(this QsLocation bondQsLocation) => new SyntaxTree.QsLocation( offset: bondQsLocation.Offset.ToCompilerObject(), range: bondQsLocation.Range.ToCompilerObject()); - private static SyntaxTree.QsNamespace ToCompilerObject(this QsNamespace bondQsNamespace) => + internal static SyntaxTree.QsNamespace ToCompilerObject(this QsNamespace bondQsNamespace) => new SyntaxTree.QsNamespace( name: bondQsNamespace.Name, elements: bondQsNamespace.Elements.Select(e => e.ToCompilerObject()).ToImmutableArray(), @@ -297,7 +298,7 @@ private static SyntaxTree.QsNamespace ToCompilerObject(this QsNamespace bondQsNa p => p.FileName, p => p.DocumentationItems.ToImmutableArray())); - private static SyntaxTree.QsNamespaceElement ToCompilerObject(this QsNamespaceElement bondQsNamespaceElement) + internal static SyntaxTree.QsNamespaceElement ToCompilerObject(this QsNamespaceElement bondQsNamespaceElement) { string UnexpectedNullFieldMessage(string fieldName) => $"Bond QsNamespaceElement '{fieldName}' field is null when Kind is '{bondQsNamespaceElement.Kind}'"; @@ -324,7 +325,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTree.QsPositionedBlock ToCompilerObject(this QsPositionedBlock bondQsPositionedBlock) => + internal static SyntaxTree.QsPositionedBlock ToCompilerObject(this QsPositionedBlock bondQsPositionedBlock) => new SyntaxTree.QsPositionedBlock( body: bondQsPositionedBlock.Body.ToCompilerObject(), location: bondQsPositionedBlock.Location != null ? @@ -332,18 +333,18 @@ private static SyntaxTree.QsPositionedBlock ToCompilerObject(this QsPositionedBl QsNullable.Null, comments: bondQsPositionedBlock.Comments.ToCompilerObject()); - private static SyntaxTree.QsQualifiedName ToCompilerObject(this QsQualifiedName bondQsQualifiedName) => + internal static SyntaxTree.QsQualifiedName ToCompilerObject(this QsQualifiedName bondQsQualifiedName) => new SyntaxTree.QsQualifiedName( @namespace: bondQsQualifiedName.Namespace, name: bondQsQualifiedName.Name); - private static SyntaxTree.QsQubitScope ToCompilerObject(this QsQubitScope bondQsQubitScope) => + internal static SyntaxTree.QsQubitScope ToCompilerObject(this QsQubitScope bondQsQubitScope) => new SyntaxTree.QsQubitScope( kind: bondQsQubitScope.Kind.ToCompilerObject(), binding: bondQsQubitScope.Binding.ToCompilerObject(), body: bondQsQubitScope.Body.ToCompilerObject()); - private static SyntaxTree.QsQubitScopeKind ToCompilerObject(this QsQubitScopeKind bondQsQubitScopeKind) => + internal static SyntaxTree.QsQubitScopeKind ToCompilerObject(this QsQubitScopeKind bondQsQubitScopeKind) => bondQsQubitScopeKind switch { QsQubitScopeKind.Allocate => SyntaxTree.QsQubitScopeKind.Allocate, @@ -351,18 +352,18 @@ private static SyntaxTree.QsQubitScopeKind ToCompilerObject(this QsQubitScopeKin _ => throw new ArgumentException($"Unsupported Bond QsQubitScopeKind '{bondQsQubitScopeKind}'") }; - private static SyntaxTree.QsRepeatStatement ToCompilerObject(this QsRepeatStatement bondQsRepeatStatement) => + internal static SyntaxTree.QsRepeatStatement ToCompilerObject(this QsRepeatStatement bondQsRepeatStatement) => new SyntaxTree.QsRepeatStatement( repeatBlock: bondQsRepeatStatement.RepeatBlock.ToCompilerObject(), successCondition: bondQsRepeatStatement.SuccessCondition.ToCompilerObject(), fixupBlock: bondQsRepeatStatement.FixupBlock.ToCompilerObject()); - private static SyntaxTree.QsScope ToCompilerObject(this QsScope bondQsScope) => + internal static SyntaxTree.QsScope ToCompilerObject(this QsScope bondQsScope) => new SyntaxTree.QsScope( statements: bondQsScope.Statements.Select(s => s.ToCompilerObject()).ToImmutableArray(), knownSymbols: bondQsScope.KnownSymbols.ToCompilerObject()); - private static SyntaxTree.QsSpecialization ToCompilerObject(this QsSpecialization bondQsSpecialization) => + internal static SyntaxTree.QsSpecialization ToCompilerObject(this QsSpecialization bondQsSpecialization) => new SyntaxTree.QsSpecialization( kind: bondQsSpecialization.Kind.ToCompilerObject(), parent: bondQsSpecialization.Parent.ToCompilerObject(), @@ -379,7 +380,7 @@ private static SyntaxTree.QsSpecialization ToCompilerObject(this QsSpecializatio documentation: bondQsSpecialization.Documentation.ToImmutableArray(), comments: bondQsSpecialization.Comments.ToCompilerObject()); - private static SyntaxTree.QsSpecializationKind ToCompilerObject(this QsSpecializationKind bondQsSpecializationKind) => + internal static SyntaxTree.QsSpecializationKind ToCompilerObject(this QsSpecializationKind bondQsSpecializationKind) => bondQsSpecializationKind switch { QsSpecializationKind.QsAdjoint => SyntaxTree.QsSpecializationKind.QsAdjoint, @@ -389,7 +390,7 @@ private static SyntaxTree.QsSpecializationKind ToCompilerObject(this QsSpecializ _ => throw new ArgumentException($"Unsupported Bond QsSpecializationKind '{bondQsSpecializationKind}'") }; - private static SyntaxTree.QsStatement ToCompilerObject(this QsStatement bondQsStatement) => + internal static SyntaxTree.QsStatement ToCompilerObject(this QsStatement bondQsStatement) => new SyntaxTree.QsStatement( statement: bondQsStatement.Statement.ToCompilerObject(), symbolDeclarations: bondQsStatement.SymbolDeclarations.ToCompilerObject(), @@ -398,7 +399,7 @@ private static SyntaxTree.QsStatement ToCompilerObject(this QsStatement bondQsSt QsNullable.Null, comments: bondQsStatement.Comments.ToCompilerObject()); - private static SyntaxTree.QsStatementKind ToCompilerObject( + internal static SyntaxTree.QsStatementKind ToCompilerObject( this QsStatementKindComposition bondQsStatementKindComposition) { string InvalidKindForFieldMessage(string fieldName) => @@ -509,7 +510,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTree.QsTypeItem ToCompilerObject(this QsTypeItem bondQsTypeItem) + internal static SyntaxTree.QsTypeItem ToCompilerObject(this QsTypeItem bondQsTypeItem) { string UnexpectedNullFieldMessage(string fieldName) => $"Bond QsTypeItem '{fieldName}' field is null when Kind is '{bondQsTypeItem.Kind}'"; @@ -537,7 +538,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTree.QsTypeParameter ToCompilerObject(this QsTypeParameter bondQsTypeParameter) => + internal static SyntaxTree.QsTypeParameter ToCompilerObject(this QsTypeParameter bondQsTypeParameter) => new SyntaxTree.QsTypeParameter( origin: bondQsTypeParameter.Origin.ToCompilerObject(), typeName: bondQsTypeParameter.TypeName, @@ -545,34 +546,34 @@ private static SyntaxTree.QsTypeParameter ToCompilerObject(this QsTypeParameter bondQsTypeParameter.Range.ToCompilerObject().ToQsNullableGeneric() : QsNullable.Null); - private static SyntaxTree.QsWhileStatement ToCompilerObject(this QsWhileStatement bondQsWhileStatement) => + internal static SyntaxTree.QsWhileStatement ToCompilerObject(this QsWhileStatement bondQsWhileStatement) => new SyntaxTree.QsWhileStatement( condition: bondQsWhileStatement.Condition.ToCompilerObject(), body: bondQsWhileStatement.Body.ToCompilerObject()); - private static SyntaxTree.QsValueUpdate ToCompilerObject(this QsValueUpdate bondQsValueUpdate) => + internal static SyntaxTree.QsValueUpdate ToCompilerObject(this QsValueUpdate bondQsValueUpdate) => new SyntaxTree.QsValueUpdate( lhs: bondQsValueUpdate.Lhs.ToCompilerObject(), rhs: bondQsValueUpdate.Rhs.ToCompilerObject()); - private static SyntaxTree.ResolvedCharacteristics ToCompilerObject(this ResolvedCharacteristics bondResolvedCharacteristics) => + internal static SyntaxTree.ResolvedCharacteristics ToCompilerObject(this ResolvedCharacteristics bondResolvedCharacteristics) => SyntaxTree.ResolvedCharacteristics.New(kind: bondResolvedCharacteristics.Expression.ToCompilerObject()); // TODO: Check whether this translation is correct in a round-trip. - private static SyntaxTree.ResolvedInitializer ToCompilerObject(this ResolvedInitializer bondResolvedInitializer) => + internal static SyntaxTree.ResolvedInitializer ToCompilerObject(this ResolvedInitializer bondResolvedInitializer) => SyntaxTree.ResolvedInitializer.New(kind: bondResolvedInitializer.Initializer.ToCompilerObject()); - private static SyntaxTree.ResolvedSignature ToCompilerObject(this ResolvedSignature bondResolvedSignature) => + internal static SyntaxTree.ResolvedSignature ToCompilerObject(this ResolvedSignature bondResolvedSignature) => new SyntaxTree.ResolvedSignature( typeParameters: bondResolvedSignature.TypeParameters.Select(tp => tp.ToCompilerObject()).ToImmutableArray(), argumentType: bondResolvedSignature.ArgumentType.ToCompilerObject(), returnType: bondResolvedSignature.ReturnType.ToCompilerObject(), information: bondResolvedSignature.Information.ToCompilerObject()); - private static SyntaxTree.ResolvedType ToCompilerObject(this ResolvedType bondResolvedType) => + internal static SyntaxTree.ResolvedType ToCompilerObject(this ResolvedType bondResolvedType) => SyntaxTree.ResolvedType.New(bondResolvedType.TypeKind.ToCompilerObject()); - private static SyntaxTree.SpecializationImplementation ToCompilerObject( + internal static SyntaxTree.SpecializationImplementation ToCompilerObject( this SpecializationImplementation bondSpecializationImplementation) { string UnexpectedNullFieldMessage(string fieldName) => @@ -608,7 +609,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTree.SymbolTuple ToCompilerObject(this SymbolTuple bondSymbolTuple) + internal static SyntaxTree.SymbolTuple ToCompilerObject(this SymbolTuple bondSymbolTuple) { string UnexpectedNullFieldMessage(string fieldName) => $"Bond SymbolTuple '{fieldName}' field is null when Kind is '{bondSymbolTuple.Kind}'"; @@ -641,7 +642,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTree.TypedExpression ToCompilerObject(this TypedExpression bondTypedExpression) => + internal static SyntaxTree.TypedExpression ToCompilerObject(this TypedExpression bondTypedExpression) => new SyntaxTree.TypedExpression( expression: bondTypedExpression.Expression.ToCompilerObject(), typeArguments: bondTypedExpression.TypedArguments. @@ -653,7 +654,7 @@ private static SyntaxTree.TypedExpression ToCompilerObject(this TypedExpression bondTypedExpression.Range.ToCompilerObject().ToQsNullableGeneric() : QsNullable.Null); - private static SyntaxTree.UserDefinedType ToCompilerObject(this UserDefinedType bondUserDefinedType) => + internal static SyntaxTree.UserDefinedType ToCompilerObject(this UserDefinedType bondUserDefinedType) => new SyntaxTree.UserDefinedType( @namespace: bondUserDefinedType.Namespace, name: bondUserDefinedType.Name, @@ -661,18 +662,18 @@ private static SyntaxTree.UserDefinedType ToCompilerObject(this UserDefinedType bondUserDefinedType.Range.ToCompilerObject().ToQsNullableGeneric() : QsNullable.Null); - private static Tuple ToCompilerObject(this QsLoopItem bondQsLoopItem) => + internal static Tuple ToCompilerObject(this QsLoopItem bondQsLoopItem) => new Tuple( item1: bondQsLoopItem.SymbolTuple.ToCompilerObject(), item2: bondQsLoopItem.ResolvedType.ToCompilerObject()); - private static Tuple ToCompilerObject( + internal static Tuple ToCompilerObject( this QsConditionalBlock bondQsConditionalBlock) => new Tuple( item1: bondQsConditionalBlock.Expression.ToCompilerObject(), item2: bondQsConditionalBlock.Block.ToCompilerObject()); - private static SyntaxTokens.CharacteristicsKind ToCompilerObjectGeneric( + internal static SyntaxTokens.CharacteristicsKind ToCompilerObjectGeneric( this CharacteristicsKindComposition bondCharacteristicsKindComposition, Func typeTranslator) { @@ -722,7 +723,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTokens.QsExpressionKind ToCompilerObjectGeneric< + internal static SyntaxTokens.QsExpressionKind ToCompilerObjectGeneric< TCompilerExpression, TCompilerSymbol, TCompilerType, @@ -999,7 +1000,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTokens.QsInitializerKind ToCompilerObjectGeneric< + internal static SyntaxTokens.QsInitializerKind ToCompilerObjectGeneric< TCompilerInitializer, TCompilerExpression, TBondInitializer, @@ -1042,7 +1043,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTokens.QsTuple ToCompilerObjectGeneric( + internal static SyntaxTokens.QsTuple ToCompilerObjectGeneric( this QsTuple bondQsTuple, Func typeTranslator) { @@ -1072,7 +1073,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTokens.QsTypeKind ToCompilerObjectGeneric< + internal static SyntaxTokens.QsTypeKind ToCompilerObjectGeneric< TCompilerType, TCompilerUdt, TCompilerParam, @@ -1183,7 +1184,7 @@ string UnexpectedNullFieldMessage(string fieldName) => } } - private static SyntaxTree.LocalVariableDeclaration ToCompilerObjectGeneric( + internal static SyntaxTree.LocalVariableDeclaration ToCompilerObjectGeneric( this LocalVariableDeclaration bondLocalVariableDeclaration, Func typeTranslator) => new SyntaxTree.LocalVariableDeclaration( @@ -1195,7 +1196,7 @@ private static SyntaxTree.LocalVariableDeclaration ToCompilerObjectGe QsNullable.Null, range: bondLocalVariableDeclaration.Range.ToCompilerObject()); - private static SyntaxTree.QsBinding ToCompilerObjectGeneric( + internal static SyntaxTree.QsBinding ToCompilerObjectGeneric( this QsBinding bondQsBinding, Func typeTranslator) => new SyntaxTree.QsBinding( @@ -1203,7 +1204,7 @@ private static SyntaxTree.QsBinding ToCompilerObjectGeneric ToQsNullableGeneric(this T obj) => + internal static QsNullable ToQsNullableGeneric(this T obj) => QsNullable.NewValue(obj); } } diff --git a/src/QsCompiler/BondSchemas/V2/BondSchemaTranslator.cs b/src/QsCompiler/BondSchemas/V2/BondSchemaTranslator.cs new file mode 100644 index 0000000000..7ccd77af63 --- /dev/null +++ b/src/QsCompiler/BondSchemas/V2/BondSchemaTranslator.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using Bond; +using Microsoft.Quantum.QsCompiler.BondSchemas.V1; + +namespace Microsoft.Quantum.QsCompiler.BondSchemas.V2 +{ + /// + /// This class translates compiler objects to Bond schema objects. + /// + internal static class BondSchemaTranslator + { + /// + /// Creates a Bond schema QsCompilation object from a QsCompilation compiler object. + /// + public static QsCompilation CreateBondCompilation(SyntaxTree.QsCompilation qsCompilation) => + new QsCompilation + { + Namespaces = qsCompilation.Namespaces.Select(n => n.ToBondSchema()).ToList(), + EntryPoints = qsCompilation.EntryPoints.Select(e => e.ToBondSchema()).ToList() + }; + + internal static QsNamespace ToBondSchema(this SyntaxTree.QsNamespace qsNamespace) => + new QsNamespace + { + Name = qsNamespace.Name, + Elements = qsNamespace.Elements.Select(e => e.ToBondSchema()).ToList(), + Documentation = qsNamespace.Documentation.ToQsSourceFileDocumentationList() + }; + + internal static LinkedList> ToQsSourceFileDocumentationList( + this ILookup> qsDocumentation) + { + var documentationList = new LinkedList>(); + foreach (var qsSourceFileDocumentation in qsDocumentation) + { + foreach (var items in qsSourceFileDocumentation) + { + var qsDocumentationItem = new QsSourceFileDocumentation + { + FileName = qsSourceFileDocumentation.Key, + DocumentationItems = items.ToList() + }; + + documentationList.AddLast(new Bonded(qsDocumentationItem)); + } + } + + return documentationList; + } + } +} diff --git a/src/QsCompiler/BondSchemas/V2/CompilerDataStructuresV2.bond b/src/QsCompiler/BondSchemas/V2/CompilerDataStructuresV2.bond new file mode 100644 index 0000000000..31378cf457 --- /dev/null +++ b/src/QsCompiler/BondSchemas/V2/CompilerDataStructuresV2.bond @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import "../V1/CompilerDataStructuresV1.bond" + +namespace Microsoft.Quantum.QsCompiler.BondSchemas.V2; + +struct QsNamespace +{ + 5: string Name; + + 10: vector Elements; + + 15: list> Documentation; +} + +struct QsCompilation +{ + 5: vector Namespaces; + + 10: vector EntryPoints; +} + diff --git a/src/QsCompiler/BondSchemas/V2/CompilerDataStructuresV2.cs b/src/QsCompiler/BondSchemas/V2/CompilerDataStructuresV2.cs new file mode 100644 index 0000000000..29d66fcf63 --- /dev/null +++ b/src/QsCompiler/BondSchemas/V2/CompilerDataStructuresV2.cs @@ -0,0 +1,77 @@ + +//------------------------------------------------------------------------------ +// This code was generated by a tool. +// +// Tool : Bond Compiler 0.12.1.0 +// Input filename: C:\Microsoft\ReposB\qsharp-compiler\src\QsCompiler\BondSchemas\V2\CompilerDataStructuresV2.bond +// Output filename: CompilerDataStructuresV2_types.cs +// +// Changes to this file may cause incorrect behavior and will be lost when +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +// suppress "Missing XML comment for publicly visible type or member" +#pragma warning disable 1591 + + +#region ReSharper warnings +// ReSharper disable PartialTypeWithSinglePart +// ReSharper disable RedundantNameQualifier +// ReSharper disable InconsistentNaming +// ReSharper disable CheckNamespace +// ReSharper disable UnusedParameter.Local +// ReSharper disable RedundantUsingDirective +#endregion + +namespace Microsoft.Quantum.QsCompiler.BondSchemas.V2 +{ + using System.Collections.Generic; + + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] + public partial class QsNamespace + { + [global::Bond.Id(5)] + public string Name { get; set; } + + [global::Bond.Id(10)] + public List Elements { get; set; } + + [global::Bond.Id(15)] + public LinkedList> Documentation { get; set; } + + public QsNamespace() + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V2.QsNamespace", "QsNamespace") + {} + + protected QsNamespace(string fullName, string name) + { + Name = ""; + Elements = new List(); + Documentation = new LinkedList>(); + } + } + + [global::Bond.Schema] + [System.CodeDom.Compiler.GeneratedCode("gbc", "0.12.1.0")] + public partial class QsCompilation + { + [global::Bond.Id(5)] + public List Namespaces { get; set; } + + [global::Bond.Id(10)] + public List EntryPoints { get; set; } + + public QsCompilation() + : this("Microsoft.Quantum.QsCompiler.BondSchemas.V2.QsCompilation", "QsCompilation") + {} + + protected QsCompilation(string fullName, string name) + { + Namespaces = new List(); + EntryPoints = new List(); + } + } +} // Microsoft.Quantum.QsCompiler.BondSchemas.V2 diff --git a/src/QsCompiler/BondSchemas/V2/CompilerObjectTranslator.cs b/src/QsCompiler/BondSchemas/V2/CompilerObjectTranslator.cs new file mode 100644 index 0000000000..172345e35e --- /dev/null +++ b/src/QsCompiler/BondSchemas/V2/CompilerObjectTranslator.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using Bond; +using Microsoft.Quantum.QsCompiler.BondSchemas.V1; + +namespace Microsoft.Quantum.QsCompiler.BondSchemas.V2 +{ + /// + /// This class translates Bond schema objects to C# compiler objects. + /// + internal static class CompilerObjectTranslator + { + /// + /// Creates a C# QsCompilation compiler object from a Bond schema QsCompilation object. + /// + public static SyntaxTree.QsCompilation CreateQsCompilation( + QsCompilation bondCompilation) => + new SyntaxTree.QsCompilation( + namespaces: bondCompilation.Namespaces.Select(n => n.ToCompilerObject()).ToImmutableArray(), + entryPoints: bondCompilation.EntryPoints.Select(e => e.ToCompilerObject()).ToImmutableArray()); + + internal static SyntaxTree.QsNamespace ToCompilerObject( + this QsNamespace bondQsNamespace) => + new SyntaxTree.QsNamespace( + name: bondQsNamespace.Name, + elements: bondQsNamespace.Elements.Select(e => e.ToCompilerObject()).ToImmutableArray(), + documentation: bondQsNamespace.Documentation.ToCompilerObject()); + + internal static ILookup> ToCompilerObject( + this LinkedList> documentation) + { + var deserializedDocumentation = documentation.Select(d => d.Deserialize()); + return deserializedDocumentation.ToLookup( + p => p.FileName, + p => p.DocumentationItems.ToImmutableArray()); + } + } +} diff --git a/src/QsCompiler/BondSchemas/compile-bond.ps1 b/src/QsCompiler/BondSchemas/compile-bond.ps1 new file mode 100644 index 0000000000..26f7bd8e6f --- /dev/null +++ b/src/QsCompiler/BondSchemas/compile-bond.ps1 @@ -0,0 +1,97 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +<# + .SYNOPSIS + Compiles Bond schemas (*.bond). + + .DESCRIPTION + Compiles Bond schemas (*.bond) present in the parent directory of this script and all its subdirectories. + + .NOTES + Assumes Bond already installed through nuget and available at the "\.nuget\packages\bond.csharp\" path relative to the user's base directory. + E.g. "C:\Users\johndoe\.nuget\packages\bond.csharp\" +#> + +# Global constants. +Set-Variable -Name BondVersion -Value "9.0.3" -Option Constant + +function Get-BondResources +{ + param( + [string]$version + ); + + $bondCompiler = Join-Path $env:UserProfile "\.nuget\packages\bond.csharp\${version}\tools\gbc.exe" + if (!(Test-Path $bondCompiler -PathType Leaf)) + { + Write-Host "Bond compiler could not be found at '${bondCompiler}'" + $bondCompiler = $null + } + + $bondImportDir = Join-Path $env:UserProfile "\.nuget\packages\bond.csharp\${version}\tools\inc" + if (!(Test-Path $bondImportDir)) + { + Write-Host "Bond import directory could not be found at '${bondImportDir}'" + $bondImportDir = $null + } + + return $bondCompiler, $bondImportDir +} + +function Compile-BondToCSharp { + param( + [string]$Schema, + [string]$Compiler, + [string]$ImportDir + ); + + $schemaFullPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Schema) + $schemaName = [System.Io.Path]::GetFileNameWithoutExtension($schemaFullPath) + $outputDirectory = (Get-Item $schemaFullPath).Directory.FullName + $compileCommand = + "$Compiler" + + " c#" + + " --namespace=bond=Bond" + + " --import-dir=`"" + $ImportDir + "`"" + + " --output-dir=`"" + $outputDirectory + "`"" + + " $schemaFullPath" + + Write-Host "Bond compiler command: $compileCommand" + iex $compileCommand + + $generatedCSharpFileName = "$schemaName" + "_types.cs" + $generatedCSharpFilePath = Join-Path $outputDirectory $generatedCSharpFileName + $newGeneratedCSharpFileName = "${schemaName}.cs" + $newGeneratedCSharpFilePath = Join-Path $outputDirectory $newGeneratedCSharpFileName + if (Test-Path $newGeneratedCSharpFilePath) + { + Write-Host "Removing existing file `"$newGeneratedCSharpFilePath`"" + Remove-Item $newGeneratedCSharpFilePath + } + + Write-Host "Renaming generated C# file: `"$generatedCSharpFilePath`" -> `"$newGeneratedCSharpFilePath`"" + Rename-Item -Path $generatedCSharpFilePath -NewName $newGeneratedCSharpFileName -Force +} + +Write-Host "Using Bond version: $BondVersion" + +# Get the path to the Bond compiler (gbc.exe) and the Bond import directory. +$bondCompiler, $bondImportDir = Get-BondResources -Version $BondVersion +if (($bondCompiler -eq $null) -or ($bondImportDir -eq $null)) +{ + Write-Error "Bond resources not found" + exit 1 +} + +Write-Host "Using Bond compiler: `"$bondCompiler`"" +Write-Host "Using Bond import directory: `"$bondImportDir`"" +Write-Host "`n" + +# Go through all *.bond files recursively and compile them. +Get-ChildItem -Path $PSScriptRoot -Filter *.bond -Recurse -File | ForEach-Object { + $bondSchema = $_.FullName + Write-Host "Compiling $bondSchema ..." + Compile-BondToCSharp -Schema $bondSchema -Compiler $bondCompiler -ImportDir $bondImportDir + Write-Host "`n" +} diff --git a/src/QsCompiler/CompilationManager/AssemblyLoader.cs b/src/QsCompiler/CompilationManager/AssemblyLoader.cs index eccb55895a..1c0fde8433 100644 --- a/src/QsCompiler/CompilationManager/AssemblyLoader.cs +++ b/src/QsCompiler/CompilationManager/AssemblyLoader.cs @@ -19,6 +19,8 @@ namespace Microsoft.Quantum.QsCompiler { + using BondQsCompilation = BondSchemas.V2.QsCompilation; + /// /// This class relies on the ECMA-335 standard to extract information contained in compiled binaries. /// The standard can be found here: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-335.pdf, @@ -26,6 +28,21 @@ namespace Microsoft.Quantum.QsCompiler /// public static class AssemblyLoader { + /// + /// TODO: Document. + /// + private static readonly IDictionary SyntaxTreeResources = + new Dictionary() + { +#pragma warning disable CS0618 // Type or member is obsolete + { DotnetCoreDll.ResourceName, null }, +#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning disable IDE0001 // Simplify Names + { DotnetCoreDll.ResourceNameQsDataBondV1, typeof(BondSchemas.V1.QsCompilation) }, + { DotnetCoreDll.ResourceNameQsDataBondV2, typeof(BondSchemas.V2.QsCompilation) } +#pragma warning restore IDE0001 // Simplify Names + }; + /// /// Loads the Q# data structures in a referenced assembly given the Uri to that assembly, /// and returns the loaded content as out parameter. @@ -112,7 +129,47 @@ public static bool LoadSyntaxTree( try { PerformanceTracking.TaskStart(PerformanceTracking.Task.SyntaxTreeDeserialization); - compilation = BondSchemas.Protocols.DeserializeQsCompilationFromSimpleBinary(byteArray); + compilation = BondSchemas.Protocols.DeserializeQsCompilationFromSimpleBinary(byteArray, typeof(BondQsCompilation)); + PerformanceTracking.TaskEnd(PerformanceTracking.Task.SyntaxTreeDeserialization); + } + catch (Exception ex) + { + onDeserializationException?.Invoke(ex); + return false; + } + + return compilation != null && IsValidCompilation(compilation); + } + + private static bool LoadSyntaxTree( + byte[] byteArray, + string resourceName, + [NotNullWhen(true)] out QsCompilation? compilation, + Action? onDeserializationException = null) + { + compilation = null; + if (!SyntaxTreeResources.TryGetValue(resourceName, out var type)) + { + onDeserializationException?.Invoke(new ArgumentException($"Unknown syntax tree resource name '{resourceName}'")); + return false; + } + + try + { + PerformanceTracking.TaskStart(PerformanceTracking.Task.SyntaxTreeDeserialization); + if (type != null) + { + compilation = BondSchemas.Protocols.DeserializeQsCompilationFromSimpleBinary( + byteArray, + type); + } + else + { +#pragma warning disable 618 // LoadSyntaxTree is obsolete. + LoadSyntaxTree(new MemoryStream(byteArray), out compilation, onDeserializationException); +#pragma warning restore 618 + } + PerformanceTracking.TaskEnd(PerformanceTracking.Task.SyntaxTreeDeserialization); } catch (Exception ex) @@ -180,27 +237,25 @@ private static bool FromResource( { compilation = null; var metadataReader = assemblyFile.GetMetadataReader(); - bool isBondV1ResourcePresent = false; - bool isNewtonSoftResourcePresent = false; - ManifestResource resource; - if (metadataReader.Resources().TryGetValue(DotnetCoreDll.ResourceNameQsDataBondV1, out resource)) - { - isBondV1ResourcePresent = true; - } -#pragma warning disable 618 // ResourceName is obsolete. - else if (metadataReader.Resources().TryGetValue(DotnetCoreDll.ResourceName, out resource)) -#pragma warning restore 618 + string? resourceName = null; + ManifestResource resource = default; + + // Get the resource name of the syntax tree resource name included in this assembly. + foreach (var item in SyntaxTreeResources) { - isNewtonSoftResourcePresent = true; + if (metadataReader.Resources().TryGetValue(item.Key, out resource)) + { + resourceName = item.Key; + break; + } } // The offset of resources is relative to the resources directory. // It is possible that there is no offset given because a valid dll allows for extenal resources. // In all Q# dlls there will be a resource with the specific name chosen by the compiler. - var isResourcePresent = isBondV1ResourcePresent || isNewtonSoftResourcePresent; var resourceDir = assemblyFile.PEHeaders.CorHeader.ResourcesDirectory; if (!assemblyFile.PEHeaders.TryGetDirectoryOffset(resourceDir, out var directoryOffset) || - !isResourcePresent || + (resourceName == null) || !resource.Implementation.IsNil) { return false; @@ -217,20 +272,11 @@ private static bool FromResource( var resourceLength = BitConverter.ToInt32(image.GetContent(absResourceOffset, sizeof(int)).ToArray(), 0); var resourceData = image.GetContent(absResourceOffset + sizeof(int), resourceLength).ToArray(); PerformanceTracking.TaskEnd(PerformanceTracking.Task.LoadDataFromReferenceToStream); - - // Use the correct method depending on the resource. - if (isBondV1ResourcePresent) - { - return LoadSyntaxTree(resourceData, out compilation, onDeserializationException); - } - else if (isNewtonSoftResourcePresent) - { -#pragma warning disable 618 // LoadSyntaxTree is obsolete. - return LoadSyntaxTree(new MemoryStream(resourceData), out compilation, onDeserializationException); -#pragma warning restore 618 - } - - return false; + return LoadSyntaxTree( + resourceData, + resourceName, + out compilation, + onDeserializationException); } // tools for loading headers based on attributes in compiled C# code (early setup for shipping Q# libraries) diff --git a/src/QsCompiler/DataStructures/ReservedKeywords.fs b/src/QsCompiler/DataStructures/ReservedKeywords.fs index 5262764dcb..31092dab04 100644 --- a/src/QsCompiler/DataStructures/ReservedKeywords.fs +++ b/src/QsCompiler/DataStructures/ReservedKeywords.fs @@ -294,8 +294,9 @@ module DotnetCoreDll = let ResourceName = "__qsharp_data__.bson" let ResourceNameQsDataBondV1 = "__qsharp_data_bond_v1__.bson" + let ResourceNameQsDataBondV2 = "__qsharp_data_bond_v2__.bson" // Should always provide the name of the resource currently used by the compiler to attach the syntax tree to a DLL. - let SyntaxTreeResourceName = ResourceNameQsDataBondV1 + let SyntaxTreeResourceName = ResourceNameQsDataBondV2 let MetadataNamespace = "__qsharp__" let ReferenceAlias = "__qsharp_reference__" let MetadataType = "Metadata"