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());
}
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<>();
}
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;
}
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;
}
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);
}
Aggregations