Search in sources :

Example 6 with Context

use of de.prob.model.eventb.Context in project prob2 by bendisposto.

the class ComponentExtractor method caseAContextParseUnit.

@Override
public void caseAContextParseUnit(final AContextParseUnit node) {
    String name = node.getName().getText();
    ContextModifier contextM = new ContextModifier(new Context(name), typeEnv);
    if (node.getExtendsNames().size() == 1) {
        String cName = node.getExtendsNames().getFirst().getText();
        Context ctx = getContext(cName);
        contextM = contextM.setExtends(ctx);
    } else if (node.getExtendsNames().size() > 1) {
        throw new IllegalArgumentException("Contexts can only refine one abstract context. Found " + node.getExtendsNames().size() + " extended machines");
    }
    contextM = contextM.addComment(getComment(node.getComments()));
    ContextExtractor cE = new ContextExtractor(contextM, typeEnv);
    node.apply(cE);
    modelM = modelM.addContext(cE.getContext());
}
Also used : Context(de.prob.model.eventb.Context) ContextModifier(de.prob.model.eventb.ContextModifier)

Example 7 with Context

use of de.prob.model.eventb.Context in project prob2 by bendisposto.

the class ContextXmlHandler method beginInternalContextExtraction.

private void beginInternalContextExtraction(final Attributes attributes) {
    String name = attributes.getValue("name");
    inInternalContext = true;
    internalContext = new Context(name);
    axiomCache.put(name, new HashMap<>());
    internalExtends = new ArrayList<>();
    internalAxioms = new ArrayList<>();
    internalInheritedAxioms = new ArrayList<>();
    internalSets = new ArrayList<>();
    internalConstants = new ArrayList<>();
}
Also used : Context(de.prob.model.eventb.Context)

Example 8 with Context

use of de.prob.model.eventb.Context in project prob2 by bendisposto.

the class EventBModelTranslator method extractContextHierarchy.

private List<Context> extractContextHierarchy(final Context context, EventBModel model) {
    List<Context> contexts = new ArrayList<>();
    contexts.add(context);
    for (Context c : context.getExtends()) {
        Context extendedContext = model.getContext(c.getName());
        contexts.add(extendedContext);
        List<Context> contextHierarchy = extractContextHierarchy(extendedContext, model);
        for (Context c2 : contextHierarchy) {
            if (!contexts.contains(c2)) {
                contexts.add(c2);
            }
        }
    }
    return contexts;
}
Also used : Context(de.prob.model.eventb.Context) ArrayList(java.util.ArrayList)

Example 9 with Context

use of de.prob.model.eventb.Context in project prob2 by bendisposto.

the class EventBModelTranslator method extractMachineHierarchy.

public List<EventBMachine> extractMachineHierarchy(final AbstractElement mainComponent, EventBModel model) {
    if (mainComponent instanceof Context) {
        return Collections.emptyList();
    }
    List<EventBMachine> machines = new ArrayList<>();
    if (mainComponent instanceof EventBMachine) {
        EventBMachine machine = (EventBMachine) mainComponent;
        machines.add(machine);
        machines.addAll(extractMachines(machine, model));
    }
    return machines;
}
Also used : Context(de.prob.model.eventb.Context) ArrayList(java.util.ArrayList) EventBMachine(de.prob.model.eventb.EventBMachine)

Example 10 with Context

use of de.prob.model.eventb.Context in project prob2 by bendisposto.

the class EventBMachineTranslator method processContexts.

private ASeesModelClause processContexts() {
    List<Context> sees = machine.getSees();
    List<TIdentifierLiteral> contextNames = new ArrayList<>();
    for (Context context : sees) {
        contextNames.add(new TIdentifierLiteral(context.getName()));
    }
    return new ASeesModelClause(contextNames);
}
Also used : Context(de.prob.model.eventb.Context) ASeesModelClause(de.be4.classicalb.core.parser.node.ASeesModelClause) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Aggregations

Context (de.prob.model.eventb.Context)11 ArrayList (java.util.ArrayList)4 EventBMachine (de.prob.model.eventb.EventBMachine)3 TIdentifierLiteral (de.be4.eventbalg.core.parser.node.TIdentifierLiteral)2 ASeesModelClause (de.be4.classicalb.core.parser.node.ASeesModelClause)1 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)1 ContextModifier (de.prob.model.eventb.ContextModifier)1 EventBConstant (de.prob.model.eventb.EventBConstant)1 EventBVariable (de.prob.model.eventb.EventBVariable)1 MachineModifier (de.prob.model.eventb.MachineModifier)1 Procedure (de.prob.model.eventb.algorithm.Procedure)1 AbstractElement (de.prob.model.representation.AbstractElement)1 Machine (de.prob.model.representation.Machine)1 ModelElementList (de.prob.model.representation.ModelElementList)1