@Override public void setIntValue(FeatureExpr ctx, int pos, Conditional<Integer> newValue) { if (Conditional.isTautology(ctx)) { values[pos] = newValue; } else { values[pos] = ChoiceFactory.create(ctx, newValue, values[pos]).simplify(); } }
@Override public void setReferenceValue(FeatureExpr ctx, int index, Conditional<Integer> newValue) { if (Conditional.isTautology(ctx)) { values[index] = newValue; } else { values[index] = ChoiceFactory.create(ctx, newValue, values[index]).simplify(); } }
@Parameters(name = "{0} : {1}") public static List<Object[]> configurations() { List<Object[]> params = new LinkedList<>(); for (Object[] choice : ChoiceFactory.asParameter()) { params.add(new Object[] {choice[0], FeatureExprFactory.bdd()}); params.add(new Object[] {choice[0], FeatureExprFactory.sat()}); } return params; }
/* (non-Javadoc) * @see gov.nasa.jpf.vm.IStackHandler#storeOperand(de.fosd.typechef.featureexpr.FeatureExpr, int) */ @Override public void storeOperand(final FeatureExpr ctx, final int index) { if (Conditional.isTautology(ctx)) { locals[index] = popEntry(ctx, true); } else { if (locals[index] == null) { locals[index] = new One<>(new Entry(MJIEnv.NULL, false)); } locals[index] = ChoiceFactory.create(ctx, popEntry(ctx, true), locals[index]).simplify(); } }
public ConditionalTest(Factory factory, AbstractFeatureExprFactory fexprFeactory) { ChoiceFactory.setDefault(factory); FeatureExprFactory.setDefault(fexprFeactory); fa = FeatureExprFactory.createDefinedExternal("A"); fb = FeatureExprFactory.createDefinedExternal("B"); fc = FeatureExprFactory.createDefinedExternal("C"); fd = FeatureExprFactory.createDefinedExternal("D"); fe = FeatureExprFactory.createDefinedExternal("E"); ff = FeatureExprFactory.createDefinedExternal("F"); fg = FeatureExprFactory.createDefinedExternal("G"); }
/* (non-Javadoc) * @see gov.nasa.jpf.vm.IStackHandler#setLocal(de.fosd.typechef.featureexpr.FeatureExpr, int, int, boolean) */ @Override public void setLocal( final FeatureExpr ctx, final int index, final int value, final boolean isRef) { if (Conditional.isTautology(ctx)) { locals[index] = new One<>(new Entry(value, isRef)); } else { if (locals[index] == null) { locals[index] = new One<>(new Entry(0, false)); } locals[index] = ChoiceFactory.create(ctx, new One<>(new Entry(value, isRef)), locals[index]).simplify(); } }
/* (non-Javadoc) * @see gov.nasa.jpf.vm.IStackHandler#storeLongOperand(de.fosd.typechef.featureexpr.FeatureExpr, int) */ @Override public void storeLongOperand(final FeatureExpr ctx, final int index) { /* stack.mapf(ctx, new VoidBiFunction<FeatureExpr, Stack>() { @Override public void apply(final FeatureExpr f, final Stack stack) { if (Conditional.isContradiction(f)) { return; } locals[index + 1] = ChoiceFactory.create(f, popEntry(f, false), locals[index + 1]); locals[index] = ChoiceFactory.create(f, popEntry(f, false), locals[index]); } }); locals[index] = locals[index].simplify(); locals[index + 1] = locals[index + 1].simplify(); stack = stack.simplify(); */ locals[index + 1] = ChoiceFactory.create(ctx, popEntry(ctx, false), locals[index + 1]); locals[index] = ChoiceFactory.create(ctx, popEntry(ctx, false), locals[index]); locals[index] = locals[index].simplify(); locals[index + 1] = locals[index + 1].simplify(); }
@Override public void setFloatValue(FeatureExpr ctx, int index, Conditional<Float> newValue) { if (Conditional.isTautology(ctx)) { values[index] = new One<>(Types.floatToInt(newValue.getValue())); } else { values[index] = ChoiceFactory.create( ctx, newValue.map( new Function<Float, Integer>() { @Override public Integer apply(Float v) { return Types.floatToInt(v); } }), values[index]) .simplify(); } }
@Override public void setByteValue(FeatureExpr ctx, int index, Conditional<Byte> newValue) { if (Conditional.isTautology(ctx)) { values[index] = new One<>((int) newValue.getValue()); } else { values[index] = ChoiceFactory.create( ctx, newValue.map( new Function<Byte, Integer>() { @Override public Integer apply(Byte x) { return (int) x; } }), values[index]) .simplify(); } }
@Override public void setBooleanValue(FeatureExpr ctx, int index, Conditional<Boolean> newValue) { if (Conditional.isTautology(ctx)) { values[index] = new One<>(newValue.getValue() ? 1 : 0); } else { values[index] = ChoiceFactory.create( ctx, newValue.map( new Function<Boolean, Integer>() { @Override public Integer apply(Boolean v) { return v ? 1 : 0; } }), values[index]) .simplify(); } }
private static Conditional<Integer> Choice( FeatureExpr f, Conditional<Integer> first, Conditional<Integer> second) { return ChoiceFactory.create(f, first, second); }
@Override public void setCharValue(FeatureExpr ctx, int index, Conditional<Character> newValue) { values[index] = ChoiceFactory.create(ctx, newValue.map(SetCharValue), values[index]).simplify(); }