Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 /// <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);
 }
Esempio n. 6
0
        /// <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));
        }
Esempio n. 7
0
 public override void Visit(IAddition operation)
 {
     ProcessOperation(operation);
 }
Esempio n. 8
0
 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);
   }
 }
Esempio n. 10
0
 /// <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);
 }
Esempio n. 11
0
 /// <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;
 }
Esempio n. 12
0
 public override void TraverseChildren(IAddition addition)
 {
     base.TraverseChildren(addition);
     ((Addition)addition).Type = this.GetBinaryNumericOperationType(addition, addition.TreatOperandsAsUnsignedIntegers);
 }
 public void Setup()
 {
     _addition = new Addition();
 }
Esempio n. 14
0
 /// <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);
 }
Esempio n. 16
0
 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;
 }
Esempio n. 17
0
 public CalculationRepository(DatabaseContext context, IRepository <Users> userRepository, IAddition addition)
 {
     this.context        = context;
     this.userRepository = userRepository;
     this.addition       = addition;
 }
Esempio n. 18
0
 //^ 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();
 }
Esempio n. 19
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="addition"></param>
 public Addition(IAddition addition)
   : base(addition) {
   this.CheckOverflow = addition.CheckOverflow;
   this.TreatOperandsAsUnsignedIntegers = addition.TreatOperandsAsUnsignedIntegers;
 }
Esempio n. 20
0
 /// <summary>
 /// Performs some computation with the given addition.
 /// </summary>
 /// <param name="addition"></param>
 public virtual void Visit(IAddition addition)
 {
     this.Visit((IBinaryOperation)addition);
 }
Esempio n. 21
0
 public override void Visit(IAddition addition)
 {
     allElements.Add(new InvokInfo(Traverser, "IAddition", addition));
 }
Esempio n. 22
0
 public virtual void onASTElement(IAddition addition) { }
 /// <summary>
 /// Rewrites the given addition.
 /// </summary>
 /// <param name="addition"></param>
 public virtual IExpression Rewrite(IAddition addition)
 {
     return addition;
 }
Esempio n. 24
0
 public void Visit(IAddition addition)
 {
     this.result = this.copier.Copy(addition);
 }
Esempio n. 25
0
 public override void TraverseChildren(IAddition addition) {
   base.TraverseChildren(addition);
   ((Addition)addition).Type = this.GetBinaryNumericOperationType(addition, addition.TreatOperandsAsUnsignedIntegers);
 }
Esempio n. 26
0
 public virtual void onASTElement(IAddition addition)
 {
 }
Esempio n. 27
0
    /// <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;
    }
Esempio n. 28
0
 public override IExpression Rewrite(IAddition operation)
 {
     return(ReplaceOperation(operation));
 }
Esempio n. 29
0
    /// <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)
 {
 }
Esempio n. 32
0
 /// <summary>
 /// Performs some computation with the given addition.
 /// </summary>
 /// <param name="addition"></param>
 public virtual void Visit(IAddition addition)
 {
 }
Esempio n. 33
0
 public void Visit(IAddition addition)
 {
     throw new NotImplementedException();
 }
Esempio n. 34
0
 /// <summary>
 /// Traverses the children of the addition.
 /// </summary>
 public virtual void TraverseChildren(IAddition addition)
 {
     Contract.Requires(addition != null);
       this.TraverseChildren((IBinaryOperation)addition);
 }
Esempio n. 35
0
 /// <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)
 {
Esempio n. 36
0
 public void Visit(IAddition addition)
 {
     this.traverser.Traverse(addition);
 }
Esempio n. 37
0
 public override void Visit(IAddition binary)
 {
     _formattedValue = Format(binary.LeftOperand) + " + " + Format(binary.RightOperand);
 }
Esempio n. 38
0
 public void Visit(IAddition addition)
 {
     Contract.Requires(addition != null);
       throw new NotImplementedException();
 }
Esempio n. 39
0
 public void Visit(IAddition addition)
 {
     this.result = this.rewriter.Rewrite(addition);
 }
Esempio n. 40
0
 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));
 }
Esempio n. 41
0
 /// <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);
 }
Esempio n. 42
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="addition"></param>
 public Addition(IAddition addition)
     : base(addition)
 {
     this.CheckOverflow = addition.CheckOverflow;
 }
Esempio n. 43
0
 /// <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;
    }
Esempio n. 45
0
 /// <summary>
 /// Returns a shallow copy of the given addition.
 /// </summary>
 /// <param name="addition"></param>
 public Addition Copy(IAddition addition)
 {
     return new Addition(addition);
 }
Esempio n. 46
0
 public override void TraverseChildren(IAddition addition)
 {
     MethodEnter(addition);
     base.TraverseChildren(addition);
     MethodExit();
 }
Esempio n. 47
0
 /// <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;
 }