Esempio n. 1
0
 //^ requires template.ContainingBlock != containingBlock;
 //^ ensures this.containingBlock == containingBlock;
 /// <summary>
 /// A copy constructor that allocates an instance that is the same as the given template, except for its containing block.
 /// </summary>
 /// <param name="containingBlock">A new value for containing block. This replaces template.ContainingBlock in the resulting copy of template.</param>
 /// <param name="template">The template to copy.</param>
 private VccAddition(BlockStatement containingBlock, VccAddition template)
     : base(containingBlock, template)
 {
 }
Esempio n. 2
0
 /// <summary>
 /// Creates an addition expression with the given left operand and this.RightOperand.
 /// The method does not use this.LeftOperand.Expression, since it may be necessary to factor out any subexpressions so that
 /// they are evaluated only once. The given left operand expression is expected to be the expression that remains after factoring.
 /// </summary>
 /// <param name="leftOperand">An expression to combine with this.RightOperand into a binary expression.</param>
 protected override Expression CreateBinaryExpression(Expression leftOperand)
 {
     Expression result = new VccAddition(leftOperand, this.RightOperand, this.SourceLocation);
       result.SetContainingExpression(this);
       return result;
 }
Esempio n. 3
0
        /// <summary>
        /// Returns an expression corresponding to *(ptr + index) where ptr is this.IndexedObject and index is the first element of this.ConvertedArguments.
        /// </summary>
        protected override IExpression ProjectAsDereferencedPointerAddition()
        {
            //transform to *(ptr + index)

              IEnumerator<Expression> indexEnumerator = this.ConvertedArguments.GetEnumerator();
              if (!indexEnumerator.MoveNext()) return CodeDummy.Expression;
              Expression ptr = this.IndexedObject;
              if (this.FixedArrayElementType != null) {
            ptr = new VccAddressOf(new VccAddressableExpression(this.IndexedObject, true), this.IndexedObject.SourceLocation);
            ptr.SetContainingExpression(this);
              }
              Expression index = indexEnumerator.Current;
              if (index.Type.IsEnum) index = this.Helper.ExplicitConversion(index, index.Type.UnderlyingType.ResolvedType);
              VccAddition addition = new VccAddition(ptr, index, this.SourceLocation);
              AddressDereference aderef = new AddressDereference(addition, this.SourceLocation);
              aderef.SetContainingExpression(this);
              return aderef.ProjectAsIExpression();
        }