package de.dhbwstuttgart.strucTypes5.algo;



import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMakerGlobal;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMakerLocal;
import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMap;
import de.dhbwstuttgart.strucTypes5.constraints.ConstraintAbstract;
import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarStore;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.Method;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by sebastian on 20.04.17.
 */
public class Type {

    List<ConstraintAbstract> constraintList = new ArrayList<>();

    // Start Type Algorithm, need Assumption and class , and Typeinformations
    public Type(AssumptionMap assumptions, ClassOrInterface cl , TypeVarStore typeVarStore) {

        // Erstellen der Globalen Assumptions
        AssumptionMakerGlobal assumptionMakerGlobal = new AssumptionMakerGlobal(cl,typeVarStore);
        assumptions.addAll(assumptionMakerGlobal.getAssumptionAbstractList());

        // TypeExpression für jede Methode ausführen
        for (Method m : cl.getMethods()) {
            // Erstelle Lokale Assumptions
            AssumptionMakerLocal assumptionMakerLocal = new AssumptionMakerLocal(m, typeVarStore);
            assumptions.addAll(assumptionMakerLocal.getResultAssumptionList());
            TypeExpr typeExpr = new TypeExpr(assumptions  , m, typeVarStore);
            constraintList.addAll(typeExpr.getResultConstraints());
        }
    }
}
