public override void Visit(IGreaterThan greaterThan)
 {
     if (Process(greaterThan))
     {
         visitor.Visit(greaterThan);
     }
     base.Visit(greaterThan);
 }
Exemple #2
0
        private HLLocation ProcessGreaterThanExpression(IGreaterThan pExpression)
        {
            HLLocation locationLeftOperand  = ProcessExpression(pExpression.LeftOperand);
            HLLocation locationRightOperand = ProcessExpression(pExpression.RightOperand);
            HLLocation locationTemporary    = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type)));

            mCurrentBlock.EmitCompare(HLCompareType.GreaterThan, locationTemporary, locationLeftOperand, locationRightOperand);
            return(pExpression.ResultIsUnmodifiedLeftOperand ? locationLeftOperand : locationTemporary);
        }
Exemple #3
0
        public override IExpression Rewrite(IGreaterThan greaterThan)
        {
            // Catch use of the x > null idiom used by Roslyn as generated
            // code for x != null statements.
            if (ExpressionHelper.IsNullLiteral(greaterThan.RightOperand))
            {
                var c = new NotEquality
                {
                    LeftOperand  = greaterThan.LeftOperand,
                    RightOperand = greaterThan.RightOperand,
                    Type         = greaterThan.Type
                };
                return(c);
            }

            return(base.Rewrite(greaterThan));
        }
Exemple #4
0
        public override IExpression Rewrite(IGreaterThan greaterThan)
        {
            var castIfPossible = greaterThan.LeftOperand as ICastIfPossible;

            if (castIfPossible != null)
            {
                var compileTimeConstant = greaterThan.RightOperand as ICompileTimeConstant;
                if (compileTimeConstant != null && compileTimeConstant.Value == null)
                {
                    return(this.Rewrite(new CheckIfInstance()
                    {
                        Operand = castIfPossible.ValueToCast,
                        TypeToCheck = castIfPossible.TargetType,
                        Type = greaterThan.Type,
                    }));
                }
            }
            return(base.Rewrite(greaterThan));
        }
 public override IExpression Rewrite(IGreaterThan greaterThan) {
   var castIfPossible = greaterThan.LeftOperand as ICastIfPossible;
   if (castIfPossible != null) {
     var compileTimeConstant = greaterThan.RightOperand as ICompileTimeConstant;
     if (compileTimeConstant != null && compileTimeConstant.Value == null) {
       return this.Rewrite(new CheckIfInstance() {
         Operand = castIfPossible.ValueToCast,
         TypeToCheck = castIfPossible.TargetType,
         Type = greaterThan.Type,
       });
     }
   }
   return base.Rewrite(greaterThan);
 }
Exemple #6
0
 public override IExpression Rewrite(IGreaterThan operation)
 {
     return(ReplaceOperation(operation));
 }
Exemple #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="greaterThan"></param>
 public GreaterThan(IGreaterThan greaterThan)
     : base(greaterThan)
 {
     this.unsignedOrUnordered = greaterThan.IsUnsignedOrUnordered;
 }
Exemple #8
0
 /// <summary>
 /// Performs some computation with the given greater-than expression.
 /// </summary>
 /// <param name="greaterThan"></param>
 public virtual void Visit(IGreaterThan greaterThan)
 {
     this.Visit((IBinaryOperation)greaterThan);
 }
Exemple #9
0
 public void Visit(IGreaterThan greaterThan)
 {
     throw new NotImplementedException();
 }
    public override void TraverseChildren(IGreaterThan greaterThan)
    {
      base.TraverseChildren(greaterThan);
      Bpl.Expr rexp = TranslatedExpressions.Pop();
      Bpl.Expr lexp = TranslatedExpressions.Pop();

      Bpl.Expr e;
      switch (greaterThan.LeftOperand.Type.TypeCode) {
        case PrimitiveTypeCode.Float32:
        case PrimitiveTypeCode.Float64:
          e = new Bpl.NAryExpr(
            greaterThan.Token(),
            new Bpl.FunctionCall(this.sink.Heap.RealGreaterThan),
            new List<Bpl.Expr>(new Bpl.Expr[] {lexp, rexp})
            );
          break;
        default:
          e = Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Gt, lexp, rexp);
          break;
      }

      TranslatedExpressions.Push(e);
    }
