internal T Key <T>(IAddition <IPrimaryKey <T> > keyedAddition) { var a = (Add)keyedAddition; if (!a.IsExecuted) { throw new TectureOrmFeatureException($"Cannot obtain primary key: addition of '{a.Entity}' did not happen yet"); } T result; string hash = Aux.IsHashRequired ? $"ORM_AdditionPK_{a.Order}" : string.Empty; if (Aux.IsEvaluationNeeded) { result = (T)(GetKey(a, GetKeyProperties <T>(a)).First()); } else { result = Aux.Get <T>(hash, "ORM Addition PK retrieval"); } if (Aux.IsTracingNeeded) { if (!Aux.IsEvaluationNeeded) { Aux.Query(hash, "test data", "ORM Addition PK retrieval"); } else { Aux.Query(hash, result, "ORM Addition PK retrieval"); } } return(result); }
internal T Key <T>(IAddition <IPrimaryKey <T> > keyedAddition) { var a = (Add)keyedAddition; if (!a.IsExecuted) { throw new TectureOrmAspectException($"Cannot obtain primary key: addition of '{a.Entity}' did not happen yet"); } string explanation = $"Get primary key of added {a.EntityType.Name}"; var p = Aux.Promise <T>(); if (p is Containing <T> c) { return(c.Get($"ORM_AdditionPK_{a.Order}", explanation)); } var result = (T)(GetKey(a, GetKeyProperties <T>(a)).First()); if (p is Demanding <T> d) { d.Fullfill(result, $"ORM_AdditionPK_{a.Order}", explanation); } return(result); }
public override void Visit(IAddition addition) { if (Process(addition)) { visitor.Visit(addition); } base.Visit(addition); }
private HLLocation ProcessAdditionExpression(IAddition pExpression) { HLLocation locationLeftOperand = ProcessExpression(pExpression.LeftOperand); HLLocation locationRightOperand = ProcessExpression(pExpression.RightOperand); HLLocation locationTemporary = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type))); mCurrentBlock.EmitAdd(locationTemporary, locationLeftOperand, locationRightOperand); return(pExpression.ResultIsUnmodifiedLeftOperand ? locationLeftOperand : locationTemporary); }
/// <summary> /// Traverses the addition. /// </summary> public void Traverse(IAddition addition) { Contract.Requires(addition != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(addition); if (this.StopTraversal) return; this.TraverseChildren(addition); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(addition); }
/// <summary> /// Retrieves primary key of just added entity /// </summary> /// <typeparam name="T">Type of primary key</typeparam> /// <param name="qr">Channel</param> /// <param name="keyedAddition">Performed addition</param> /// <returns>Primary key</returns> public static T Key <T>(this Read <QueryChannel <Query> > qr, IAddition <IPrimaryKey <T> > keyedAddition) { var pr = qr.Aspect(); return(pr.Key(keyedAddition)); }
public override void Visit(IAddition operation) { ProcessOperation(operation); }
public IAdditionable AddAddition(IAddition ingredient) { _ingredients.Add(ingredient); return(this); }
public override void TraverseChildren(IAddition addition) { var targetExpression = addition.LeftOperand as ITargetExpression; if (targetExpression != null) { // x += e bool statement = this.currentExpressionIsOpAssignStatement; this.currentExpressionIsOpAssignStatement = false; this.VisitAssignment(targetExpression, addition, (IExpression e) => this.TraverseAdditionRightOperandAndDoOperation(e), treatAsStatement: statement, pushTargetRValue: true, resultIsInitialTargetRValue: addition.ResultIsUnmodifiedLeftOperand); } else { // x + e this.Traverse(addition.LeftOperand); this.TraverseAdditionRightOperandAndDoOperation(addition); } }
/// <summary> /// Visits the specified addition. /// </summary> /// <param name="addition">The addition.</param> public override void Visit(IAddition addition) { Addition/*?*/ mutableAddition = addition as Addition; if (alwaysMakeACopy || mutableAddition == null) mutableAddition = new Addition(addition); this.resultExpression = this.myCodeMutator.Visit(mutableAddition); }
/// <summary> /// Rewrites the given addition. /// </summary> /// <param name="addition"></param> public virtual IExpression Rewrite(IAddition addition) { var mutableAddition = addition as Addition; if (mutableAddition == null) return addition; this.RewriteChildren(mutableAddition); return mutableAddition; }
public override void TraverseChildren(IAddition addition) { base.TraverseChildren(addition); ((Addition)addition).Type = this.GetBinaryNumericOperationType(addition, addition.TreatOperandsAsUnsignedIntegers); }
public void Setup() { _addition = new Addition(); }
/// <summary> /// Generates IL for the specified addition. /// </summary> /// <param name="addition">The addition.</param> public override void TraverseChildren(IAddition addition) { this.Traverse(addition.LeftOperand); this.Traverse(addition.RightOperand); OperationCode operationCode = OperationCode.Add; if (addition.CheckOverflow) { if (TypeHelper.IsSignedPrimitive(addition.Type)) operationCode = OperationCode.Add_Ovf; else if (TypeHelper.IsUnsignedPrimitive(addition.Type)) operationCode = OperationCode.Add_Ovf_Un; else if (addition.Type.TypeCode == PrimitiveTypeCode.Pointer || addition.Type.TypeCode == PrimitiveTypeCode.Reference) { if (TypeHelper.IsSignedPrimitive(addition.LeftOperand.Type) || TypeHelper.IsSignedPrimitive(addition.RightOperand.Type)) operationCode = OperationCode.Add_Ovf; else operationCode = OperationCode.Add_Ovf_Un; } } this.generator.Emit(operationCode); this.StackSize--; }
public override void Visit(IAddition addition) { if(Process(addition)){visitor.Visit(addition);} base.Visit(addition); }
private HLLocation ProcessAdditionExpression(IAddition pExpression) { HLLocation locationLeftOperand = ProcessExpression(pExpression.LeftOperand); HLLocation locationRightOperand = ProcessExpression(pExpression.RightOperand); HLLocation locationTemporary = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type))); mCurrentBlock.EmitAdd(locationTemporary, locationLeftOperand, locationRightOperand); return pExpression.ResultIsUnmodifiedLeftOperand ? locationLeftOperand : locationTemporary; }
public CalculationRepository(DatabaseContext context, IRepository <Users> userRepository, IAddition addition) { this.context = context; this.userRepository = userRepository; this.addition = addition; }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given addition. /// </summary> /// <param name="addition"></param> public virtual void Visit(IAddition addition) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(addition); this.Visit(addition.LeftOperand); this.Visit(addition.RightOperand); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count. this.path.Pop(); }
/// <summary> /// /// </summary> /// <param name="addition"></param> public Addition(IAddition addition) : base(addition) { this.CheckOverflow = addition.CheckOverflow; this.TreatOperandsAsUnsignedIntegers = addition.TreatOperandsAsUnsignedIntegers; }
/// <summary> /// Performs some computation with the given addition. /// </summary> /// <param name="addition"></param> public virtual void Visit(IAddition addition) { this.Visit((IBinaryOperation)addition); }
public override void Visit(IAddition addition) { allElements.Add(new InvokInfo(Traverser, "IAddition", addition)); }
public virtual void onASTElement(IAddition addition) { }
/// <summary> /// Rewrites the given addition. /// </summary> /// <param name="addition"></param> public virtual IExpression Rewrite(IAddition addition) { return addition; }
public void Visit(IAddition addition) { this.result = this.copier.Copy(addition); }
/// <summary> /// Returns a deep copy of the given addition. /// </summary> /// <param name="addition"></param> public Addition Copy(IAddition addition) { Contract.Requires(addition != null); Contract.Ensures(Contract.Result<Addition>() != null); var mutableCopy = this.shallowCopier.Copy(addition); this.CopyChildren((BinaryOperation)mutableCopy); return mutableCopy; }
public override IExpression Rewrite(IAddition operation) { return(ReplaceOperation(operation)); }
/// <summary> /// Returns a shallow copy of the given addition. /// </summary> /// <param name="addition"></param> public Addition Copy(IAddition addition) { Contract.Requires(addition != null); Contract.Ensures(Contract.Result<Addition>() != null); return new Addition(addition); }
public override void TraverseChildren(IAddition addition) { MethodEnter(addition); base.TraverseChildren(addition); MethodExit(); }
/// <summary> /// Performs some computation with the given addition. /// </summary> /// <param name="addition"></param> public virtual void Visit(IAddition addition) { }
public void Visit(IAddition addition) { throw new NotImplementedException(); }
/// <summary> /// Traverses the children of the addition. /// </summary> public virtual void TraverseChildren(IAddition addition) { Contract.Requires(addition != null); this.TraverseChildren((IBinaryOperation)addition); }
/// <summary> /// Retrieves primary key of just added entity /// </summary> /// <typeparam name="T1">Type of key component #1</typeparam> /// <typeparam name="T2">Type of key component #2</typeparam> /// <param name="qr">Channel</param> /// <param name="keyedAddition">Performed addition</param> /// <returns>Primary key</returns> public static (T1, T2) Key <T1, T2>(this Read <QueryChannel <Query> > qr, IAddition <IPrimaryKey <T1, T2> > keyedAddition) {
public void Visit(IAddition addition) { this.traverser.Traverse(addition); }
public override void Visit(IAddition binary) { _formattedValue = Format(binary.LeftOperand) + " + " + Format(binary.RightOperand); }
public void Visit(IAddition addition) { Contract.Requires(addition != null); throw new NotImplementedException(); }
public void Visit(IAddition addition) { this.result = this.rewriter.Rewrite(addition); }
public override void Visit(IAddition addition) { base.Visit(addition); Bpl.Expr rexp = TranslatedExpressions.Pop(); Bpl.Expr lexp = TranslatedExpressions.Pop(); TranslatedExpressions.Push(Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Add, lexp, rexp)); }
/// <summary> /// Visits the specified addition. /// </summary> /// <param name="addition">The addition.</param> public override void Visit(IAddition addition) { Addition/*?*/ mutableAddition = new Addition(addition); this.resultExpression = this.myCodeCopier.DeepCopy(mutableAddition); }
/// <summary> /// /// </summary> /// <param name="addition"></param> public Addition(IAddition addition) : base(addition) { this.CheckOverflow = addition.CheckOverflow; }
/// <summary> /// Returns a deep copy of the given addition. /// </summary> /// <param name="addition"></param> public Addition Copy(IAddition addition) { var mutableCopy = this.shallowCopier.Copy(addition); this.CopyChildren((BinaryOperation)mutableCopy); return mutableCopy; }
public override void TraverseChildren(IAddition addition) { var needsParen = LowerPrecedenceThanParentExpression(addition); var savedCurrentPrecedence = this.currentPrecedence; this.currentPrecedence = this.Precedence(addition); if (needsParen) this.sourceEmitterOutput.Write("("); if (addition.LeftOperand is ITargetExpression && ExpressionHelper.IsIntegralOne(addition.RightOperand)) { if (addition.ResultIsUnmodifiedLeftOperand) { this.Traverse(addition.LeftOperand); this.sourceEmitterOutput.Write("++"); } else { this.sourceEmitterOutput.Write("++"); this.Traverse(addition.LeftOperand); } goto Ret; } this.Traverse(addition.LeftOperand); if (addition.LeftOperand is ITargetExpression) this.sourceEmitterOutput.Write(" += "); else this.sourceEmitterOutput.Write(" + "); this.Traverse(addition.RightOperand); Ret: if (needsParen) this.sourceEmitterOutput.Write(")"); this.currentPrecedence = savedCurrentPrecedence; }
/// <summary> /// Returns a shallow copy of the given addition. /// </summary> /// <param name="addition"></param> public Addition Copy(IAddition addition) { return new Addition(addition); }
/// <summary> /// Visits the specified addition. /// </summary> /// <param name="addition">The addition.</param> public override void Visit(IAddition addition) { Addition/*?*/ mutableAddition = addition as Addition; if (mutableAddition != null) this.resultExpression = this.myCodeMutator.Visit(mutableAddition); else this.resultExpression = addition; }