Search in sources :

Example 1 with EventBConstant

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

the class EventBModelTranslator method printPragmas.

private void printPragmas(final IPrologTermOutput pto) {
    for (Machine machine : model.getChildrenOfType(Machine.class)) {
        EventBMachine ebM = (EventBMachine) machine;
        for (EventBVariable var : ebM.getVariables()) {
            if (var.hasUnit()) {
                pto.openTerm("pragma");
                pto.printAtom("unit");
                pto.printAtom(machine.getName());
                pto.printAtom(var.getName());
                pto.openList();
                pto.printAtom(var.getUnit());
                pto.closeList();
                pto.closeTerm();
            }
        }
    }
    for (Context context : model.getChildrenOfType(Context.class)) {
        for (EventBConstant constant : context.getConstants()) {
            if (constant.hasUnit()) {
                pto.openTerm("pragma");
                pto.printAtom("unit");
                pto.printAtom(context.getName());
                pto.printAtom(constant.getName());
                pto.openList();
                pto.printAtom(constant.getUnit());
                pto.closeList();
                pto.closeTerm();
            }
        }
    }
}
Also used : Context(de.prob.model.eventb.Context) EventBVariable(de.prob.model.eventb.EventBVariable) EventBConstant(de.prob.model.eventb.EventBConstant) EventBMachine(de.prob.model.eventb.EventBMachine) EventBMachine(de.prob.model.eventb.EventBMachine) Machine(de.prob.model.representation.Machine)

Example 2 with EventBConstant

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

the class ContextTranslator method processConstants.

private List<PContextClause> processConstants() {
    List<PContextClause> constants = new ArrayList<>();
    List<PExpression> concrete = new ArrayList<>();
    List<PExpression> abstractC = new ArrayList<>();
    for (EventBConstant eventBConstant : context.getConstants()) {
        if (eventBConstant.isAbstract()) {
            abstractC.add((PExpression) ((EventB) eventBConstant.getExpression()).getAst());
        } else {
            concrete.add((PExpression) ((EventB) eventBConstant.getExpression()).getAst());
        }
    }
    constants.add(new AConstantsContextClause(concrete));
    constants.add(new AAbstractConstantsContextClause(abstractC));
    return constants;
}
Also used : AConstantsContextClause(de.be4.classicalb.core.parser.node.AConstantsContextClause) EventB(de.prob.animator.domainobjects.EventB) ArrayList(java.util.ArrayList) EventBConstant(de.prob.model.eventb.EventBConstant) PExpression(de.be4.classicalb.core.parser.node.PExpression) PContextClause(de.be4.classicalb.core.parser.node.PContextClause) AAbstractConstantsContextClause(de.be4.classicalb.core.parser.node.AAbstractConstantsContextClause)

Example 3 with EventBConstant

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

the class ContextXmlHandler method addConstant.

private void addConstant(final Attributes attributes) {
    String name = attributes.getValue("name");
    boolean symbolic = "true".equals(attributes.getValue("de.prob.symbolic.symbolicAttribute"));
    String unit = attributes.getValue("de.prob.units.unitPragmaAttribute");
    if (inInternalContext) {
        internalConstants.add(new EventBConstant(name, symbolic, unit));
    } else {
        constants.add(new EventBConstant(name, symbolic, unit));
    }
}
Also used : EventBConstant(de.prob.model.eventb.EventBConstant)

Example 4 with EventBConstant

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

the class MachineXmlHandler method addConstant.

private void addConstant(final Attributes attributes) {
    String name = attributes.getValue("name");
    boolean symbolic = "true".equals(attributes.getValue("de.prob.symbolic.symbolicAttribute"));
    String unit = attributes.getValue("de.prob.units.unitPragmaAttribute");
    constants.add(new EventBConstant(name, symbolic, unit));
}
Also used : EventBConstant(de.prob.model.eventb.EventBConstant)

Aggregations

EventBConstant (de.prob.model.eventb.EventBConstant)4 AAbstractConstantsContextClause (de.be4.classicalb.core.parser.node.AAbstractConstantsContextClause)1 AConstantsContextClause (de.be4.classicalb.core.parser.node.AConstantsContextClause)1 PContextClause (de.be4.classicalb.core.parser.node.PContextClause)1 PExpression (de.be4.classicalb.core.parser.node.PExpression)1 EventB (de.prob.animator.domainobjects.EventB)1 Context (de.prob.model.eventb.Context)1 EventBMachine (de.prob.model.eventb.EventBMachine)1 EventBVariable (de.prob.model.eventb.EventBVariable)1 Machine (de.prob.model.representation.Machine)1 ArrayList (java.util.ArrayList)1