Ejemplo n.º 1
0
  @Override
  public Stream caseActorInstance(ActorInstance actor) {
    List<PortInstance> inputPorts = actor.getInputs();
    List<PortInstance> outputPorts = actor.getOutputs();
    int rows = inputPorts.size() > outputPorts.size() ? inputPorts.size() : outputPorts.size();

    s.println(actor.getName() + " [label=<");
    s.inc();
    s.println("<TABLE BORDER=\"1\" CELLBORDER=\"0\" CELLSPACING=\"0\">");
    s.println("<TR><TD COLSPAN=\"2\">" + actor.getName() + "</TD></TR>");
    s.println(
        "<TR><TD COLSPAN=\"2\"><FONT POINT-SIZE=\"8\">["
            + ((TypeActor) actor.getType()).getName()
            + "]</FONT></TD></TR>");

    for (int i = 0; i < rows; i++) {
      String in = i < inputPorts.size() ? inputPorts.get(i).getName() : "";
      String out = i < outputPorts.size() ? outputPorts.get(i).getName() : "";
      s.println(
          "<TR><TD ALIGN=\"LEFT\" PORT=\""
              + in
              + "\">"
              + in
              + "</TD><TD ALIGN=\"RIGHT\" PORT=\""
              + out
              + "\">"
              + out
              + "</TD></TR>");
    }
    s.printlnDec("</TABLE>>];");

    return s;
  }
Ejemplo n.º 2
0
  private PortInstance findPortInstance(ActorInstance instance, String portName, boolean outputs) {
    List<PortInstance> ports = outputs ? instance.getOutputs() : instance.getInputs();
    for (PortInstance port : ports) {
      if (port.getName().equals(portName)) return port;
    }

    assert (false);
    return null;
  }
Ejemplo n.º 3
0
  private ActorInstance createActorInstance(Element element) {
    ActorInstance instance = IrFactory.eINSTANCE.createActorInstance();
    String id = element.getAttribute("id");
    instance.setId(id);
    doAnnotations(instance, element);

    addIrObject(id, instance);

    instance.setName(element.getAttribute("name"));
    instance.setType(createType(getChild(element, "Type")));

    List<Element> ports = getChildren(element, "PortInstance");
    for (Element e : ports) {
      PortInstance portInstance = IrFactory.eINSTANCE.createPortInstance();
      portInstance.setId(e.getAttribute("id"));
      portInstance.setName(e.getAttribute("name"));
      portInstance.setActor(instance);
      if (e.getAttribute("direction").equals("in")) {
        instance.getInputs().add(portInstance);
      } else {
        instance.getOutputs().add(portInstance);
      }
    }

    List<Element> actualParameters = getChildren(element, "ActualParameter");
    for (Element p : actualParameters) {
      TaggedExpression te = IrFactory.eINSTANCE.createTaggedExpression();
      te.setTag(p.getAttribute("name"));
      te.setExpression(createExpression(getChild(p, "Expr")));
      instance.getActualParameters().add(te);
    }

    return instance;
  }