public override void Visit(INotEquality notEquality)
 {
     if (Process(notEquality))
     {
         visitor.Visit(notEquality);
     }
     base.Visit(notEquality);
 }
示例#2
0
        private HLLocation ProcessNotEqualityExpression(INotEquality pExpression)
        {
            HLLocation locationLeftOperand  = ProcessExpression(pExpression.LeftOperand);
            HLLocation locationRightOperand = ProcessExpression(pExpression.RightOperand);
            HLLocation locationTemporary    = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type)));

            mCurrentBlock.EmitCompare(HLCompareType.NotEqual, locationTemporary, locationLeftOperand, locationRightOperand);
            return(pExpression.ResultIsUnmodifiedLeftOperand ? locationLeftOperand : locationTemporary);
        }
示例#3
0
        public override IExpression Rewrite(INotEquality notEquality)
        {
            base.Rewrite(notEquality);
            var cc1 = notEquality.LeftOperand as CompileTimeConstant;
            var cc2 = notEquality.RightOperand as CompileTimeConstant;

            if (cc1 != null && cc2 != null)
            {
                if (cc1.Type.TypeCode == PrimitiveTypeCode.Int32 && cc2.Type.TypeCode == PrimitiveTypeCode.Int32)
                {
                    Contract.Assume(cc1.Value is int);
                    Contract.Assume(cc2.Value is int);
                    return(new CompileTimeConstant()
                    {
                        Value = ((int)cc1.Value) != ((int)cc2.Value), Type = notEquality.Type
                    });
                }
            }
            else if (cc2 != null && ExpressionHelper.IsNumericZero(cc2) && notEquality.LeftOperand.Type.TypeCode == PrimitiveTypeCode.Boolean)
            {
                return(notEquality.LeftOperand);
            }
            return(notEquality);
        }
 public override IExpression Rewrite(INotEquality notEquality) {
   base.Rewrite(notEquality);
   var cc1 = notEquality.LeftOperand as CompileTimeConstant;
   var cc2 = notEquality.RightOperand as CompileTimeConstant;
   if (cc1 != null && cc2 != null) {
     if (cc1.Type.TypeCode == PrimitiveTypeCode.Int32 && cc2.Type.TypeCode == PrimitiveTypeCode.Int32) {
       Contract.Assume(cc1.Value is int);
       Contract.Assume(cc2.Value is int);
       return new CompileTimeConstant() { Value = ((int)cc1.Value) != ((int)cc2.Value), Type = notEquality.Type };
     }
   } else if (cc2 != null && ExpressionHelper.IsNumericZero(cc2) && notEquality.LeftOperand.Type.TypeCode == PrimitiveTypeCode.Boolean) {
     return notEquality.LeftOperand;
   }
   return notEquality;
 }
示例#5
0
 public override IExpression Rewrite(INotEquality operation)
 {
     return(ReplaceOperation(operation));
 }
示例#6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="notEquality"></param>
 public NotEquality(INotEquality notEquality)
     : base(notEquality)
 {
 }
示例#7
0
 /// <summary>
 /// Performs some computation with the given not equality expression.
 /// </summary>
 /// <param name="notEquality"></param>
 public virtual void Visit(INotEquality notEquality)
 {
     this.Visit((IBinaryOperation)notEquality);
 }
示例#8
0
 public void Visit(INotEquality notEquality)
 {
     throw new NotImplementedException();
 }
    public override void TraverseChildren(INotEquality nonEqual)
    {

      if ((nonEqual.LeftOperand.Type.TypeCode != PrimitiveTypeCode.NotPrimitive || nonEqual.RightOperand.Type.TypeCode != PrimitiveTypeCode.NotPrimitive)
        &&
        !TypeHelper.TypesAreEquivalent(nonEqual.LeftOperand.Type, nonEqual.RightOperand.Type)
        && (!(IsConstantNull(nonEqual.LeftOperand) || IsConstantNull(nonEqual.RightOperand))) // null is "polymorphic": it can be compared against any reference type.
        ) {
        throw new TranslationException(
          String.Format("Decompiler messed up: inequality's left operand is of type '{0}' but right operand is of type '{1}'.",
          TypeHelper.GetTypeName(nonEqual.LeftOperand.Type),
          TypeHelper.GetTypeName(nonEqual.RightOperand.Type)
          ));
      }

      base.TraverseChildren(nonEqual);
      Bpl.Expr rexp = TranslatedExpressions.Pop();
      Bpl.Expr lexp = TranslatedExpressions.Pop();
      TranslatedExpressions.Push(Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Neq, lexp, rexp));
    }
