private HLLocation ProcessLogicalNotExpression(ILogicalNot pExpression) { HLLocation locationOperand = ProcessExpression(pExpression.Operand); HLLocation locationTemporary = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type))); mCurrentBlock.EmitBitwiseXor(locationTemporary, locationOperand, HLBooleanLiteralLocation.Create(true)); return(locationTemporary); }
public override void Visit(ILogicalNot logicalNot) { if (Process(logicalNot)) { visitor.Visit(logicalNot); } base.Visit(logicalNot); }
public override IExpression Rewrite(ILogicalNot logicalNot) { if (logicalNot.Type is Dummy) { return(IfThenElseReplacer.InvertCondition(this.Rewrite(logicalNot.Operand))); } else if (logicalNot.Operand.Type.TypeCode == PrimitiveTypeCode.Int32) { return new Equality() { LeftOperand = this.Rewrite(logicalNot.Operand), RightOperand = new CompileTimeConstant() { Value = 0, Type = this.host.PlatformType.SystemInt32 }, Type = this.host.PlatformType.SystemBoolean, } } ; else { var castIfPossible = logicalNot.Operand as CastIfPossible; if (castIfPossible != null) { var mutableLogicalNot = logicalNot as LogicalNot; if (mutableLogicalNot != null) { var operand = new CheckIfInstance() { Locations = castIfPossible.Locations, Operand = castIfPossible.ValueToCast, Type = this.host.PlatformType.SystemBoolean, TypeToCheck = castIfPossible.TargetType, }; mutableLogicalNot.Operand = operand; return(mutableLogicalNot); } } return(base.Rewrite(logicalNot)); } }
internal static IExpression InvertCondition(IExpression expression) { IBinaryOperation /*?*/ binOp = expression as IBinaryOperation; if (binOp != null) { return(InvertBinaryOperation(binOp)); } ILogicalNot /*?*/ logNot = expression as ILogicalNot; if (logNot != null) { return(logNot.Operand); } LogicalNot logicalNot = new LogicalNot(); logicalNot.Operand = expression; logicalNot.Type = expression.Type; logicalNot.Locations.AddRange(expression.Locations); return(logicalNot); }
public virtual void onASTElement(ILogicalNot logicalNot) { }
public override void Visit(ILogicalNot logicalNot) { base.Visit(logicalNot); Bpl.Expr exp = TranslatedExpressions.Pop(); TranslatedExpressions.Push(Bpl.Expr.Unary( logicalNot.Token(), Bpl.UnaryOperator.Opcode.Not, exp)); }
public override IExpression Rewrite(ILogicalNot logicalNot) { if (logicalNot.Type is Dummy) return IfThenElseReplacer.InvertCondition(this.Rewrite(logicalNot.Operand)); else if (logicalNot.Operand.Type.TypeCode == PrimitiveTypeCode.Int32) return new Equality() { LeftOperand = this.Rewrite(logicalNot.Operand), RightOperand = new CompileTimeConstant() { Value = 0, Type = this.host.PlatformType.SystemInt32 }, Type = this.host.PlatformType.SystemBoolean, }; else { var castIfPossible = logicalNot.Operand as CastIfPossible; if (castIfPossible != null) { var mutableLogicalNot = logicalNot as LogicalNot; if (mutableLogicalNot != null) { var operand = new CheckIfInstance() { Locations = castIfPossible.Locations, Operand = castIfPossible.ValueToCast, Type = this.host.PlatformType.SystemBoolean, TypeToCheck = castIfPossible.TargetType, }; mutableLogicalNot.Operand = operand; return mutableLogicalNot; } } return base.Rewrite(logicalNot); } }
public override void Visit(ILogicalNot logicalNot) { if(Process(logicalNot)){visitor.Visit(logicalNot);} base.Visit(logicalNot); }
public void Visit(ILogicalNot logicalNot) { Contract.Requires(logicalNot != null); throw new NotImplementedException(); }
public override void TraverseChildren(ILogicalNot logicalNot) { base.Traverse(logicalNot.Operand); Bpl.Expr exp = TranslatedExpressions.Pop(); Bpl.Type operandType = this.sink.CciTypeToBoogie(logicalNot.Operand.Type); if (operandType == this.sink.Heap.RefType) { exp = Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Neq, exp, Bpl.Expr.Ident(this.sink.Heap.NullRef)); } else if (operandType == Bpl.Type.Int) { exp = Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Neq, exp, Bpl.Expr.Literal(0)); } else { //System.Diagnostics.Debug.Assert(operandType == Bpl.Type.Bool); } TranslatedExpressions.Push(Bpl.Expr.Unary( logicalNot.Token(), Bpl.UnaryOperator.Opcode.Not, exp)); }
public override void TraverseChildren(ILogicalNot logicalNot) { MethodEnter(logicalNot); base.TraverseChildren(logicalNot); MethodExit(); }
/// <summary> /// Rewrites the given logical not expression. /// </summary> /// <param name="logicalNot"></param> public virtual IExpression Rewrite(ILogicalNot logicalNot) { return logicalNot; }
public void Visit(ILogicalNot logicalNot) { this.result = this.rewriter.Rewrite(logicalNot); }
public override IExpression Rewrite(ILogicalNot logicalNot) { var result = base.Rewrite(logicalNot); return(BooleanExpressionHelper.Normalize(result)); }
public override void Visit(ILogicalNot logicalNot) { allElements.Add(new InvokInfo(Traverser, "ILogicalNot", logicalNot)); }
public override void TraverseChildren(ILogicalNot logicalNot) { base.TraverseChildren(logicalNot); ((LogicalNot)logicalNot).Type = this.platformType.SystemBoolean; }
/// <summary> /// Generates IL for the specified logical not. /// </summary> /// <param name="logicalNot">The logical not.</param> public override void TraverseChildren(ILogicalNot logicalNot) { if (logicalNot.Operand.Type.IsValueType) { //The type should be a primitive integer, a boolean or an enum. this.Traverse(logicalNot.Operand); var opsize = TypeHelper.SizeOfType(logicalNot.Operand.Type); if (opsize == 1 || opsize == 2 || opsize == 4) { this.generator.Emit(OperationCode.Ldc_I4_0); this.StackSize++; this.generator.Emit(OperationCode.Ceq); this.StackSize--; } else if (opsize == 8) { this.generator.Emit(OperationCode.Ldc_I4_0); this.StackSize++; this.generator.Emit(OperationCode.Conv_I8); this.generator.Emit(OperationCode.Ceq); this.StackSize--; } else { Contract.Assert(opsize == 0); //If not, the CodeModel is invalid. //the type is an unresolved reference, typically an enum, so we just don't know what size it is (at compile time, that is). var trueCase = new ILGeneratorLabel(); var done = new ILGeneratorLabel(); this.generator.Emit(OperationCode.Brtrue_S, trueCase); this.generator.Emit(OperationCode.Ldc_I4_0); this.generator.Emit(OperationCode.Br_S, done); this.generator.MarkLabel(trueCase); this.generator.Emit(OperationCode.Ldc_I4_1); this.generator.MarkLabel(done); } } else { //pointer non null test this.Traverse(logicalNot.Operand); this.generator.Emit(OperationCode.Ldnull); this.StackSize++; this.generator.Emit(OperationCode.Ceq); this.StackSize--; } }
public override void TraverseChildren(ILogicalNot logicalNot) { this.sourceEmitterOutput.Write("Not "); this.Traverse(logicalNot.Operand); }
/// <summary> /// Rewrites the given logical not expression. /// </summary> /// <param name="logicalNot"></param> public virtual IExpression Rewrite(ILogicalNot logicalNot) { var mutableLogicalNot = logicalNot as LogicalNot; if (mutableLogicalNot == null) return logicalNot; this.RewriteChildren(mutableLogicalNot); return mutableLogicalNot; }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given logical not expression. /// </summary> /// <param name="logicalNot"></param> public virtual void Visit(ILogicalNot logicalNot) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(logicalNot); this.Visit(logicalNot.Operand); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not to decrease this.path.Count.hod or operation is not implemented."); this.path.Pop(); }
public void Visit(ILogicalNot logicalNot) { this.result = this.copier.Copy(logicalNot); }
/// <summary> /// Traverses the logical not expression. /// </summary> public void Traverse(ILogicalNot logicalNot) { Contract.Requires(logicalNot != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(logicalNot); if (this.StopTraversal) return; this.TraverseChildren(logicalNot); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(logicalNot); }
public void Visit(ILogicalNot logicalNot) { this.traverser.Traverse(logicalNot); }
private HLLocation ProcessLogicalNotExpression(ILogicalNot pExpression) { HLLocation locationOperand = ProcessExpression(pExpression.Operand); HLLocation locationTemporary = HLTemporaryLocation.Create(CreateTemporary(HLDomain.GetOrCreateType(pExpression.Type))); mCurrentBlock.EmitBitwiseXor(locationTemporary, locationOperand, HLBooleanLiteralLocation.Create(true)); return locationTemporary; }
/// <summary> /// Performs some computation with the given logical not expression. /// </summary> /// <param name="logicalNot"></param> public virtual void Visit(ILogicalNot logicalNot) { }
/// <summary> /// Returns a shallow copy of the given logical not expression. /// </summary> /// <param name="logicalNot"></param> public LogicalNot Copy(ILogicalNot logicalNot) { Contract.Requires(logicalNot != null); Contract.Ensures(Contract.Result<LogicalNot>() != null); return new LogicalNot(logicalNot); }
/// <summary> /// Traverses the children of the logical not expression. /// </summary> public virtual void TraverseChildren(ILogicalNot logicalNot) { Contract.Requires(logicalNot != null); this.TraverseChildren((IUnaryOperation)logicalNot); }
/// <summary> /// Returns a deep copy of the given logical not expression. /// </summary> /// <param name="logicalNot"></param> public LogicalNot Copy(ILogicalNot logicalNot) { Contract.Requires(logicalNot != null); Contract.Ensures(Contract.Result<LogicalNot>() != null); var mutableCopy = this.shallowCopier.Copy(logicalNot); this.CopyChildren((UnaryOperation)mutableCopy); return mutableCopy; }
/// <summary> /// Performs some computation with the given logical not expression. /// </summary> /// <param name="logicalNot"></param> public virtual void Visit(ILogicalNot logicalNot) { this.Visit((IUnaryOperation)logicalNot); }
public void Visit(ILogicalNot logicalNot) { throw new NotImplementedException(); }
/// <summary> /// Visits the specified logical not. /// </summary> /// <param name="logicalNot">The logical not.</param> public override void Visit(ILogicalNot logicalNot) { LogicalNot mutableLogicalNot = new LogicalNot(logicalNot); this.resultExpression = this.myCodeCopier.DeepCopy(mutableLogicalNot); }
/// <summary> /// /// </summary> /// <param name="logicalNot"></param> public LogicalNot(ILogicalNot logicalNot) : base(logicalNot) { }
/// <summary> /// Returns a deep copy of the given logical not expression. /// </summary> /// <param name="logicalNot"></param> public LogicalNot Copy(ILogicalNot logicalNot) { var mutableCopy = this.shallowCopier.Copy(logicalNot); this.CopyChildren((UnaryOperation)mutableCopy); return mutableCopy; }
public override void TraverseChildren(ILogicalNot logicalNot) { var needsParen = LowerPrecedenceThanParentExpression(logicalNot); var savedCurrentPrecedence = this.currentPrecedence; this.currentPrecedence = this.Precedence(logicalNot); if (needsParen) this.sourceEmitterOutput.Write("("); this.sourceEmitterOutput.Write("!"); this.Traverse(logicalNot.Operand); if (needsParen) this.sourceEmitterOutput.Write(")"); this.currentPrecedence = savedCurrentPrecedence; }
/// <summary> /// Returns a shallow copy of the given logical not expression. /// </summary> /// <param name="logicalNot"></param> public LogicalNot Copy(ILogicalNot logicalNot) { return new LogicalNot(logicalNot); }
/// <summary> /// Visits the specified logical not. /// </summary> /// <param name="logicalNot">The logical not.</param> public override void Visit(ILogicalNot logicalNot) { LogicalNot mutableLogicalNot = logicalNot as LogicalNot; if (alwaysMakeACopy || mutableLogicalNot == null) mutableLogicalNot = new LogicalNot(logicalNot); this.resultExpression = this.myCodeMutator.Visit(mutableLogicalNot); }