@Override
  public ASTNode transform(org.kframework.kil.ListBuiltin node) throws TransformerException {
    ArrayList<Term> elementsLeft = new ArrayList<Term>(node.elementsLeft().size());
    for (org.kframework.kil.Term entry : node.elementsLeft()) {
      Term newEntry = (Term) entry.accept(this);
      elementsLeft.add(newEntry);
    }

    ArrayList<Term> elementsRight = new ArrayList<Term>(node.elementsRight().size());
    for (org.kframework.kil.Term entry : node.elementsRight()) {
      Term newEntry = (Term) entry.accept(this);
      elementsRight.add(newEntry);
    }

    Term base = null;
    if (node.hasViewBase()) {
      assert node.viewBase() instanceof org.kframework.kil.Variable
          : "The viewbase " + node.viewBase() + " must be a variable";
      base = (Variable) node.viewBase().accept(this);
    } else {
      Collection<org.kframework.kil.Term> baseTerms = node.baseTerms();
      if (!baseTerms.isEmpty()) {
        assert baseTerms.size() == 1 : "Don't know how to handle multiple base terms for now.";
        Iterator<org.kframework.kil.Term> iterator = baseTerms.iterator();
        base = (Term) iterator.next().accept(this);
      }
    }
    return BuiltinList.of(base, 0, 0, elementsLeft, elementsRight);
  }
Ejemplo n.º 2
0
 @Override
 public ASTNode visit(org.kframework.kil.ListBuiltin node, Void _void) {
   BuiltinList.Builder builder = BuiltinList.builder(termContext);
   for (org.kframework.kil.Term element : node.elementsLeft()) {
     builder.addItem((Term) this.visitNode(element));
   }
   for (org.kframework.kil.Term term : node.baseTerms()) {
     builder.concatenate((Term) this.visitNode(term));
   }
   for (org.kframework.kil.Term element : node.elementsRight()) {
     builder.addItem((Term) this.visitNode(element));
   }
   return builder.build();
 }