示例#10
0
 private HLLocation ProcessNotEqualityExpression(INotEquality pExpression)
 {
     HLLocation locationLeftOperand = ProcessExpression(pExpression.LeftOperand);
     HLLocation locationRightOperand = ProcessExpression(pExpression.RightOperand);
     HLLocation locationTemporary = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type)));
     mCurrentBlock.EmitCompare(HLCompareType.NotEqual, locationTemporary, locationLeftOperand, locationRightOperand);
     return pExpression.ResultIsUnmodifiedLeftOperand ? locationLeftOperand : locationTemporary;
 }
 /// <summary>
 /// Rewrites the given not equality expression.
 /// </summary>
 /// <param name="notEquality"></param>
 public virtual IExpression Rewrite(INotEquality notEquality)
 {
     return notEquality;
 }
        public override void TraverseChildren(INotEquality notEquality)
{ MethodEnter(notEquality);
            base.TraverseChildren(notEquality);
     MethodExit();   }
示例#13
0
 public override void TraverseChildren(INotEquality notEquality)
 {
     base.TraverseChildren(notEquality);
     ((NotEquality)notEquality).Type = this.platformType.SystemBoolean;
 }
示例#14
0
 public override void Visit(INotEquality notEquality)
 {
     allElements.Add(new InvokInfo(Traverser, "INotEquality", notEquality));
 }
示例#15
0
 /// <summary>
 /// Generates IL for the specified not equality.
 /// </summary>
 /// <param name="notEquality">The not equality.</param>
 public override void TraverseChildren(INotEquality notEquality)
 {
     this.Traverse(notEquality.LeftOperand);
       this.Traverse(notEquality.RightOperand);
       var compileTimeConstant = notEquality.LeftOperand as ICompileTimeConstant;
       if (compileTimeConstant != null) {
     if (compileTimeConstant.Value == null) {
       this.generator.Emit(OperationCode.Clt_Un);
       this.StackSize--;
       return;
     }
       }
       compileTimeConstant = notEquality.RightOperand as ICompileTimeConstant;
       if (compileTimeConstant != null) {
     if (compileTimeConstant.Value == null) {
       this.generator.Emit(OperationCode.Cgt_Un);
       this.StackSize--;
       return;
     }
       }
       this.generator.Emit(OperationCode.Ceq);
       this.generator.Emit(OperationCode.Ldc_I4_0);
       this.generator.Emit(OperationCode.Ceq);
       this.StackSize--;
 }
 public override void Visit(INotEquality notEquality)
 {
     if(Process(notEquality)){visitor.Visit(notEquality);}
     base.Visit(notEquality);
 }
示例#17
0
 /// <summary>
 /// Rewrites the given not equality expression.
 /// </summary>
 /// <param name="notEquality"></param>
 public virtual IExpression Rewrite(INotEquality notEquality)
 {
     var mutableNotEquality = notEquality as NotEquality;
       if (mutableNotEquality == null) return notEquality;
       this.RewriteChildren(mutableNotEquality);
       return mutableNotEquality;
 }
 public virtual void onASTElement(INotEquality notEquality) { }
示例#19
0
 /// <summary>
 /// Performs some computation with the given not equality expression.
 /// </summary>
 /// <param name="notEquality"></param>
 public virtual void Visit(INotEquality notEquality)
 {
 }
示例#20
0
 /// <summary>
 /// Visits the specified not equality.
 /// </summary>
 /// <param name="notEquality">The not equality.</param>
 public override void Visit(INotEquality notEquality)
 {
     NotEquality mutableNotEquality = notEquality as NotEquality;
     if (alwaysMakeACopy || mutableNotEquality == null) mutableNotEquality = new NotEquality(notEquality);
     this.resultExpression = this.myCodeMutator.Visit(mutableNotEquality);
 }
示例#21
0
 /// <summary>
 /// Traverses the children of the not equality expression.
 /// </summary>
 public virtual void TraverseChildren(INotEquality notEquality)
 {
     Contract.Requires(notEquality != null);
       this.TraverseChildren((IBinaryOperation)notEquality);
 }
示例#22
0
 public virtual void onASTElement(INotEquality notEquality)
 {
 }
示例#23
0
 public void Visit(INotEquality notEquality)
 {
     this.result = this.rewriter.Rewrite((NotEquality)notEquality);
 }
