Exemplo n.º 1
0
  private Guard createGuard(Element element) {
    Guard guard = IrFactory.eINSTANCE.createGuard();
    String id = element.getAttribute("id");
    guard.setId(id);
    doAnnotations(guard, element);

    addIrObject(id, guard);

    Action action = (Action) findIrObject(element.getAttribute("outer-scope"));
    guard.setOuter(action);

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

    List<Element> peeks = getChildren(element, "PortPeek");
    for (Element e : peeks) {
      PortPeek peek = createPortPeek(action, e);
      guard.getPeeks().add(peek);
    }

    Expression body = createExpression(getChild(element, "Expr"));
    guard.setBody(body);

    guard.setType(TypeSystem.createTypeBool());

    return guard;
  }