Package org.eclipse.imp.pdb.facts

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


  static IConstructor HOV(int hspace, IValue... t) {
    return HOV(hspace, false, t);
  }

  static IConstructor HOV(int hspace, boolean indent, IValue... t) {
    IList q = BoxADT.getEmptyList();
    for (IValue a : t) {
      if (a == null)
        continue;
      if (a.getType().isList()) {
        q = q.concat(indent ? makeIndent((IList) a, q.isEmpty())
            : (IList) a);
      } else
        q = q.append(indent && !q.isEmpty() ? I(a) : a);
    }
    IConstructor r = BoxADT.TAG.HOV.create(q);
    if (hspace >= 0)
      r = r.asAnnotatable().setAnnotation("hs", vf.integer(hspace));
    r = r.asAnnotatable().setAnnotation("vs", vf.integer(0));
View Full Code Here


    r = r.asAnnotatable().setAnnotation("vs", vf.integer(0));
    return r;
  }

  static IConstructor HV(int hspace, boolean indent, IValue... t) {
    IList q = BoxADT.getEmptyList();
    for (IValue a : t) {
      if (a == null)
        continue;
      if (a.getType().isList()) {
        q = q.concat(indent ? makeIndent((IList) a, q.isEmpty())
            : (IList) a);
      } else
        q = q.append(indent && !q.isEmpty() ? I(a) : a);
    }
    IConstructor r = BoxADT.TAG.HV.create(q);
    if (hspace >= 0)
      r = r.asAnnotatable().setAnnotation("hs", vf.integer(hspace));
    r = r.asAnnotatable().setAnnotation("vs", vf.integer(0));
View Full Code Here

    return false;
  }


  private IValue wrapWithListProd(IValue subject) {
    IList args = (IList) subject;
    IValue prod = ctx.getValueFactory().constructor(Factory.Production_Regular, declaredType.getSymbol());
   
    if (args.length() == 1) {
      IConstructor arg = (IConstructor) args.get(0);
     
      if (TreeAdapter.isList(arg) && TreeAdapter.getProduction(arg).isEqual(prod)) {
        return arg;
      }
    }
View Full Code Here

    return RascalTypeFactory.getInstance().functionType(returnType, parameters, tf.tupleEmpty());
  }

  private Type consToType(IConstructor symbol, TypeStore store) {
    Type adt = symbolToType((IConstructor) symbol.get("adt"), store);
    IList parameters = (IList) symbol.get("parameters");
    String name = ((IString) symbol.get("name")).getValue();
    // here we assume the store has the declaration already
    Type t = store.lookupConstructor(adt, name, symbolsToTupleType(parameters, store));
    return t;
   
View Full Code Here

  }

  private Type aliasToType(IConstructor symbol, TypeStore store) {
    String name = ((IString) symbol.get("name")).getValue();
    Type aliased = symbolToType((IConstructor) symbol.get("aliased"), store);
    IList parameters = (IList) symbol.get("parameters");
   
    if (parameters.isEmpty()) {
      return tf.aliasType(store, name, aliased);
    }
    else {
      return tf.aliasTypeFromTuple(store, name, aliased,  symbolsToTupleType(parameters, store));
    }
View Full Code Here

  public IConstructor addPositionInformation(IConstructor node, ISourceLocation location){
    return node.asAnnotatable().setAnnotation(Factory.Location, location);
  }
 
  public ArrayList<IConstructor> getChildren(IConstructor node){
    IList args = TreeAdapter.getArgs(node);
    ArrayList<IConstructor> children = new ArrayList<IConstructor>(args.length());
    for(int i = 0; i < args.length(); ++i){
      children.add((IConstructor) args.get(i));
    }
    return children;
  }
View Full Code Here

   
    return buildContextFreeNode((IConstructor) arg);
  }

  private List<AbstractAST> buildList(IConstructor in)  {
    IList args = TreeAdapter.getListASTArgs(in);
    List<AbstractAST> result = new ArrayList<AbstractAST>(args.length());
    for (IValue arg: args) {
      result.add(buildValue(arg));
    }
    return result;
  }
View Full Code Here

      sort = "KeywordArgument_Expression"; break;
    case "KeywordArguments":
      sort = "KeywordArguments_Expression"; break;
    }

    IList args = getASTArgs(tree);
    int arity = args.length();
    Object actuals[] = new Object[arity+1];
    actuals[0] = tree;

    int i = 1;
    for (IValue arg : args) {
View Full Code Here

        return liftHole(tree);
      }

      boolean lex = lexicalFather ? !TreeAdapter.isSort(tree) : TreeAdapter.isLexical(tree);
     
      IList args = TreeAdapter.getArgs(tree);
      String layout = layoutOfFather;
     
      if (cons != null && !lex) {
        String newLayout = getLayoutName(TreeAdapter.getProduction(tree));
       
        // this approximation is possibly harmfull. Perhaps there is a chain rule defined in another module, which nevertheless
        // switched the applicable layout. Until we have a proper type-analysis there is nothing we can do here.
        if (newLayout != null) {
          layout = newLayout;
        }
      }
     
      java.util.List<Expression> kids = new ArrayList<Expression>(args.length());
      for (IValue arg : args) {
        Expression ast = liftRec((IConstructor) arg, lex, layout);
        if (ast == null) {
          return null;
        }
        kids.add(ast);
      }

      if (TreeAdapter.isLexical(tree)) {
        return cache(tree, new Tree.Lexical(tree, kids));
      }
      else if (TreeAdapter.isList(tree)) {
        // TODO: splice element lists (can happen in case of ambiguous lists)
        return cache(tree, new Tree.List(tree, kids));
      }
      else if (TreeAdapter.isOpt(tree)) {
        return cache(tree, new Tree.Optional(tree, kids));
      }
      else {
        return cache(tree, new Tree.Appl(tree, kids));
      }
    }
    else if (TreeAdapter.isCycle(tree)) {
      return new Tree.Cycle(TreeAdapter.getCycleType(tree), TreeAdapter.getCycleLength(tree));
    }
    else if (TreeAdapter.isAmb(tree)) {
      ISet args = TreeAdapter.getAlternatives(tree);
      java.util.List<Expression> kids = new ArrayList<Expression>(args.size());
     
      for (IValue arg : args) {
        kids.add(liftRec((IConstructor) arg, lexicalFather, layoutOfFather));
      }
     
View Full Code Here

  private Expression liftHole(IConstructor tree) {
    assert tree.asAnnotatable().hasAnnotation("holeType");
    IConstructor type = (IConstructor) tree.asAnnotatable().getAnnotation("holeType");
    tree = (IConstructor) TreeAdapter.getArgs(tree).get(0);
    IList args = TreeAdapter.getArgs(tree);
    IConstructor nameTree = (IConstructor) args.get(4);
    ISourceLocation src = TreeAdapter.getLocation(tree);
    Expression result = new Tree.MetaVariable(tree, type, TreeAdapter.yield(nameTree));
    result.setSourceLocation(src);
    return result;
  }
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.