@Override public ASTNode transform(org.kframework.kil.MapBuiltin node) throws TransformerException { assert node.isLHSView() : "unsupported map " + node; HashMap<Term, Term> entries = new HashMap<Term, Term>(node.elements().size()); for (Map.Entry<org.kframework.kil.Term, org.kframework.kil.Term> entry : node.elements().entrySet()) { Term key = (Term) entry.getKey().accept(this); Term value = (Term) entry.getValue().accept(this); entries.put(key, value); } if (node.hasViewBase()) { Term base = (Term) node.viewBase().accept(this); if (base instanceof MapUpdate) { MapUpdate mapUpdate = (MapUpdate) base; /* TODO(AndreiS): check key uniqueness */ entries.putAll(mapUpdate.updateMap()); return new MapUpdate(mapUpdate.map(), mapUpdate.removeSet(), entries); } else { /* base instanceof Variable */ return new BuiltinMap(entries, (Variable) base); } } else { return new BuiltinMap(entries); } }
@Override public ASTNode visit(org.kframework.kil.MapBuiltin node, Void _void) { BuiltinMap.Builder builder = BuiltinMap.builder(termContext); for (Map.Entry<org.kframework.kil.Term, org.kframework.kil.Term> entry : node.elements().entrySet()) { builder.put((Term) this.visitNode(entry.getKey()), (Term) this.visitNode(entry.getValue())); } for (org.kframework.kil.Term term : node.baseTerms()) { builder.concatenate((Term) this.visitNode(term)); } return builder.build(); }