Commit 4761cd4b authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Rename all expression pieces to not mention Matlab explicitly.

Since all expressions are in fact general pupose expression, and not tied
to Matlab in the slightest, avoid calling the classes as Matlab*.  No actual
functional change is required for this.

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/branches/TableTool_javization@10848 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent a2356756
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ import java.util.Collection;
 *
 * @author matthew
 */
public enum MatlabBinaryOperation {
public enum BinaryOperation {

    Addition,
    Minus,
@@ -27,7 +27,7 @@ public enum MatlabBinaryOperation {
    BooleanAnd,
    BooleanOr;

    public static MatlabBinaryOperation getOpForSymbol(String text) {
    public static BinaryOperation getOpForSymbol(String text) {
        if (text.equals("+")) {
            return Addition;
        } else if (text.equals("-")) {
+13 −13
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ import org.apache.commons.lang3.StringUtils;
final public class CVC3Generator implements CheckerGenerator{

    // For operations that don't have specific signed/unsigned representations, use this function.
    private static String GetIndifferentFixedPointFunctionFor(MatlabBinaryOperation op) {
    private static String GetIndifferentFixedPointFunctionFor(BinaryOperation op) {
        switch (op) {
            case Addition:
                return "BVPLUS(";
@@ -29,7 +29,7 @@ final public class CVC3Generator implements CheckerGenerator{
        throw new IllegalArgumentException("Operation " + op + " doesn't have a fixed point function!");
    }

    private static String GetSignedFixedPointFunctionFor(MatlabBinaryOperation op) {
    private static String GetSignedFixedPointFunctionFor(BinaryOperation op) {
        switch (op) {
            case Division:
                return "BVSDIV(";
@@ -45,7 +45,7 @@ final public class CVC3Generator implements CheckerGenerator{
        return GetIndifferentFixedPointFunctionFor(op);
    }

    private static String GetUnsignedFixedPointFunctionFor(MatlabBinaryOperation op) {
    private static String GetUnsignedFixedPointFunctionFor(BinaryOperation op) {
        switch (op) {
            case Division:
                return "BVUDIV(";
@@ -61,7 +61,7 @@ final public class CVC3Generator implements CheckerGenerator{
        return GetIndifferentFixedPointFunctionFor(op);
    }

    private static String GetInfixSymbolFor(MatlabBinaryOperation op) {
    private static String GetInfixSymbolFor(BinaryOperation op) {
        switch (op) {
            case Addition:
                return "+";
@@ -89,14 +89,14 @@ final public class CVC3Generator implements CheckerGenerator{
        throw new RuntimeException("Should never happen!");
    }

    protected static String ConvertToOutputOp(MatlabBinaryOperation op, VariableType type) {
    protected static String ConvertToOutputOp(BinaryOperation op, VariableType type) {
        switch (OpTypeForVariableType(op, type)) {
            case Function:
                String func = GetSignedFixedPointFunctionFor(op);
                if (!((FixedPointVariableType) type).isSigned()) {
                    func = GetUnsignedFixedPointFunctionFor(op);
                }
                if (op == MatlabBinaryOperation.Addition || op == MatlabBinaryOperation.Multiplication) {
                if (op == BinaryOperation.Addition || op == BinaryOperation.Multiplication) {
                    FixedPointVariableType typeF = (FixedPointVariableType) type;
                    return func + typeF.digits() + ",";
                } else {
@@ -109,8 +109,8 @@ final public class CVC3Generator implements CheckerGenerator{
        }
    }

    private static OperationType OpTypeForVariableType(MatlabBinaryOperation op, VariableType type) {
        if (type instanceof FixedPointVariableType && op != MatlabBinaryOperation.Equals) {
    private static OperationType OpTypeForVariableType(BinaryOperation op, VariableType type) {
        if (type instanceof FixedPointVariableType && op != BinaryOperation.Equals) {
            return OperationType.Function;
        } else {
            return OperationType.CenterOp;
@@ -118,7 +118,7 @@ final public class CVC3Generator implements CheckerGenerator{
    }

    @Override
    public String GenerateBinaryOperation(MatlabBinaryOperation op, String lhsExp, String rhsExp, VariableType usedType) {
    public String GenerateBinaryOperation(BinaryOperation op, String lhsExp, String rhsExp, VariableType usedType) {
        switch (CVC3Generator.OpTypeForVariableType(op, usedType)) {
            case CenterOp:
                return "(" + lhsExp + " " + CVC3Generator.ConvertToOutputOp(op, usedType) + " " + rhsExp + ")";
@@ -129,7 +129,7 @@ final public class CVC3Generator implements CheckerGenerator{
        }
    }

    private static String GetUnaryOperationSymbolFor(MatlabUnaryOperation op) {
    private static String GetUnaryOperationSymbolFor(UnaryOperation op) {
        switch (op) {
            case Negation:
                return "NOT";
@@ -140,7 +140,7 @@ final public class CVC3Generator implements CheckerGenerator{
    }

    @Override
    public String GenerateUnaryOperation(MatlabUnaryOperation op, String expression, VariableType usedType) {
    public String GenerateUnaryOperation(UnaryOperation op, String expression, VariableType usedType) {
        switch (CVC3Generator.OpTypeForVariableType(op, usedType)) {
            case PrefixOp:
                return "(" + CVC3Generator.ConvertToOutputOp(op, usedType) + " " + expression + ")";
@@ -151,14 +151,14 @@ final public class CVC3Generator implements CheckerGenerator{
        }
    }

    private static OperationType OpTypeForVariableType(MatlabUnaryOperation op, VariableType usedType) {
    private static OperationType OpTypeForVariableType(UnaryOperation op, VariableType usedType) {
        if (usedType instanceof FixedPointVariableType) {
            return OperationType.Function;
        }
        return OperationType.PrefixOp;
    }

    private static String ConvertToOutputOp(MatlabUnaryOperation op, VariableType usedType) {
    private static String ConvertToOutputOp(UnaryOperation op, VariableType usedType) {
        switch (op) {
            case Negation:
                return "NOT";
+2 −2
Original line number Diff line number Diff line
@@ -11,8 +11,8 @@ import java.util.Map;
 * @author matthew
 */
public interface CheckerGenerator {
    public String GenerateUnaryOperation(MatlabUnaryOperation op, String expression, VariableType usedType);
    public String GenerateBinaryOperation(MatlabBinaryOperation op, String lhsExp, String rhsExp, VariableType usedType);
    public String GenerateUnaryOperation(UnaryOperation op, String expression, VariableType usedType);
    public String GenerateBinaryOperation(BinaryOperation op, String lhsExp, String rhsExp, VariableType usedType);
    public String GenerateLiterlaValue(String value, VariableType requestedType);
    public String GenerateVariablesDeclaration(Map<String, Variable> vars);
}
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ package ca.mcmaster.cas.tabularexpressiontoolbox.expression;
 *
 * @author matthew
 */
public interface MatlabExpression {
public interface Expression {

    /* This methods returns an actual variable type for the requested input type.  If due to the setup of the system,
    *  this is not possible, then this function should return null.
+8 −8
Original line number Diff line number Diff line
@@ -10,19 +10,19 @@ import java.util.Collection;
 *
 * @author matthew
 */
public final class MatlabExpressionBinaryOperation implements MatlabExpression, MatlabExpressionWithSubExpression {
public final class ExpressionBinaryOperation implements Expression, ExpressionWithSubExpression {

    public MatlabExpressionBinaryOperation(MatlabExpression lhs, MatlabBinaryOperation op, MatlabExpression rhs) {
    public ExpressionBinaryOperation(Expression lhs, BinaryOperation op, Expression rhs) {
        m_lhs = lhs;
        m_rhs = rhs;
        m_op = op;
    }

    public void setLHS(MatlabExpression expr) {
    public void setLHS(Expression expr) {
        m_lhs = expr;
    }

    public void setRHS(MatlabExpression expr) {
    public void setRHS(Expression expr) {
        m_rhs = expr;
    }

@@ -66,12 +66,12 @@ public final class MatlabExpressionBinaryOperation implements MatlabExpression,
    }

    @Override
    public MatlabExpression getSubExpression() {
    public Expression getSubExpression() {
        return m_rhs;
    }

    @Override
    public void setSubExpression(MatlabExpression subExpression) {
    public void setSubExpression(Expression subExpression) {
        m_rhs = subExpression;
    }

@@ -80,6 +80,6 @@ public final class MatlabExpressionBinaryOperation implements MatlabExpression,
        return "(" + m_lhs.toString() + " " + m_op.toString() + " " + m_rhs.toString() + ")";
    }

    private MatlabExpression m_lhs, m_rhs;
    private MatlabBinaryOperation m_op;
    private Expression m_lhs, m_rhs;
    private BinaryOperation m_op;
}
Loading