Package org.eclipse.imp.pdb.facts

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


    private void visitSequence(Iterator<IValue> listIterator)
        throws IOException {
      append('[');
      if (listIterator.hasNext()) {
        IValue v = listIterator.next();
        if (debug)
          System.err.println("VisitList:" + v + " " + v.getClass()
              + " " + v.getType());
        v.accept(this);
        while (listIterator.hasNext()) {
          append(',');
          listIterator.next().accept(this);
        }
      }
View Full Code Here


    public IValue visitMap(IMap o) throws IOException {
      Iterator<IValue> mapIterator = o.iterator();
      if (o.getKeyType().isString()) {
        append('{');
        if (mapIterator.hasNext()) {
          IValue key = mapIterator.next();
          key.accept(this);
          append(':');
          o.get(key).accept(this);
          while (mapIterator.hasNext()) {
            append(',');
            key = mapIterator.next();
            key.accept(this);
            append(':');
            o.get(key).accept(this);
          }
        }
        append('}');
      } else {
        if (typed || inNode > 0)
          append("{\"" + name + "\":\"#map\",\"" + args + "\":[");
        else
          append('[');
        if (mapIterator.hasNext()) {
          if (typed || inNode > 0)
            append("{\"" + name + "\":\"#tuple\",\"" + args
                + "\":[");
          else
            append('[');
          IValue key = mapIterator.next();
          key.accept(this);
          append(',');
          o.get(key).accept(this);
          if (typed || inNode > 0)
            append("]}");
          else
            append(']');
          while (mapIterator.hasNext()) {
            append(',');
            if (typed || inNode > 0)
              append("{\"" + name + "\":\"#tuple\",\"" + args
                  + "\":[");
            else
              append('[');
            key = mapIterator.next();
            key.accept(this);
            append(',');
            o.get(key).accept(this);
            if (typed || inNode > 0)
              append("]}");
            else
View Full Code Here

      append("{\"" + name + "\":");
      visitString(vf.string(o.getName()));
      append(",\"" + args + "\":");
      append('[');
      if (nodeIterator.hasNext()) {
        IValue v = nodeIterator.next();
        v.accept(this);
        while (nodeIterator.hasNext()) {
          append(',');
          v = nodeIterator.next();
          v.accept(this);
        }
      }
      append(']');
     
      if(o.isAnnotatable()){
View Full Code Here

      if (!anno.getType().isSubtypeOf(annoType)){
        throw new UnexpectedType(annoType, anno.getType(), ctx.getCurrentAST());
      }
    }

    IValue annotatedBase = ((INode)getValue()).asAnnotatable().setAnnotation(annoName, anno.getValue());

    return makeResult(getType(), annotatedBase, ctx);
  }
View Full Code Here

    }
   
    public Result<IValue> createVisitedDateTime(IEvaluator<Result<IValue>> eval, String datePart, String timePart, Lexical x) {
      try {
        StandardTextReader parser = new StandardTextReader();
        IValue result = parser.read(VF, new StringReader("$" + datePart + "T" + timePart));
        return makeResult(TF.dateTimeType(), result, eval);
      } catch (FactTypeUseException e) {
        throw new DateTimeSyntax(e.getMessage(), eval.getCurrentAST().getLocation());
      } catch (FactParseError e) {
        throw new DateTimeSyntax(e.getMessage(), eval.getCurrentAST().getLocation());
View Full Code Here

    private final IValue[] array;
    private final int size;
    private final Less less;

    private void swap(int i, int j) {
      IValue tmp = array[i];
      array[i] = array[j];
      array[j] = tmp;
    }
View Full Code Here

      }
      return this;
    }
   
    private void sort(int low, int high) {
      IValue pivot = array[low + (high-low)/2];
      int oldLow = low;
      int oldHigh = high;
     
      while (low < high) {
        for ( ; less.less(array[low], pivot); low++);
View Full Code Here

      }
     
      java.util.Map<Type,Type> bindings = new HashMap<Type,Type>();
      bindings.put(Factory.TypeParam, new TypeReifier(VF).symbolToType((IConstructor) symbol.getValue(), (IMap) declarations.getValue()));
     
      IValue val = VF.constructor(Factory.Type_Reified.instantiate(bindings), symbol.getValue(), declarations.getValue());
     
      bindings.put(Factory.TypeParam, TF.valueType());
      Type typ = Factory.Type.instantiate(bindings);
     
      return ResultFactory.makeResult(typ, val, __eval);
View Full Code Here

        }
      } else if(child instanceof LiteralPattern){
        /*
         * A literal pattern: add it to the set of fixed element
         */
        IValue lit = ((LiteralPattern) child).toIValue(env);
        Type childType = child.getType(env, null);
        if(!childType.comparable(staticSubjectElementType)){
//          throw new UnexpectedType(setSubject.getType(), childType, getAST());
          hasNext = false;
          return;
View Full Code Here

            return false;
          varGen[i] = new SingleElementIterator(elements, ctx);
        }
      } else {
        // Variable has been set before, use its dynamic type to distinguish set variables.
        IValue val = env.getVariable(name).getValue();
       
        if (val != null) {
          if (val != null && val.getType().isSet()){
            isSetVar[i] = true;
            if(elements.equals(val)){
              varGen[i] = new SingleIValueIterator(val);
              return true;
            }
View Full Code Here

TOP

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

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.