Package org.eclipse.imp.pdb.facts

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


  {
    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);
View Full Code Here


   */
 
  public IList fieldsOf(IValue v){
    if(!v.getType().isTuple())
      throw RuntimeExceptionFactory.illegalArgument(v, null, null, "argument of type tuple is required");
    ITuple tp = (ITuple) v;
    Type tt = tp.getType();
    int a = tt.getArity();
    IListWriter w = values.listWriter();
    for(int i = 0; i < a; i++){
      String fname = tt.getFieldName(i);
      if(fname == null)
View Full Code Here

        wrel = this.getValueFactory().relationWriter();
      }

     
      for (IValue v : getValue()) {
        ITuple tup = (ITuple)v;
        boolean allEqual = true;
        for(int k = 0; k < nSubs; k++){
          if(subscriptIsSet[k] && ((subscripts[k] == null) ||
                               ((ISet) subscripts[k].getValue()).contains(tup.get(k)))){
            /* ok */
          } else if (subscripts[k] == null || tup.get(k).isEqual(subscripts[k].getValue())){
            /* ok */
          } else {
            allEqual = false;
          }
        }
       
        if (allEqual) {
          IValue args[] = new IValue[relArity - nSubs];
          for (int i = nSubs; i < relArity; i++) {
            args[i - nSubs] = tup.get(i);
          }
          if(yieldSet){
            wset.insert(args[0]);
          } else {
            wrel.insert(getValueFactory().tuple(args));
View Full Code Here

  }

  private IValue traverseTupleOnce(IValue subject, CaseBlockList casesOrRules,
      DIRECTION direction, PROGRESS progress, FIXEDPOINT fixedpoint, TraverseResult tr) {
    IValue result;
    ITuple tuple = (ITuple) subject;
    int arity = tuple.arity();
    IValue args[] = new IValue[arity];
    boolean hasMatched = false;
    boolean hasChanged = false;
   
   
    for (int i = 0; i < arity; i++){
      tr.changed = false;
      tr.matched = false;
      args[i] = traverseOnce(tuple.get(i), casesOrRules, direction, progress, fixedpoint, tr);
      hasMatched |= tr.matched;
      hasChanged |= tr.changed;
    }
   
    result = eval.getValueFactory().tuple(args);
View Full Code Here

  private void buildAdjacencyListAndDistance(ISet G){
    adjacencyList = new HashMap<IValue, LinkedList<IValue>> ();
    distance = new HashMap<IValue, Distance>();
   
    for(IValue v : G){
      ITuple tup = (ITuple) v;
      IValue from = tup.get(0);
      IValue to = tup.get(1);
     
      if(distance.get(from) == null)
        distance.put(from, new Distance(MAXDISTANCE));
      if(distance.get(to) == null)
        distance.put(to, new Distance(MAXDISTANCE));
View Full Code Here

  // @doc{toMap -- convert a list of tuples to a map; first value in old tuples is associated with a set of second values}
  {
    Map<IValueWrap,ISetWriter> hm = new HashMap<IValueWrap,ISetWriter>();

    for (IValue v : lst) {
      ITuple t = (ITuple) v;
      IValueWrap key = new IValueWrap(t.get(0));
      IValue val = t.get(1);
      ISetWriter wValSet = hm.get(key);
      if(wValSet == null){
        wValSet = values.setWriter();
        hm.put(key, wValSet);
      }
View Full Code Here

     }
   
     IMapWriter w = values.mapWriter();
     Set<IValueWrap> seenKeys = new HashSet<IValueWrap>();
     for(IValue v : lst){
       ITuple t = (ITuple) v;
       IValueWrap key = new IValueWrap(t.get(0));
       if(seenKeys.contains(key))
        throw RuntimeExceptionFactory.MultipleKey(key.getValue(), null, null);
       seenKeys.add(key);
       w.put(key.getValue(), t.get(1));
     }
     return w.done();
  }
View Full Code Here

 
  public IMap index(ISet s) {
    Map<IValue, ISetWriter> map = new HashMap<IValue, ISetWriter>(s.size());
   
    for (IValue t : s) {
      ITuple tuple = (ITuple) t;
      IValue key = tuple.get(0);
      IValue value = tuple.get(1);
     
      ISetWriter writer = map.get(key);
      if (writer == null) {
        writer = values.setWriter();
        map.put(key, writer);
View Full Code Here

        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);
      }
    }
   
   
View Full Code Here

TOP

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

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.