Commit 3c570824 authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Start implementing fixed point back again with *all* the operators.

Add a test for CVC3 fixed point support, and get fixed point working again.
This implements support for the fixed point marker, and make use of it.

The only problem is that literals by default fall down to Reals, so not all
operations are tested.  This needs to be fixed.

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/branches/TableTool_javization@10709 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 3ff284b4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ package ca.mcmaster.cas.matlab2smt;
 *
 * @author matthew
 */
public class BooleanVariableType implements VariableType {
public class BooleanVariableType extends VariableType {

    @Override
    public boolean equals(Object other) {
+16 −11
Original line number Diff line number Diff line
@@ -14,32 +14,37 @@ import org.apache.commons.lang3.StringUtils;
 */
final public class CVC3Generator implements CheckerGenerator{

    private static String GetSignedFixedPointFunctionFor(MatlabBinaryOperation op) {
    // For operations that don't have specific signed/unsigned representations, use this function.
    private static String GetIndifferentFixedPointFunctionFor(MatlabBinaryOperation op) {
        switch (op) {
            case Addition:
                return "BVPLUS(";
            case Minus:
                return "BVSUB(";
            case Multiplication:
                return "BVMULT(";
        }
        throw new IllegalArgumentException("Operation " + op + " doesn't have a fixed point function!");
    }

    private static String GetSignedFixedPointFunctionFor(MatlabBinaryOperation op) {
        switch (op) {
            case Division:
                return "BVSDIV(";
            case GreaterThen:
                return "BVSGT(";
            case Equals:
                throw new IllegalArgumentException("Operation " + op + " doesn't have a signed fixed point function!");
        }
        throw new RuntimeException("Should never happen!");
        return GetIndifferentFixedPointFunctionFor(op);
    }

    private static String GetUnsignedFixedPointFunctionFor(MatlabBinaryOperation op) {
        switch (op) {
            case Addition:
                return "BVPLUS(";
            case Multiplication:
                return "BVMULT(";
            case Division:
                return "BVUDIV(";
            case GreaterThen:
                return "BVGT(";
            case Equals:
                throw new IllegalArgumentException("Operation " + op + " doesn't have a signed fixed point function!");
        }
        throw new RuntimeException("Should never happen!");
        return GetIndifferentFixedPointFunctionFor(op);
    }

    private static String GetInfixSymbolFor(MatlabBinaryOperation op) {
+7 −2
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ package ca.mcmaster.cas.matlab2smt;
 *
 * @author matthew
 */
final public class FixedPointVariableType implements VariableType {
final public class FixedPointVariableType extends VariableType {

    public FixedPointVariableType(boolean signed, int digits, int fractionPart) {
        m_isSigned = signed;
@@ -62,5 +62,10 @@ final public class FixedPointVariableType implements VariableType {
    private final int m_digits;
    private final boolean m_isSigned;

    public static class Marker implements VariableTypeMarker {}
    public static class Marker implements VariableTypeMarker {
        @Override
        public boolean isMarkerFor(VariableType m_type) {
            return m_type instanceof FixedPointVariableType;
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ package ca.mcmaster.cas.matlab2smt;
 *
 * @author matthew
 */
public final class RealVariableType implements VariableType {
public final class RealVariableType extends VariableType {
    @Override
    public boolean equals(Object other) {
        return other instanceof RealVariableType;
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ public class Variable implements MatlabExpression, MatlabExpressionValue {

    @Override
    public VariableType actualOutputTypeForRequestedOutput(VariableTypeMarker requestedType) {
        if (m_type.equals(requestedType)) {
        if (requestedType.isMarkerFor(m_type)) {
            return m_type;
        }
        return null;
Loading