Пример #1
0
  private void processNode(INode i, boolean isModel) throws SaveFailedException {
    String instanceName = normaliseName(i.getName()),
        controlName = normaliseName(i.getControl().getName()),
        param = ParameterUtilities.getParameter((Node) i); /* XXX!! */
    if (param != null) controlName += "_P__" + normaliseName(param);
    if (isModel) write(instanceName + ":" + controlName);
    else write(controlName);

    Iterator<? extends IPort> it = i.getPorts().iterator();
    if (it.hasNext()) {
      write("[" + getPortString(it.next().getLink()));
      while (it.hasNext()) write("," + getPortString(it.next().getLink()));
      write("]");
    }

    Iterator<? extends IChild> in = i.getIChildren().iterator();
    if (in.hasNext()) {
      write(".");
      IChild firstChild = in.next();
      if (in.hasNext()) {
        write("(");
        processChild(firstChild, isModel);
        while (in.hasNext()) {
          write(" | ");
          processChild(in.next(), isModel);
        }
        write(")");
      } else processChild(firstChild, isModel);
    }
  }
Пример #2
0
 public void process(INode node) throws SaveFailedException {
   print(SMLify(node.getControl().getName()));
   processIterable(
       node.getPorts(),
       "[]",
       "[",
       ", ",
       "]",
       new Processor<IPort>() {
         @Override
         public void proc(IPort p) throws SaveFailedException {
           print(p.getName());
           print(" == ");
           print(SMLify(p.getLink().getName()));
         }
       });
   if (node.getNodes().iterator().hasNext() || node.getSites().iterator().hasNext()) {
     printLine(" o");
     scope++;
     process((IParent) node);
     scope--;
   }
 }