Пример #1
0
  private Action createAction(Element element) {
    Action action = IrFactory.eINSTANCE.createAction();
    String id = element.getAttribute("id");
    action.setId(id);
    doAnnotations(action, element);

    addIrObject(id, action);

    action.setOuter((Actor) findIrObject(element.getAttribute("outer-scope")));
    List<Element> qualifiedName = getChildren(getChild(element, "QID"), "ID");
    for (Element e : qualifiedName) {
      action.getTag().add(e.getAttribute("name"));
    }

    List<Element> decls = getChildren(element, "Decl");
    for (Element e : decls) {
      Declaration decl = createDeclaration(e);
      action.getDeclarations().add(decl);
    }

    List<Element> guards = getChildren(element, "Guard");
    for (Element e : guards) {
      Guard guard = createGuard(e);
      action.getGuards().add(guard);
    }

    List<Element> inputs = getChildren(element, "PortRead");
    for (Element e : inputs) {
      PortRead portRead = createPortRead(action, e);
      action.getInputs().add(portRead);
    }

    List<Element> stmts = getChildren(element, "Stmt");
    for (Element e : stmts) {
      Statement stmt = createStatement(e);
      action.getStatements().add(stmt);
    }

    List<Element> outputs = getChildren(element, "PortWrite");
    for (Element e : outputs) {
      PortWrite portWrite = createPortWrite(action, e);
      action.getOutputs().add(portWrite);
    }

    return action;
  }
Пример #2
0
  private PortPeek createPortPeek(Action action, Element element) {
    PortPeek portPeek = IrFactory.eINSTANCE.createPortPeek();
    portPeek.setId(element.getAttribute("id"));
    doAnnotations(portPeek, element);
    portPeek.setPort(findPort((Actor) action.getOuter(), element.getAttribute("port"), false));
    portPeek.setPosition(Integer.parseInt(element.getAttribute("position")));
    Element repeat = getChild(element, "Repeat");
    if (repeat != null) {
      portPeek.setRepeat(createExpression(getChild(repeat, "Expr")));
    }

    portPeek.setVariable(createVariableReference(getChild(element, "Var")));

    return portPeek;
  }
Пример #3
0
  private PortRead createPortRead(Action action, Element element) {
    PortRead portRead = IrFactory.eINSTANCE.createPortRead();
    portRead.setId(element.getAttribute("id"));
    doAnnotations(portRead, element);
    portRead.setPort(findPort((Actor) action.getOuter(), element.getAttribute("port"), false));

    List<Element> vars = getChildren(element, "Var");
    for (Element e : vars) {
      VariableReference var = createVariableReference(e);
      portRead.getVariables().add(var);
    }

    Element repeat = getChild(element, "Repeat");
    if (repeat != null) {
      portRead.setRepeat(createExpression(getChild(repeat, "Expr")));
    }

    return portRead;
  }
Пример #4
0
  private PortWrite createPortWrite(Action action, Element element) {
    PortWrite portWrite = IrFactory.eINSTANCE.createPortWrite();
    String id = element.getAttribute("id");
    portWrite.setId(id);
    doAnnotations(portWrite, element);
    addIrObject(id, portWrite);

    portWrite.setOuter(action);

    portWrite.setPort(findPort((Actor) action.getOuter(), element.getAttribute("port"), true));

    List<Element> decls = getChildren(element, "Decl");
    for (Element e : decls) {
      Declaration decl = createDeclaration(e);
      portWrite.getDeclarations().add(decl);
    }

    List<Element> stmts = getChildren(element, "Stmt");
    for (Element e : stmts) {
      Statement stmt = createStatement(e);
      portWrite.getStatements().add(stmt);
    }

    List<Element> exprs = getChildren(element, "Expr");
    for (Element e : exprs) {
      Expression expr = createExpression(e);
      portWrite.getExpressions().add(expr);
    }

    Element repeat = getChild(element, "Repeat");
    if (repeat != null) {
      portWrite.setRepeat(createExpression(getChild(repeat, "Expr")));
    }

    return portWrite;
  }