示例#24
0
 //^ ensures this.path.Count == old(this.path.Count);
 /// <summary>
 /// Traverses the given not equality expression.
 /// </summary>
 /// <param name="notEquality"></param>
 public virtual void Visit(INotEquality notEquality)
 {
     if (this.stopTraversal) return;
       //^ int oldCount = this.path.Count;
       this.path.Push(notEquality);
       this.Visit(notEquality.LeftOperand);
       this.Visit(notEquality.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();
 }
示例#25
0
 public override void TraverseChildren(INotEquality notEquality) {
   base.TraverseChildren(notEquality);
   ((NotEquality)notEquality).Type = this.platformType.SystemBoolean;
 }
示例#26
0
 /// <summary>
 /// Traverses the not equality expression.
 /// </summary>
 public void Traverse(INotEquality notEquality)
 {
     Contract.Requires(notEquality != null);
       if (this.preorderVisitor != null) this.preorderVisitor.Visit(notEquality);
       if (this.StopTraversal) return;
       this.TraverseChildren(notEquality);
       if (this.StopTraversal) return;
       if (this.postorderVisitor != null) this.postorderVisitor.Visit(notEquality);
 }
示例#27
0
    /// <summary>
    /// Returns a shallow copy of the given not equality expression.
    /// </summary>
    /// <param name="notEquality"></param>
    public NotEquality Copy(INotEquality notEquality) {
      Contract.Requires(notEquality != null);
      Contract.Ensures(Contract.Result<NotEquality>() != null);

      return new NotEquality(notEquality);
    }
示例#28
0
 public void Visit(INotEquality notEquality)
 {
     this.traverser.Traverse(notEquality);
 }
示例#29
0
    /// <summary>
    /// Returns a deep copy of the given not equality expression.
    /// </summary>
    /// <param name="notEquality"></param>
    public NotEquality Copy(INotEquality notEquality) {
      Contract.Requires(notEquality != null);
      Contract.Ensures(Contract.Result<NotEquality>() != null);

      var mutableCopy = this.shallowCopier.Copy(notEquality);
      this.CopyChildren((BinaryOperation)mutableCopy);
      return mutableCopy;
    }
示例#30
0
 public void Visit(INotEquality notEquality)
 {
     Contract.Requires(notEquality != null);
       throw new NotImplementedException();
 }
 /// <summary>
 /// Performs some computation with the given not equality expression.
 /// </summary>
 /// <param name="notEquality"></param>
 public virtual void Visit(INotEquality notEquality)
 {
 }
示例#32
0
 public override void Visit(INotEquality nonEqual) {
   base.Visit(nonEqual);
   Bpl.Expr rexp = TranslatedExpressions.Pop();
   Bpl.Expr lexp = TranslatedExpressions.Pop();
   TranslatedExpressions.Push(Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Neq, lexp, rexp));
 }
示例#33
0
 /// <summary>
 /// Visits the specified not equality.
 /// </summary>
 /// <param name="notEquality">The not equality.</param>
 public override void Visit(INotEquality notEquality)
 {
     NotEquality mutableNotEquality = new NotEquality(notEquality);
     this.resultExpression = this.myCodeCopier.DeepCopy(mutableNotEquality);
 }
示例#34
0
 public override void Visit(INotEquality operation)
 {
     ProcessOperation(operation);
 }
示例#35
0
 /// <summary>
 /// Returns a deep copy of the given not equality expression.
 /// </summary>
 /// <param name="notEquality"></param>
 public NotEquality Copy(INotEquality notEquality)
 {
     var mutableCopy = this.shallowCopier.Copy(notEquality);
       this.CopyChildren((BinaryOperation)mutableCopy);
       return mutableCopy;
 }
示例#36
0
 public override void Visit(INotEquality binary)
 {
     _formattedValue = Format(binary.LeftOperand) + " != " + Format(binary.RightOperand);
 }
示例#37
0
 /// <summary>
 /// Returns a shallow copy of the given not equality expression.
 /// </summary>
 /// <param name="notEquality"></param>
 public NotEquality Copy(INotEquality notEquality)
 {
     return new NotEquality(notEquality);
 }
    public override void TraverseChildren(INotEquality notEquality) {

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

      if (needsParen) this.sourceEmitterOutput.Write("(");
      this.Traverse(notEquality.LeftOperand);
      this.sourceEmitterOutput.Write(" != ");
      this.Traverse(notEquality.RightOperand);
      if (needsParen) this.sourceEmitterOutput.Write(")");

      this.currentPrecedence = savedCurrentPrecedence;
    }
示例#39
0
 public void Visit(INotEquality notEquality)
 {
     this.result = this.copier.Copy(notEquality);
 }
示例#40
0
 public override void TraverseChildren(INotEquality notEquality)
 {
     MethodEnter(notEquality);
     base.TraverseChildren(notEquality);
     MethodExit();
 }
示例#41
0
 /// <summary>
 /// Visits the specified not equality.
 /// </summary>
 /// <param name="notEquality">The not equality.</param>
 public override void Visit(INotEquality notEquality)
 {
     NotEquality mutableNotEquality = notEquality as NotEquality;
     if (mutableNotEquality == null) {
       this.resultExpression = notEquality;
       return;
     }
     this.resultExpression = this.myCodeMutator.Visit(mutableNotEquality);
 }