@Override public ASTNode visit(org.kframework.kil.SetBuiltin node, Void _void) { BuiltinSet.Builder builder = BuiltinSet.builder(termContext); for (org.kframework.kil.Term element : node.elements()) { builder.add((Term) this.visitNode(element)); } for (org.kframework.kil.Term term : node.baseTerms()) { builder.concatenate((Term) this.visitNode(term)); } return builder.build(); }
@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); } }