Example #1
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;
  }
Example #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;
  }