Exemple #11
0
 private HLLocation ProcessGreaterThanExpression(IGreaterThan pExpression)
 {
     HLLocation locationLeftOperand = ProcessExpression(pExpression.LeftOperand);
     HLLocation locationRightOperand = ProcessExpression(pExpression.RightOperand);
     HLLocation locationTemporary = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type)));
     mCurrentBlock.EmitCompare(HLCompareType.GreaterThan, locationTemporary, locationLeftOperand, locationRightOperand);
     return pExpression.ResultIsUnmodifiedLeftOperand ? locationLeftOperand : locationTemporary;
 }
 /// <summary>
 /// Rewrites the given greater-than expression.
 /// </summary>
 /// <param name="greaterThan"></param>
 public virtual IExpression Rewrite(IGreaterThan greaterThan)
 {
     return greaterThan;
 }
        public override void TraverseChildren(IGreaterThan greaterThan)
{ MethodEnter(greaterThan);
            base.TraverseChildren(greaterThan);
     MethodExit();   }
Exemple #14
0
 public override void TraverseChildren(IGreaterThan greaterThan)
 {
     base.TraverseChildren(greaterThan);
     ((GreaterThan)greaterThan).Type = this.platformType.SystemBoolean;
 }
Exemple #15
0
 public override void Visit(IGreaterThan greaterThan)
 {
     allElements.Add(new InvokInfo(Traverser, "IGreaterThan", greaterThan));
 }
Exemple #16
0
 /// <summary>
 /// Generates IL for the specified greater than.
 /// </summary>
 /// <param name="greaterThan">The greater than.</param>
 public override void TraverseChildren(IGreaterThan greaterThan)
 {
     this.Traverse(greaterThan.LeftOperand);
       this.Traverse(greaterThan.RightOperand);
       if (greaterThan.IsUnsignedOrUnordered)
     this.generator.Emit(OperationCode.Cgt_Un);
       else
     this.generator.Emit(OperationCode.Cgt);
       this.StackSize--;
 }
 public override void Visit(IGreaterThan greaterThan)
 {
     if(Process(greaterThan)){visitor.Visit(greaterThan);}
     base.Visit(greaterThan);
 }
Exemple #18
0
 /// <summary>
 /// Rewrites the given greater-than expression.
 /// </summary>
 /// <param name="greaterThan"></param>
 public virtual IExpression Rewrite(IGreaterThan greaterThan)
 {
     var mutableGreaterThan = greaterThan as GreaterThan;
       if (mutableGreaterThan == null) return greaterThan;
       this.RewriteChildren(mutableGreaterThan);
       return mutableGreaterThan;
 }
 public virtual void onASTElement(IGreaterThan greaterThan) { }
Exemple #20
0
 /// <summary>
 /// Performs some computation with the given greater-than expression.
 /// </summary>
 /// <param name="greaterThan"></param>
 public virtual void Visit(IGreaterThan greaterThan)
 {
 }
Exemple #21
0
 /// <summary>
 /// Visits the specified greater than.
 /// </summary>
 /// <param name="greaterThan">The greater than.</param>
 public override void Visit(IGreaterThan greaterThan)
 {
     GreaterThan mutableGreaterThan = greaterThan as GreaterThan;
     if (alwaysMakeACopy || mutableGreaterThan == null) mutableGreaterThan = new GreaterThan(greaterThan);
     this.resultExpression = this.myCodeMutator.Visit(mutableGreaterThan);
 }
Exemple #22
0
 /// <summary>
 /// Traverses the children of the greater-than expression.
 /// </summary>
 public virtual void TraverseChildren(IGreaterThan greaterThan)
 {
     Contract.Requires(greaterThan != null);
       this.TraverseChildren((IBinaryOperation)greaterThan);
 }
