コード例 #1
0
ファイル: BuiltinSet.java プロジェクト: kframework/k
  @Override
  public List<Term> getKComponents() {
    DataStructureSort sort = global.getDefinition().dataStructureSortOf(sort());

    ArrayList<Term> components = Lists.newArrayList();
    elements
        .stream()
        .forEach(
            element ->
                components.add(
                    KItem.of(
                        KLabelConstant.of(sort.elementLabel(), global.getDefinition()),
                        KList.singleton(element),
                        global,
                        element.getSource(),
                        element.getLocation())));

    for (Term term : baseTerms()) {
      if (term instanceof BuiltinSet) {
        components.addAll(((BuiltinSet) term).getKComponents());
      } else {
        components.add(term);
      }
    }

    return components;
  }
コード例 #2
0
 @Override
 public ASTNode transform(org.kframework.kil.Variable node) throws TransformerException {
   if (node.getSort().equals("Bag"))
     return new Variable(node.getName(), Kind.CELL_COLLECTION.toString());
   DataStructureSort dataStructureSort = context.dataStructureSortOf(node.getSort());
   if (dataStructureSort != null) {
     if (dataStructureSort.type().equals(org.kframework.kil.KSorts.LIST))
       return new Variable(node.getName(), KSorts.LIST);
     if (dataStructureSort.type().equals(org.kframework.kil.KSorts.MAP))
       return new Variable(node.getName(), KSorts.MAP);
     if (dataStructureSort.type().equals(org.kframework.kil.KSorts.SET))
       return new Variable(node.getName(), KSorts.SET);
   }
   return new Variable(node.getName(), node.getSort());
 }
コード例 #3
0
  @Override
  public ASTNode visit(org.kframework.kil.Variable node, Void _void) {
    String name = node.fullName();

    if (node.getSort().equals(org.kframework.kil.Sort.BAG)
        || node.getSort().equals(org.kframework.kil.Sort.BAG_ITEM)) {
      return new Variable(name, Kind.CELL_COLLECTION.asSort());
    }

    if (node.getSort().equals(org.kframework.kil.Sort.K)) {
      return new Variable(name, Sort.KSEQUENCE);
    }
    if (node.getSort().equals(org.kframework.kil.Sort.KLIST)) {
      return new Variable(name, Sort.KLIST);
    }

    DataStructureSort dataStructureSort = context.dataStructureSortOf(node.getSort());
    if (dataStructureSort != null) {
      Sort sort = null;
      if (dataStructureSort.type().equals(org.kframework.kil.Sort.LIST)) {
        sort = Sort.LIST;
      } else if (dataStructureSort.type().equals(org.kframework.kil.Sort.MAP)) {
        sort = Sort.MAP;
      } else if (dataStructureSort.type().equals(org.kframework.kil.Sort.SET)) {
        sort = Sort.SET;
      } else {
        assert false : "unexpected data structure " + dataStructureSort.type();
      }

      if (concreteCollectionSize.containsKey(node)) {
        return new ConcreteCollectionVariable(name, sort, concreteCollectionSize.get(node));
      } else {
        return new Variable(name, sort);
      }
    }

    return new Variable(name, Sort.of(node.getSort()));
  }