Package org.eclipse.imp.pdb.facts

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


        result = org.rascalmpl.interpreter.result.ResultFactory
            .makeResult(rec.getType(), node, __eval.__getEval());
      } else if (rec.getType().isTuple()
          && subscript.getType().isInteger()) {
        int index = ((IInteger) subscript.getValue()).intValue();
        ITuple tuple = (ITuple) rec.getValue();

        if (index >= tuple.arity()) {
          throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
              .indexOutOfBounds((IInteger) subscript.getValue(),
                  __eval.__getEval().getCurrentAST(), __eval
                      .__getEval().getStackTrace());
        }

        __eval.__setValue(__eval.newResult(tuple.get(index), __eval
            .__getValue()));

        tuple = tuple.set(index, __eval.__getValue().getValue());
        result = org.rascalmpl.interpreter.result.ResultFactory
            .makeResult(rec.getType(), tuple, __eval.__getEval());
      } else if (rec.getType().isRelation()
          && subscript.getType().isSubtypeOf(
              rec.getType().getFieldType(0))) {
View Full Code Here


  public Void visitTuple(ITuple value) throws IOException {
    // {tuple: [ ... ]}
    out.beginArray()
      .value("tuple");
    out.beginArray();
    ITuple t = (ITuple) value;
    for (int i = 0; i < t.arity(); i++) {
      write(out, t.get(i));
    }
    out.endArray();
    out.endArray();
    return null;
  }
View Full Code Here

    }
  }
 
  public void fillOverloadedStore(IList overloadedStore) {
    for(IValue of : overloadedStore) {
      ITuple ofTuple = (ITuple) of;
      String scopeIn = ((IString) ofTuple.get(0)).getValue();
      if(scopeIn.equals("")) {
        scopeIn = null;
      }
      IList fuids = (IList) ofTuple.get(1);
      int[] funs = new int[fuids.length()];
      int i = 0;
      for(IValue fuid : fuids) {
        String name = ((IString) fuid).getValue();
        //stdout.println("fillOverloadedStore: " + name);
        //stdout.flush();
        Integer index = functionMap.get(name);
        if(index == null){
          throw new CompilerError("No definition for " + fuid + " in functionMap");
        }
        funs[i++] = index;
      }
      fuids = (IList) ofTuple.get(2);
      int[] constrs = new int[fuids.length()];
      i = 0;
      for(IValue fuid : fuids) {
        Integer index = constructorMap.get(((IString) fuid).getValue());
        if(index == null){
View Full Code Here

    types = new int[exceptions.length()];
    handlers = new int[exceptions.length()];
   
    int i = 0;
    for(IValue entry : exceptions) {
      ITuple tuple = (ITuple) entry;
      String from = ((IString) tuple.get(0)).getValue();
      String to = ((IString) tuple.get(1)).getValue();
      Type type = rvm.symbolToType((IConstructor) tuple.get(2));
      String handler = ((IString) tuple.get(3)).getValue();
     
      froms[i] = codeblock.getLabelPC(from);
      tos[i] = codeblock.getLabelPC(to);
      types[i] = codeblock.getTypeConstantIndex(type);
      handlers[i] = codeblock.getLabelPC(handler);     
View Full Code Here

      }
     
      Pattern escapingNeeded = Pattern.compile("[\\n\\r\"\\x" + Integer.toHexString(separator.charAt(0)) + "]");
     
      for(IValue v : (isListRel ? lrel : irel)){
        ITuple tup = (ITuple) v;
        boolean firstTime = true;
        for(IValue w : tup){
          if(firstTime)
            firstTime = false;
          else
View Full Code Here

  SimpleRegression make(IList dataValues){
    if(dataValues.length() <= 2)
      throw RuntimeExceptionFactory.illegalArgument(dataValues, null, null, "SimpleRegression data should have more than 2 elements");
    SimpleRegression simple = new SimpleRegression();
    for(IValue v : dataValues){
      ITuple t = (ITuple) v;
      INumber x = (INumber) t.get(0);
      INumber y = (INumber) t.get(1);
      simple.addData(x.toReal().doubleValue(), y.toReal().doubleValue());
    }
    return simple;
  }
View Full Code Here

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

     
      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(yieldList){
            wset.append(args[0]);
          } else {
            wrel.append(getValueFactory().tuple(args));
View Full Code Here

                .tupleEmpty(), __eval.__getValue().getType(),
            this);
      }

      Type tupleType = __eval.__getValue().getType();
      ITuple tuple = (ITuple) __eval.__getValue().getValue();
      IValue[] results = new IValue[arguments.size()];
      Type[] resultTypes = new Type[arguments.size()];

      for (int i = 0; i < arguments.size(); i++) {
        Type argType = tupleType.getFieldType(i);
        IValue arg = tuple.get(i);
        Result<IValue> result = org.rascalmpl.interpreter.result.ResultFactory
            .makeResult(argType, arg, __eval.__getEval());
        AssignableEvaluator ae = new AssignableEvaluator(__eval
            .__getEnv(), null, result, __eval.__getEval());
        Result<IValue> argResult = arguments.get(i).assignment(ae);
View Full Code Here

 
  public IMap index(IList s) {
    Map<IValue, ISetWriter> map = new HashMap<IValue, ISetWriter>(s.length());
   
    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

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

    for (IValue v : st) {
      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

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.