예제 #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);
        }
예제 #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);
 }
예제 #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);
        }
예제 #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);
 }
예제 #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));
        }
예제 #7
0
 public override void Visit(IAddition operation)
 {
     ProcessOperation(operation);
 }
예제 #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);
   }
 }
예제 #10
0
파일: Mutator.cs 프로젝트: riverar/devtools
 /// <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);
 }
예제 #11
0
파일: Mutator.cs 프로젝트: riverar/devtools
 /// <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;
 }
예제 #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();
 }
예제 #14
0
파일: Visitor.cs 프로젝트: riverar/devtools
 /// <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);
 }
예제 #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;
 }
예제 #17
0
 public CalculationRepository(DatabaseContext context, IRepository <Users> userRepository, IAddition addition)
 {
     this.context        = context;
     this.userRepository = userRepository;
     this.addition       = addition;
 }
예제 #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();
 }
예제 #19
0
파일: Expressions.cs 프로젝트: xornand/cci
 /// <summary>
 /// 
 /// </summary>
 /// <param name="addition"></param>
 public Addition(IAddition addition)
   : base(addition) {
   this.CheckOverflow = addition.CheckOverflow;
   this.TreatOperandsAsUnsignedIntegers = addition.TreatOperandsAsUnsignedIntegers;
 }
예제 #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);
 }
예제 #21
0
 public override void Visit(IAddition addition)
 {
     allElements.Add(new InvokInfo(Traverser, "IAddition", addition));
 }
예제 #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;
 }
예제 #24
0
파일: Copier.cs 프로젝트: riverar/devtools
 public void Visit(IAddition addition)
 {
     this.result = this.copier.Copy(addition);
 }
예제 #25
0
 public override void TraverseChildren(IAddition addition) {
   base.TraverseChildren(addition);
   ((Addition)addition).Type = this.GetBinaryNumericOperationType(addition, addition.TreatOperandsAsUnsignedIntegers);
 }
예제 #26
0
 public virtual void onASTElement(IAddition addition)
 {
 }
예제 #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;
    }
예제 #28
0
 public override IExpression Rewrite(IAddition operation)
 {
     return(ReplaceOperation(operation));
 }
예제 #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);
    }
예제 #30
0
        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)
 {
 }
예제 #32
0
 /// <summary>
 /// Performs some computation with the given addition.
 /// </summary>
 /// <param name="addition"></param>
 public virtual void Visit(IAddition addition)
 {
 }
예제 #33
0
 public void Visit(IAddition addition)
 {
     throw new NotImplementedException();
 }
예제 #34
0
 /// <summary>
 /// Traverses the children of the addition.
 /// </summary>
 public virtual void TraverseChildren(IAddition addition)
 {
     Contract.Requires(addition != null);
       this.TraverseChildren((IBinaryOperation)addition);
 }
예제 #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)
 {
예제 #36
0
 public void Visit(IAddition addition)
 {
     this.traverser.Traverse(addition);
 }
예제 #37
0
 public override void Visit(IAddition binary)
 {
     _formattedValue = Format(binary.LeftOperand) + " + " + Format(binary.RightOperand);
 }
예제 #38
0
 public void Visit(IAddition addition)
 {
     Contract.Requires(addition != null);
       throw new NotImplementedException();
 }
예제 #39
0
파일: Mutator.cs 프로젝트: riverar/devtools
 public void Visit(IAddition addition)
 {
     this.result = this.rewriter.Rewrite(addition);
 }
예제 #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));
 }
예제 #41
0
파일: Copier.cs 프로젝트: riverar/devtools
 /// <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);
 }
예제 #42
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="addition"></param>
 public Addition(IAddition addition)
     : base(addition)
 {
     this.CheckOverflow = addition.CheckOverflow;
 }
예제 #43
0
파일: Copier.cs 프로젝트: riverar/devtools
 /// <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;
    }
예제 #45
0
파일: Copier.cs 프로젝트: riverar/devtools
 /// <summary>
 /// Returns a shallow copy of the given addition.
 /// </summary>
 /// <param name="addition"></param>
 public Addition Copy(IAddition addition)
 {
     return new Addition(addition);
 }
예제 #46
0
 public override void TraverseChildren(IAddition addition)
 {
     MethodEnter(addition);
     base.TraverseChildren(addition);
     MethodExit();
 }
예제 #47
0
파일: Mutator.cs 프로젝트: riverar/devtools
 /// <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;
 }