Package org.eclipse.imp.pdb.facts

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


    }
    /* Abstract Data Type */
    final String funname = ((IString) key).getValue();
    if (debug && key != null)
      System.err.println("builterm funname=" + funname);
    IList rs = vf.list(tf.valueType());
    final Iterator<IValue> args = ((IList) t.get(argKey)).iterator();
    while (args.hasNext()) {
      IValue arg = (IValue) args.next();
      arg = buildTerm(arg, type);
      rs = rs.append(arg);
    }
    IValue[] a = new IValue[rs.length()];
    Type[] b = new Type[rs.length()];
    {
      int i = 0;
      for (IValue c : rs) {
        a[i] = c;
        b[i] = c.getType();
View Full Code Here


      int found = -1;
      IConstructor foundType = null;
      IConstructor prod = TreeAdapter.getProduction(tree);
     
      if (!ProductionAdapter.isRegular(prod)) {
        IList syms = ProductionAdapter.getSymbols(prod);

        // TODO: find deeper into optionals, checking the actual arguments for presence/absence of optional trees.
        for (int i = 0; i < syms.length(); i++) {
          IConstructor sym = (IConstructor) syms.get(i);
         
          while (SymbolAdapter.isConditional(sym)) {
            sym = SymbolAdapter.getSymbol(sym);
          }
          if (SymbolAdapter.isLabel(sym)) {
View Full Code Here

   
    if (TreeAdapter.isAppl(tree)) {
      int found = -1;
      IConstructor foundType = null;
      IConstructor prod = TreeAdapter.getProduction(tree);
      IList syms = ProductionAdapter.getSymbols(prod);
     
      // TODO: find deeper into optionals, alternatives and sequences checking the actual arguments for presence/absence of optional trees.
      for (int i = 0; i < syms.length(); i++) {
        IConstructor sym = (IConstructor) syms.get(i);
        if (SymbolAdapter.isLabel(sym)) {
          if (SymbolAdapter.getLabel(sym).equals(name)) {
            found = i;
            foundType = SymbolAdapter.delabel(sym);
            break;
          }
        }
      }
     
      if (found != -1) {
        Type nont = RascalTypeFactory.getInstance().nonTerminalType(foundType);
        if (repl.getType().isSubtypeOf(nont)) {
          IList args = TreeAdapter.getArgs(tree).put(found, repl.getValue());
          return makeResult(getType(), tree.set("args", args), ctx);
        }
        throw new UnexpectedType(nont, repl.getType(), ctx.getCurrentAST());
      }
     
View Full Code Here

  }
 
  public static String getName(IConstructor tree) {
    IConstructor name = TreeAdapter.getArg(TreeAdapter.getArg(tree, "header"),"name");
    IConstructor parts = TreeAdapter.getArg(name, "names");
    IList args = TreeAdapter.getListASTArgs(parts);
    StringBuilder result = new StringBuilder();
   
    boolean first = true;
    for (IValue elem : args) {
      if (!first) {
View Full Code Here

 
  @Override
  public Result<IBool> has(Name name) {
    if (TreeAdapter.isAppl(getValue())) {
      IConstructor prod = TreeAdapter.getProduction(getValue());
      IList syms = ProductionAdapter.getSymbols(prod);
      String tmp = Names.name(name);
     
      // TODO: find deeper into optionals, checking the actual arguments for presence/absence of optional trees.
      for (IValue sym : syms) {
        if (SymbolAdapter.isLabel((IConstructor) sym)) {
View Full Code Here

     
      if (!p1.isEqual(p2)) {
        return bool(false, ctx);
      }
     
      IList l1 = TreeAdapter.getArgs(left);
      IList l2 = TreeAdapter.getArgs(right);
     
      if (l1.length() != l2.length()) {
        return bool(false, ctx);
      }
      for (int i = 0; i < l1.length(); i++) {
        IValue kid1 = l1.get(i);
        IValue kid2 = l2.get(i);
        // Recurse here on kids to reuse layout handling etc.
        Result<IBool> result = makeResult(kid1.getType(), kid1, ctx).equals(makeResult(kid2.getType(), kid2, ctx));
        if (!result.getValue().getValue()) {
          return bool(false, ctx);
        }
View Full Code Here

    try{
      boolean isListRel = rel instanceof IList;
      out = new UnicodeOutputStreamWriter(ctx.getResolverRegistry().getOutputStream(loc.getURI(), false), encoding.getValue(), false);
      out = new BufferedWriter(out); // performance
      ISet irel = null;
      IList lrel = null;
      if (isListRel) {
        lrel = (IList)rel;
      }
      else {
        irel = (ISet) rel;
      }
     
      int nfields = isListRel ? lrel.asRelation().arity() : irel.asRelation().arity();
      if(head){
        for(int i = 0; i < nfields; i++){
          if(i > 0)
            out.write(sep);
          String label = paramType.getFieldName(i);
View Full Code Here

    }
 
    List<MethodNode> buildMethods(IList iList) {
      ArrayList<MethodNode> ml = new ArrayList<MethodNode>();
      for (IValue v : iList) {
        IList eil = ((IList)((IConstructor)v).get(4));
        String ea[] = new String[eil.length()];
        for (int i = 0; i < eil.length(); i++) {
          ea[i] = ((IString)eil.get(i)).getValue();
        }
        MethodNode mn = new MethodNode(((IInteger)((IConstructor)v).get(0)).intValue(),
                         ((IString)((IConstructor)v).get(1)).getValue(),
                         ((IString)((IConstructor)v).get(2)).getValue(),
                         emptyIsNull(((IString)((IConstructor)v).get(3)).getValue()),
View Full Code Here

        } else if (((IConstructor)v).getName().equals("loadConstantFloat")) {
          il.add(new LdcInsnNode(((IReal)((IConstructor)v).get(0)).floatValue()));
        } else if (((IConstructor)v).getName().equals("loadConstantDouble")) {
          il.add(new LdcInsnNode(((IReal)((IConstructor)v).get(0)).doubleValue()));
        } else if (((IConstructor)v).getName().equals("lookupSwitch")) {
          IList kl = (IList)((IConstructor)v).get(1);
          int ka[] = new int[kl.length()];
          for (int i = 0; i < kl.length(); i++) {
            ka[i] = ((IInteger)kl.get(i)).intValue();
          }
          IList ll = (IList)((IConstructor)v).get(2);
          LabelNode la[] = new LabelNode[ll.length()];
          for (int i = 0; i < ll.length(); i++) {
            la[i] = getLabel(((IInteger)ll.get(i)).intValue());
          }
          il.add(new LookupSwitchInsnNode(getLabel(((IInteger)((IConstructor)v).get(0)).intValue()),
                          ka,
                          la));
        } else if (((IConstructor)v).getName().equals("method")) {
          il.add(new MethodInsnNode(((IInteger)((IConstructor)v).get(0)).intValue(),
                        ((IString)((IConstructor)v).get(1)).getValue(),
                        ((IString)((IConstructor)v).get(2)).getValue(),
                        ((IString)((IConstructor)v).get(3)).getValue()));
        } else if (((IConstructor)v).getName().equals("multiANewArray")) {
          il.add(new MultiANewArrayInsnNode(((IString)((IConstructor)v).get(0)).getValue(),
                            ((IInteger)((IConstructor)v).get(1)).intValue()));
        } else if (((IConstructor)v).getName().equals("tableSwitch")) {
          IList ll = (IList)((IConstructor)v).get(3);
          LabelNode la[] = new LabelNode[ll.length()];
          for (int i = 0; i < ll.length(); i++) {
            la[i] = getLabel(((IInteger)ll.get(i)).intValue());
          }
          il.add(new TableSwitchInsnNode(((IInteger)((IConstructor)v).get(0)).intValue(),
                           ((IInteger)((IConstructor)v).get(1)).intValue(),
                           getLabel(((IInteger)((IConstructor)v).get(2)).intValue()),
                           la));
View Full Code Here

 
  Collection<double[]> makeAnova(IList dataValues){
    int n = dataValues.length();
    Collection<double[]> res = new ArrayList<double[]>();
    for(int i = 0; i < n; i++){
      IList cat = (IList) dataValues.get(i);
      int m = cat.length();
      double[] dat = new double[m];
      for(int j = 0; j < m; j++){
        dat[i] = ((INumber) cat.get(j)).toReal().doubleValue();
      }
      res.add(dat);
    }
    return res;
  }
View Full Code Here

TOP

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

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.