Exemple #23
0
 public virtual void onASTElement(IGreaterThan greaterThan)
 {
 }
Exemple #24
0
 public void Visit(IGreaterThan greaterThan)
 {
     this.result = this.rewriter.Rewrite(greaterThan);
 }
Exemple #25
0
 //^ ensures this.path.Count == old(this.path.Count);
 /// <summary>
 /// Traverses the given greater-than expression.
 /// </summary>
 /// <param name="greaterThan"></param>
 public virtual void Visit(IGreaterThan greaterThan)
 {
     if (this.stopTraversal) return;
       //^ int oldCount = this.path.Count;
       this.path.Push(greaterThan);
       this.Visit(greaterThan.LeftOperand);
       this.Visit(greaterThan.RightOperand);
       //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not to decrease this.path.Count.
       this.path.Pop();
 }
 public override void TraverseChildren(IGreaterThan greaterThan) {
   base.TraverseChildren(greaterThan);
   ((GreaterThan)greaterThan).Type = this.platformType.SystemBoolean;
 }
Exemple #27
0
 /// <summary>
 /// Traverses the greater-than expression.
 /// </summary>
 public void Traverse(IGreaterThan greaterThan)
 {
     Contract.Requires(greaterThan != null);
       if (this.preorderVisitor != null) this.preorderVisitor.Visit(greaterThan);
       if (this.StopTraversal) return;
       this.TraverseChildren(greaterThan);
       if (this.StopTraversal) return;
       if (this.postorderVisitor != null) this.postorderVisitor.Visit(greaterThan);
 }
Exemple #28
0
    /// <summary>
    /// Returns a deep copy of the given greater-than expression.
    /// </summary>
    /// <param name="greaterThan"></param>
    public GreaterThan Copy(IGreaterThan greaterThan) {
      Contract.Requires(greaterThan != null);
      Contract.Ensures(Contract.Result<GreaterThan>() != null);

      var mutableCopy = this.shallowCopier.Copy(greaterThan);
      this.CopyChildren((BinaryOperation)mutableCopy);
      return mutableCopy;
    }
Exemple #29
0
 public void Visit(IGreaterThan greaterThan)
 {
     this.traverser.Traverse(greaterThan);
 }
Exemple #30
0
    /// <summary>
    /// Returns a shallow copy of the given greater-than expression.
    /// </summary>
    /// <param name="greaterThan"></param>
    public GreaterThan Copy(IGreaterThan greaterThan) {
      Contract.Requires(greaterThan != null);
      Contract.Ensures(Contract.Result<GreaterThan>() != null);

      return new GreaterThan(greaterThan);
    }
Exemple #31
0
 public void Visit(IGreaterThan greaterThan)
 {
     Contract.Requires(greaterThan != null);
       throw new NotImplementedException();
 }
 /// <summary>
 /// Performs some computation with the given greater-than expression.
 /// </summary>
 /// <param name="greaterThan"></param>
 public virtual void Visit(IGreaterThan greaterThan)
 {
 }
 public override void Visit(IGreaterThan greaterThan) {
   base.Visit(greaterThan);
   Bpl.Expr rexp = TranslatedExpressions.Pop();
   Bpl.Expr lexp = TranslatedExpressions.Pop();
   TranslatedExpressions.Push(Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Gt, lexp, rexp));
 }
Exemple #34
0
 /// <summary>
 /// Visits the specified greater than.
 /// </summary>
 /// <param name="greaterThan">The greater than.</param>
 public override void Visit(IGreaterThan greaterThan)
 {
     GreaterThan mutableGreaterThan = new GreaterThan(greaterThan);
     this.resultExpression = this.myCodeCopier.DeepCopy(mutableGreaterThan);
 }
Exemple #35
0
 public override void Visit(IGreaterThan operation)
 {
     ProcessOperation(operation);
 }
