public override WExpr InterpretModel(Context context, Model model, ProgramBuilder builder) { WEVar lhsConc = (WEVar)lhs.InterpretModel(context, model, builder); WEOperand assignConc = (WEOperand)assign.InterpretModel(context, model, builder); WExpr rv = new WEArith(lhsConc, assignConc, WEArith.ArithOp.plus, 0); builder.CheckExpr(rv); return(rv); }
public override WExpr InterpretModel(Context context, Model model, ProgramBuilder builder) { WEVar argConc = (WEVar)arg.InterpretModel(context, model, builder); WEArith.ArithOp op = (WEArith.ArithOp)GetConcChoice(context, model); WExpr rv = new WEArith(argConc, argConc, op, builder.NewConst(1)); builder.CheckExpr(rv); return(rv); }
public override WExpr InterpretModel(Context context, Model model, ProgramBuilder builder) { WEVar lhsConc = (WEVar)lhs.InterpretModel(context, model, builder); WEArith.ArithOp op = (WEArith.ArithOp)(GetConcChoice(context, model) + 2); WEOperand arg1Conc = (WEOperand)arg1.InterpretModel(context, model, builder); WEOperand arg2Conc = (WEOperand)arg2.InterpretModel(context, model, builder); WExpr rv = new WEArith(lhsConc, arg1Conc, op, arg2Conc); builder.CheckExpr(rv); return(rv); }
public override bool KeepProgram(WExpr expr) { #region filter out: x_i = x_i if (expr is WEArith) { WEArith e = (WEArith)expr; if (e.op == WEArith.ArithOp.plus || e.op == WEArith.ArithOp.minus) { if (e.arg1 is WEVar && e.arg2 is WEConst) { if (e.lhs.id == ((WEVar)e.arg1).id && ((WEConst)e.arg2).value == 0) { return(false); } } if (e.arg2 is WEVar && e.arg1 is WEConst) { if (e.lhs.id == ((WEVar)e.arg2).id && ((WEConst)e.arg1).value == 0) { return(false); } } } } #endregion #region filter out: x = x_i - x_i if (expr is WEArith) { WEArith e = (WEArith)expr; if (e.op == WEArith.ArithOp.minus) { if (e.arg1 is WEVar && e.arg2 is WEVar) { if (((WEVar)e.arg1).id == ((WEVar)e.arg2).id) { return(false); } } } } #endregion #region filter out: unsatisfiable and tautological comparisons if (expr is WCComparison) { WCComparison e = (WCComparison)expr; if (e.arg2 is WEVar) { if (e.arg1.id == ((WEVar)e.arg2).id) { return(false); } } else { if (e.arg2.IsZero() && e.op == WCComparison.CompareType.l) { return(false); } } } #endregion #region filter out: if statements where the <then> and <else> parts are the same if (expr is WEIf) { WEIf e = (WEIf)expr; if (e.elseBody != null) { if (e.thenBody.ToString() == e.elseBody.ToString()) { return(false); } } } #endregion #region filter out: compound conditions of the form C_i op C_i if (expr is WCCompound) { WCCompound e = (WCCompound)expr; if (e.cond1.ToString() == e.cond2.ToString()) { return(false); } } #endregion return(true); }