Exemple #1
0
 @Override
 public void visit(SetUpdate setUpdate) {
   setUpdate.base().accept(this);
   for (Term key : setUpdate.removeSet()) {
     key.accept(this);
   }
 }
  @Override
  public ASTNode transform(org.kframework.kil.SetBuiltin node) throws TransformerException {
    assert node.isLHSView() : "unsupported set " + node;

    HashSet<Term> entries = new HashSet<Term>(node.elements().size());
    for (org.kframework.kil.Term entry : node.elements()) {
      Term key = (Term) entry.accept(this);
      entries.add(key);
    }

    if (node.hasViewBase()) {
      Term base = (Term) node.viewBase().accept(this);
      if (base instanceof SetUpdate) {
        SetUpdate setUpdate = (SetUpdate) base;
        /* TODO(AndreiS): check key uniqueness */
        return new SetUpdate(setUpdate.base(), setUpdate.removeSet());
      } else {
        /* base instanceof Variable */
        return new BuiltinSet(entries, (Variable) base);
      }
    } else {
      return new BuiltinSet(entries);
    }
  }