Commit 1f9c1f96 authored by Yanjun Jiang's avatar Yanjun Jiang Committed by Matthew Dawson
Browse files

Split out VariableDeclarationGenerator from ExpressionGenerator.

This refactor reduces the coupling between variable declaration and expression
generation.  Instead, each generation system can choose how to deal with these
problems separately.
parent d6cf2f29
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ import org.apache.commons.lang3.StringUtils;
 *
 * @author matthew
 */
final public class CVC3Generator implements ExpressionGenerator {
final public class CVC3Generator implements VariablesDeclarationGenerator, ExpressionGenerator {

    // For operations that don't have specific signed/unsigned representations, use this function.
    private static String GetIndifferentFixedPointFunctionFor(BinaryOperation op) {
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ import java.util.Map;
 *
 * @author Yanjun Jiang <jiangy76@mcmaster.ca>
 */
final public class EventBGenerator implements ExpressionGenerator {
final public class EventBGenerator implements VariablesDeclarationGenerator, ExpressionGenerator {

    private static String GetInfixSymbolFor(BinaryOperation op) {
        switch (op) {
+0 −1
Original line number Diff line number Diff line
@@ -36,5 +36,4 @@ public interface ExpressionGenerator {
    public String GenerateUnaryOperation(UnaryOperation op, String expression, VariableType usedType);
    public String GenerateBinaryOperation(BinaryOperation op, String lhsExp, String rhsExp, VariableType usedType);
    public String GenerateLiteralValue(String value, VariableType requestedType);
    public String GenerateVariablesDeclaration(VariableCollection vars);
}
+0 −10
Original line number Diff line number Diff line
@@ -77,16 +77,6 @@ public class ExpressionGeneratorSpy implements ExpressionGenerator {
        return expressionGenerator.GenerateLiteralValue(value, requestedType);
    }

    /**
     * {@inheritDoc}
     * <p>
     * This currently remains unrecorded.
     */
    @Override
    public String GenerateVariablesDeclaration(VariableCollection vars) {
        return expressionGenerator.GenerateVariablesDeclaration(vars);
    }

    /**
     * Returns an unmodifiable list of all unary operations that have occurred so far.
     * @return All unary operations seen
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import java.util.Map;
/**
 * @author Matthew Dawson <matthew@mjdsystems.ca>
 */
public class SALGenerator implements ExpressionGenerator {
public class SALGenerator implements VariablesDeclarationGenerator, ExpressionGenerator {

    private static String GetInfixSymbolFor(BinaryOperation op) {
        switch (op) {
Loading