/// <summary> /// Given the body of an operation, auto-generates the (content of the) adjoint specialization, /// under the assumption that operation calls may only ever occur within expression statements, /// and while-loops cannot occur within operations. /// </summary> public static QsScope GenerateAdjoint(this QsScope scope) { // Since we are pulling purely classical statements up, we are potentially changing the order of declarations. // We therefore need to generate unique variable names before reordering the statements. scope = new UniqueVariableNames().Transform(scope); scope = ApplyFunctorToOperationCalls.ApplyAdjoint(scope); scope = new ReverseOrderOfOperationCalls().Transform(scope); return(StripLocationInformation.Apply(scope)); }
internal ReverseLoops(ReverseOrderOfOperationCalls parent) : base(parent) { }
/// <summary> /// Given the body of an operation, auto-generates the (content of the) adjoint specialization, /// under the assumption that operation calls may only ever occur within expression statements, /// and while-loops cannot occur within operations. /// </summary> public static QsScope DistributeAdjointFunctorAndReverse(this QsScope scope) { scope = new ApplyFunctorToOperationCalls(QsFunctor.Adjoint).Transform(scope); scope = new ReverseOrderOfOperationCalls().Transform(scope); return(new StripLocationInformation().Transform(scope)); }