Exemple #36
0
 /// <summary>
 /// Returns a deep copy of the given greater-than expression.
 /// </summary>
 /// <param name="greaterThan"></param>
 public GreaterThan Copy(IGreaterThan greaterThan)
 {
     var mutableCopy = this.shallowCopier.Copy(greaterThan);
       this.CopyChildren((BinaryOperation)mutableCopy);
       return mutableCopy;
 }
Exemple #37
0
 public override void Visit(IGreaterThan binary)
 {
     _formattedValue = Format(binary.LeftOperand) + " > " + Format(binary.RightOperand);
 }
Exemple #38
0
 /// <summary>
 /// Returns a shallow copy of the given greater-than expression.
 /// </summary>
 /// <param name="greaterThan"></param>
 public GreaterThan Copy(IGreaterThan greaterThan)
 {
     return new GreaterThan(greaterThan);
 }
    public override void TraverseChildren(IGreaterThan greaterThan) {

      if (greaterThan.IsUnsignedOrUnordered && !TypeHelper.IsPrimitiveInteger(greaterThan.LeftOperand.Type)) {
        this.sourceEmitterOutput.Write("!(");
        this.Traverse(greaterThan.LeftOperand);
        this.sourceEmitterOutput.Write(" <= ");
        this.Traverse(greaterThan.RightOperand);
        this.sourceEmitterOutput.Write(")");
        return;
      }

      var needsParen = LowerPrecedenceThanParentExpression(greaterThan);
      var savedCurrentPrecedence = this.currentPrecedence;
      this.currentPrecedence = this.Precedence(greaterThan);

      if (needsParen) this.sourceEmitterOutput.Write("(");
      if (greaterThan.IsUnsignedOrUnordered && TypeHelper.IsPrimitiveInteger(greaterThan.LeftOperand.Type) && 
        greaterThan.LeftOperand.Type != TypeHelper.UnsignedEquivalent(greaterThan.LeftOperand.Type)) {
        if (needsParen) this.sourceEmitterOutput.Write("(");
        this.PrintTypeReferenceName(TypeHelper.UnsignedEquivalent(greaterThan.LeftOperand.Type));
        if (needsParen) this.sourceEmitterOutput.Write(")");
      }
      this.Traverse(greaterThan.LeftOperand);
      this.sourceEmitterOutput.Write(" > ");
      if (greaterThan.IsUnsignedOrUnordered && TypeHelper.IsPrimitiveInteger(greaterThan.RightOperand.Type) && 
        greaterThan.RightOperand.Type != TypeHelper.UnsignedEquivalent(greaterThan.RightOperand.Type)) {
        if (needsParen) this.sourceEmitterOutput.Write("(");
        this.PrintTypeReferenceName(TypeHelper.UnsignedEquivalent(greaterThan.RightOperand.Type));
        if (needsParen) this.sourceEmitterOutput.Write(")");
      }
      this.Traverse(greaterThan.RightOperand);
      if (needsParen) this.sourceEmitterOutput.Write(")");

      this.currentPrecedence = savedCurrentPrecedence;
    }
Exemple #40
0
 public void Visit(IGreaterThan greaterThan)
 {
     this.result = this.copier.Copy(greaterThan);
 }
Exemple #41
0
 public override void TraverseChildren(IGreaterThan greaterThan)
 {
     MethodEnter(greaterThan);
     base.TraverseChildren(greaterThan);
     MethodExit();
 }
Exemple #42
0
 /// <summary>
 /// Visits the specified greater than.
 /// </summary>
 /// <param name="greaterThan">The greater than.</param>
 public override void Visit(IGreaterThan greaterThan)
 {
     GreaterThan mutableGreaterThan = greaterThan as GreaterThan;
     if (mutableGreaterThan == null) {
       this.resultExpression = greaterThan;
       return;
     }
     this.resultExpression = this.myCodeMutator.Visit(mutableGreaterThan);
 }