public static BranchOperator Negate(BranchOperator op) { switch (op) { case BranchOperator.True: return(BranchOperator.False); case BranchOperator.False: return(BranchOperator.True); case BranchOperator.Equality: return(BranchOperator.Inequality); case BranchOperator.Inequality: return(BranchOperator.Equality); case BranchOperator.LessThan: return(BranchOperator.GreaterThanOrEqual); case BranchOperator.LessThanOrEqual: return(BranchOperator.GreaterThan); case BranchOperator.GreaterThan: return(BranchOperator.LessThanOrEqual); case BranchOperator.GreaterThanOrEqual: return(BranchOperator.LessThan); default: throw new ArgumentOutOfRangeException("op"); } }
public static BinaryOperator ToBinaryOperator(this BranchOperator op) { switch (op) { case BranchOperator.Equality: return(BinaryOperator.Equality); case BranchOperator.Inequality: return(BinaryOperator.Inequality); case BranchOperator.GreaterThan: return(BinaryOperator.GreaterThan); case BranchOperator.GreaterThanOrEqual: return(BinaryOperator.GreaterThanOrEqual); case BranchOperator.LessThan: return(BinaryOperator.LessThan); case BranchOperator.LessThanOrEqual: return(BinaryOperator.LessThanOrEqual); default: throw new ArgumentOutOfRangeException("op"); } }
public static Instruction If(BranchOperator op) { switch (op) { case BranchOperator.True: return(new Instruction(InstructionCode.Iftrue)); case BranchOperator.False: return(new Instruction(InstructionCode.Iffalse)); case BranchOperator.Equality: return(new Instruction(InstructionCode.Ifeq)); case BranchOperator.Inequality: return(new Instruction(InstructionCode.Ifne)); case BranchOperator.LessThan: return(new Instruction(InstructionCode.Iflt)); case BranchOperator.LessThanOrEqual: return(new Instruction(InstructionCode.Ifle)); case BranchOperator.GreaterThan: return(new Instruction(InstructionCode.Ifgt)); case BranchOperator.GreaterThanOrEqual: return(new Instruction(InstructionCode.Ifge)); default: throw new ArgumentOutOfRangeException("op"); } }
public static bool IsTrueOrFalse(this BranchOperator op) { switch (op) { case BranchOperator.False: case BranchOperator.True: return(true); } return(false); }
public static bool IsUnary(this BranchOperator op) { switch (op) { case BranchOperator.True: case BranchOperator.False: case BranchOperator.Null: case BranchOperator.NotNull: return(true); } return(false); }
public static bool IsBinary(this BranchOperator op) { switch (op) { case BranchOperator.Equality: case BranchOperator.Inequality: case BranchOperator.GreaterThan: case BranchOperator.GreaterThanOrEqual: case BranchOperator.LessThan: case BranchOperator.LessThanOrEqual: return(true); } return(false); }
private void HandleBranchOperator(int i, BranchOperator branchOperator) { var localVariable = branchOperator.CompareValue as LocalVariable; if (localVariable == null) { return; } var analysis = _pointsOfAnalysis[i]; var variableState = analysis.GetConstVariableState(localVariable); if (variableState == null) { return; } branchOperator.CompareValue = localVariable; }
static void ApplyChange(CilMethodInterpreter interpreter, ConstValue constValue, BranchOperator destAssignment, int i) { var expressionValue = Convert.ToInt32(constValue.Value) != 0; var isTrue = (expressionValue) ^ (destAssignment.Name != OpcodeBranchNames.BrTrue); var operationList = interpreter.MidRepresentation.LocalOperations; if (isTrue) { operationList[i] = new AlwaysBranch { JumpTo = destAssignment.JumpTo }; } else { operationList.RemoveAt(i); } }
public Result BranchCond(APC pc, APC target, BranchOperator bop, Dummy value1, Dummy value2, Data data) { Dummy dest = Dummy.Value; switch (bop) { case BranchOperator.Beq: return(this.visitor.Binary(pc, BinaryOperator.Ceq, dest, value1, value2, data)); case BranchOperator.Bge: return(this.visitor.Binary(pc, BinaryOperator.Cge, dest, value1, value2, data)); case BranchOperator.Bge_Un: return(this.visitor.Binary(pc, BinaryOperator.Cge_Un, dest, value1, value2, data)); case BranchOperator.Bgt: return(this.visitor.Binary(pc, BinaryOperator.Cgt, dest, value1, value2, data)); case BranchOperator.Bgt_Un: return(this.visitor.Binary(pc, BinaryOperator.Cgt_Un, dest, value1, value2, data)); case BranchOperator.Ble: return(this.visitor.Binary(pc, BinaryOperator.Cle, dest, value1, value2, data)); case BranchOperator.Ble_Un: return(this.visitor.Binary(pc, BinaryOperator.Cle_Un, dest, value1, value2, data)); case BranchOperator.Blt: return(this.visitor.Binary(pc, BinaryOperator.Clt, dest, value1, value2, data)); case BranchOperator.Blt_Un: return(this.visitor.Binary(pc, BinaryOperator.Clt_Un, dest, value1, value2, data)); case BranchOperator.Bne_un: return(this.visitor.Binary(pc, BinaryOperator.Cne_Un, dest, value1, value2, data)); default: return(this.visitor.Nop(pc, data)); } }
public bool SupportBranchOperator(BranchOperator op) { return(true); }
public IEnumerable <IInstruction> Branch(BranchOperator op, IType left, IType right) { return(NopArray); }
public Result BranchCond(APC pc, APC target, BranchOperator bop, SymbolicValue value1, SymbolicValue value2, Data data) { throw new Exception("Should not get branches at this level of abstraction."); }
public IEnumerable <IInstruction> Branch(BranchOperator op, IType left, IType right) { if (op.IsUnary()) { if (op == BranchOperator.Null) { var code = new AbcCode(_abc); //NOTE: old code - not working with nullable types //code.PushNull(); //code.Add(InstructionCode.Ifeq); code.IsNull(left, right); code.Add(InstructionCode.Iftrue); return(code); } if (op == BranchOperator.NotNull) { var code = new AbcCode(_abc); //NOTE: old code - not working with nullable types //code.PushNull(); //code.Add(InstructionCode.Ifne); code.IsNull(left, right); code.Add(InstructionCode.Iffalse); return(code); } if (left.IsDecimalOrInt64()) { var code = new AbcCode(_abc); bool isTrue = op == BranchOperator.True; var abcOp = _generator.Operators.BuildBoolOp(left, isTrue); //TODO: Should we enshure not null value onto the stack??? //AbcMethod abcOp = _generator.DefineTruthOperator(left, isTrue); //code.LoadStaticReceiver(abcOp); //code.Swap(); code.Call(abcOp); code.Add(isTrue ? InstructionCode.Iftrue : InstructionCode.Iffalse); return(code); } } else if (InternalTypeExtensions.IsDecimalOrInt64(left, right)) { var code = new AbcCode(_abc); var opm = _generator.Operators.Build(op, left, right); code.Call(opm); code.Add(InstructionCode.Iftrue); return(code); } switch (op) { case BranchOperator.True: return(If(InstructionCode.Iftrue)); case BranchOperator.False: return(If(InstructionCode.Iffalse)); case BranchOperator.Equality: return(If(InstructionCode.Ifeq)); case BranchOperator.Inequality: return(If(InstructionCode.Ifne)); case BranchOperator.LessThan: return(If(InstructionCode.Iflt)); case BranchOperator.LessThanOrEqual: return(If(InstructionCode.Ifle)); case BranchOperator.GreaterThan: return(If(InstructionCode.Ifgt)); case BranchOperator.GreaterThanOrEqual: return(If(InstructionCode.Ifge)); default: throw new NotSupportedException(); } }
public override bool BranchCond(Label pc, Label target, BranchOperator bop, Dummy value1, Dummy value2, Dummy data) { AddTargetLabel(target); return(true); }
public TResult BranchCond(APC pc, APC target, BranchOperator bop, Dummy value1, Dummy value2, TData data) { return(this.visitor.BranchCond(pc, target, bop, Pop(pc, 1), Pop(pc, 0), data)); }
public Unit BranchCond(Label pc, Label target, BranchOperator bop, Source value1, Source value2, TextWriter data) { data.WriteLine("{0}br.{1} {2},{3}", prefix, bop, SourceName(value1), SourceName(value2)); return(Unit.Value); }
public override bool BranchCond(Label pc, Label target, BranchOperator bop, Dummy value1, Dummy value2, BlockWithLabels <Label> currentBlock) { return(HandleConditionalBranch(pc, target, true, currentBlock)); }
virtual public AElement BranchCond(APC pc, APC target, BranchOperator bop, Variable value1, Variable value2, AElement pre) { BreakHere(pc, pre); return(pre); }
// Should not be used in the stack based CFG. public Unit BranchCond(APC pc, APC target, BranchOperator bop, Source value1, Source value2, Unit data) { throw new NotImplementedException(); }
private static void ApplyChange(MethodInterpreter interpreter, ConstValue constValue, BranchOperator destAssignment, int i) { var expressionValue = Convert.ToInt32(constValue.Value) != 0; var isTrue = (expressionValue) ^ (destAssignment.Name != OpcodeBranchNames.BrTrue); var operationList = interpreter.MidRepresentation.LocalOperations; if (isTrue) { operationList[i] = new LocalOperation {
public override ArrayState BranchCond(APC pc, APC target, BranchOperator bop, Variable value1, Variable value2, ArrayState data) { return(data); }
public string BranchCond(Label pc, Label target, BranchOperator bop, Source value1, Source value2, string data) { return(data); }
public static Code Branch(this Code code, BranchOperator op, IType leftType, IType rightType) { code.AddRange(code.Provider.Branch(op, leftType, rightType)); return(code); }
private void FoldEvaluation(BranchOperator operation, bool resultEq) { operation.CompareValue = new ConstValue(resultEq ? 1 : 0); operation.Name = OpcodeBranchNames.BrTrue; Result = true; }
public StackInfo BranchCond(APC pc, APC target, BranchOperator bop, Dummy value1, Dummy value2, StackInfo data) { return(data.Pop(2)); }
public virtual Result BranchCond(Label pc, Label target, BranchOperator bop, Source value1, Source value2, Data data) { return(Default(pc, data)); }
public BoxedExpression BranchCond(APC pc, APC target, BranchOperator bop, Variable value1, Variable value2, BoxedExpression data) { return(data); }
public AbcMethod Build(BranchOperator op, IType left, IType right) { return(Build(op.ToBinaryOperator(), left, right)); }
public Preconditions BranchCond(APC pc, APC target, BranchOperator bop, Variable value1, Variable value2, Preconditions pre) { BreakHere(pc, pre); return(pre); }
public Result BranchCond(Label pc, Label target, BranchOperator bop, Dummy value1, Dummy value2, Data data) { return(this.visitor.BranchCond(ConvertLabel(pc), ConvertLabel(target), bop, value1, value2, data)); }