Package edu.mit.csail.sdg.alloy4

Examples of edu.mit.csail.sdg.alloy4.Subprocess


       return field;
    }

    /** Parse skolem. */
    private ExprVar parseSkolem(String id) throws IOException, Err {
       final XMLNode node = nmap.get(id);
       if (node==null) throw new IOException("Unknown ID "+id+" encountered.");
       if (!node.is("skolem")) throw new IOException("ID "+id+" is not a skolem.");
       String label = label(node);
       Expr type = null;
       for(XMLNode sub:node) if (sub.is("types")) { Expr t=parseType(sub); if (type==null) type=t; else type=type.plus(t); }
       int arity;
       if (type==null || (arity=type.type().arity())<1) throw new IOException("Skolem "+label+" is maltyped.");
View Full Code Here


           choices.add(s);
           for(Field f:s.getFields()) choices.add(f);
       }
       // find <instance>..</instance>
       if (!xml.is("alloy")) throw new ErrorSyntax("The XML file's root node must be <alloy> or <instance>.");
       XMLNode inst = null;
       for(XMLNode sub: xml) if (sub.is("instance")) { inst=sub; break; }
       if (inst==null) throw new ErrorSyntax("The XML file must contain an <instance> element.");
       // set up the basic values of the A4Solution object
       final int bitwidth = Integer.parseInt(inst.getAttribute("bitwidth"));
       final int maxseq = Integer.parseInt(inst.getAttribute("maxseq"));
       final int max = (1<<(bitwidth-1))-1, min = 0-(1<<(bitwidth-1));
       if (bitwidth>=1 && bitwidth<=30) for(int i=min; i<=max; i++) { atoms.add(Integer.toString(i)); }
       for(XMLNode x:inst) {
           String id=x.getAttribute("ID");
           if (id.length()>0 && (x.is("field") || x.is("skolem") || x.is("sig"))) {
              if (nmap.put(id, x)!=null) throw new IOException("ID "+id+" is repeated.");
              if (x.is("sig")) {
                  boolean isString = STRING.label.equals(label(x)) && yes(x, "builtin");
                  for(XMLNode y:x) if (y.is("atom")) {
                      String attr = y.getAttribute("label");
                      atoms.add(attr);
                      if (isString) strings.add(attr);
                  }
              }
           }
       }
       // create the A4Solution object
       A4Options opt = new A4Options();
       opt.originalFilename = inst.getAttribute("filename");
       sol = new A4Solution(inst.getAttribute("command"), bitwidth, maxseq, strings, atoms, null, opt, 1);
       factory = sol.getFactory();
       // parse all the sigs, fields, and skolems
       for(Map.Entry<String,XMLNode> e:nmap.entrySet()) if (e.getValue().is("sig")) parseSig(e.getKey(), 0);
       for(Map.Entry<String,XMLNode> e:nmap.entrySet()) if (e.getValue().is("field")) parseField(e.getKey());
       for(Map.Entry<String,XMLNode> e:nmap.entrySet()) if (e.getValue().is("skolem")) parseSkolem(e.getKey());
View Full Code Here

        }
    }

    /** Validate the given filename to see if it is a valid Alloy XML instance file. */
    private static void validate(String filename) throws Exception {
        A4SolutionReader.read(new ArrayList<Sig>(), new XMLNode(new File(filename))).toString();
        StaticInstanceReader.parseInstance(new File(filename));
    }
View Full Code Here

        if (element instanceof StartEvent) {

            outgoing = ((StartEvent) element).getOutgoing();
        } else if (element instanceof SubProcess) {
           
            SubProcess subProcess = ((SubProcess) element);
            outgoing = subProcess.getOutgoing();
        } else if (element instanceof Event) {
           
            outgoing = ((Event) element).getOutgoing();
        } else if (element instanceof Activity) {
View Full Code Here

public class EmbeddedSubprocessHandler extends MainElementHandler {

   
    public boolean handle(FlowElement element, PathContextManager manager) {
        SubProcess subProcess = ((SubProcess) element);
       
        // process internal nodes of the sub process
        List<FlowElement> sbElements = subProcess.getFlowElements();
        StartEvent start = null;
        for (FlowElement sbElement : sbElements) {
            if (sbElement instanceof StartEvent) {
                start = (StartEvent) sbElement;
                break;
View Full Code Here

            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
        case Bpmn2Package.SUB_PROCESS: {
            SubProcess subProcess = (SubProcess) theEObject;
            T result = caseSubProcess(subProcess);
            if (result == null)
                result = caseActivity(subProcess);
            if (result == null)
                result = caseFlowElementsContainer(subProcess);
View Full Code Here

      if (flowElement instanceof SequenceFlow) {
        SequenceFlow flow = (SequenceFlow) flowElement;
        flowSourceMap.put(flow.getSourceRef().getId(), flow);
        flowTargetMap.put(flow.getTargetRef().getId(), flow);
      } else if (flowElement instanceof SubProcess) {
        SubProcess subProcess = (SubProcess) flowElement;
        addAllSequenceFlows(subProcess.getFlowElements(), flowSourceMap, flowTargetMap);
      }
    }
  }
View Full Code Here

        } else {
          boundaryEvent.setAttachedToRef(activity);
          activity.getBoundaryEventRefs().add(boundaryEvent);
        }
      } else if (flowElement instanceof SubProcess) {
        SubProcess subProcess = (SubProcess) flowElement;
        postProcessElements(process, subProcess.getFlowElements(), flowSourceMap, flowTargetMap);
      }
    }
  }
View Full Code Here

  private Activity retrieveAttachedRefObject(String attachedToRefId, Collection<FlowElement> flowElementList) {
    for (FlowElement flowElement : flowElementList) {
      if (attachedToRefId.equals(flowElement.getId())) {
        return (Activity) flowElement;
      } else if (flowElement instanceof SubProcess) {
        SubProcess subProcess = (SubProcess) flowElement;
        Activity activity = retrieveAttachedRefObject(attachedToRefId, subProcess.getFlowElements());
        if (activity != null) {
          return activity;
        }
      }
    }
View Full Code Here

  }

  private void loadEventObj(BaseElement baseElement) {
    BaseElementImpl baseElementImpl = (BaseElementImpl) baseElement;
    if (baseElement instanceof SubProcess) {
      SubProcess subProcess = (SubProcess) baseElement;
      List<FlowElement> flowElements = subProcess.getFlowElements();
      for (FlowElement flowElement : flowElements) {
        if (flowElement instanceof Activity) {
          loadEventObj(flowElement);
        }
      }
View Full Code Here

TOP

Related Classes of edu.mit.csail.sdg.alloy4.Subprocess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.