Commit 96088005 authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Initial refactoring for generic generator.

Start with basic changes for generator.  First step, try moving the operation
generation piece to a new class.  For now, just use static methods.

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/branches/TableTool_javization@10327 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 6ed48eef
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.mcmaster.cas.matlab2smt;

/**
 *
 * @author matthew
 */
public class CVC3Generator {

    public static String GenerateOperation(MatlabOperation op, String lhsExp, String rhsExp, VariableType usedType) {
        switch (op.CVC3OpTypeForType(usedType)) {
            case CenterOp:
                return "(" + lhsExp + " " + op.convertToCVC3Op(usedType) + " " + rhsExp + ")";
            case Function:
                return op.convertToCVC3Op(usedType) + lhsExp + "," + rhsExp + ")";
            default:
                throw new IllegalStateException("Cannot output expression operation for requested operation type.");
        }
    }
}
+5 −8
Original line number Diff line number Diff line
@@ -43,14 +43,11 @@ final class MatlabExpressionOperation implements MatlabExpression, MatlabExpress
    public String getCVC3Output(VariableType requestedType) {
        VariableType usedType = type();
        assert usedType.equals(requestedType);
        switch (m_op.CVC3OpTypeForType(usedType)) {
            case CenterOp:
                return "(" + m_lhs.getCVC3Output(usedType) + " " + m_op.convertToCVC3Op(usedType) + " " + m_rhs.getCVC3Output(usedType) + ")";
            case Function:
                return m_op.convertToCVC3Op(usedType) + m_lhs.getCVC3Output(usedType) + "," + m_rhs.getCVC3Output(usedType) + ")";
            default:
                throw new IllegalStateException("Cannot output expression operation for requested operation type.");
        }

        String lhsExp = m_lhs.getCVC3Output(usedType);
        String rhsExp = m_rhs.getCVC3Output(usedType);

        return CVC3Generator.GenerateOperation(m_op, lhsExp, rhsExp, usedType);
    }

    @Override