Package org.eclipse.imp.pdb.facts

Examples of org.eclipse.imp.pdb.facts.IMapWriter


        map.put(key, writer);
      }
      writer.insert(value);
    }
   
    IMapWriter mapWriter = values.mapWriter();
    for (IValue key : map.keySet()) {
      mapWriter.put(key, map.get(key).done());
    }
   
    return mapWriter.done();
  }
View Full Code Here


        map.put(key, writer);
      }
      writer.insert(value);
    }
   
    IMapWriter mapWriter = values.mapWriter();
    for (IValue key : map.keySet()) {
      mapWriter.put(key, map.get(key).done());
    }
   
    return mapWriter.done();
  }
View Full Code Here

        hm.put(key, wValSet);
      }
      wValSet.insert(val);
    }
   
    IMapWriter w = values.mapWriter();
    for(IValueWrap v : hm.keySet()){
      w.put(v.getValue(), hm.get(v).done());
    }
    return w.done();
  }
View Full Code Here

  }
 
  public IValue toMapUnique(ISet st)
  // @doc{toMapUnique -- convert a set of tuples to a map; keys are unique}
  {
    IMapWriter w = values.mapWriter();
    HashSet<IValueWrap> seenKeys = new HashSet<IValueWrap>();

    for (IValue v : st) {
      ITuple t = (ITuple) v;
      IValueWrap key = new IValueWrap(t.get(0));
      IValue val = t.get(1);
      if(seenKeys.contains(key)) {
        throw RuntimeExceptionFactory.MultipleKey(key.getValue(), null, null);
      }
      seenKeys.add(key);
      w.put(key.getValue(), val);
    }
    return w.done();
  }
View Full Code Here

    List<String> todo = new LinkedList<String>();
    Set<String> done = new HashSet<String>();
    todo.add(getName());
   
    IValueFactory VF = ValueFactoryFactory.getValueFactory();
    IMapWriter result = VF.mapWriter();
   
    while(!todo.isEmpty()){
      String m = todo.get(0);
      todo.remove(0);
     
      if(done.contains(m))
        continue;
     
      done.add(m);
     
      /* This allows the current module not to be loaded on the heap, for
       * parsing in the IDE
       */
      ModuleEnvironment env = m.equals(getName()) ? this : heap.getModule(m);
     
      if(env != null){
        ISetWriter importWriter = VF.setWriter();
        for(String impname : env.getImports()){
          if(!done.contains(impname)) todo.add(impname);
         
          importWriter.insert(VF.string(impname));
        }
       
        ISetWriter extendWriter = VF.setWriter();
        for(String impname : env.getExtends()){
          if(!done.contains(impname)) todo.add(impname);
         
          extendWriter.insert(VF.string(impname));
        }
       
        ISetWriter defWriter = VF.setWriter();
        for(IValue def : env.productions){
          defWriter.insert(def);
        }
       
        ITuple t = VF.tuple(importWriter.done(), extendWriter.done(), defWriter.done());
        result.put(VF.string(m), t);
      }else if(m.equals(getName())) { // This is the root scope.
        ISetWriter importWriter = VF.setWriter();
        for(String impname : importedModules){
          if(!done.contains(impname)) todo.add(impname);
         
          importWriter.insert(VF.string(impname));
        }
       
        ISetWriter extendWriter = VF.setWriter();
        for(String impname : getExtends()){
          if(!done.contains(impname)) todo.add(impname);
         
          extendWriter.insert(VF.string(impname));
        }
       
        ISetWriter defWriter = VF.setWriter();
        for(IValue def : productions){
          defWriter.insert(def);
        }
       
        ITuple t = VF.tuple(importWriter.done(), extendWriter.done(), defWriter.done());
        result.put(VF.string(m), t);
      }
    }
   
   
    return result.done();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.imp.pdb.facts.IMapWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.