Package org.eclipse.imp.pdb.facts

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


        out.println("\t" + key + " => " + tpbindings.get(key));
      }
    }
    out.println("Actual parameters:");
    for (int i = 0; i < formals.getArity(); i++) {
      IValue arg = values[i];
      out.println("\t" + formals.getFieldType(i) + " " + "=>" + arg);
    }
    out.println();
    return false;
  }
View Full Code Here


  public IString shell(IString command, IInteger duration, IEvaluatorContext ctx) {
    if (evaluator == null || old == null || env == null) {
      throw new ImplementationError("First call startShell, then shell, then end with endShell");
    }
   
    IValue valueType = tr.typeToValue(TypeFactory.getInstance().valueType(), ctx).getValue();
    StringBuilder content = new StringBuilder();
   
    try {
      outString.getBuffer().setLength(0);
      errString.getBuffer().setLength(0);
View Full Code Here

    checkUnaryFunction("second", to);
    checkUnaryFunction("third", from);
    ICursor c = (ICursor)cursor;
    Context ctx = new InvertorContext(c.getCtx(), (ICallableValue)from);
    ICallableValue f = (ICallableValue)to;
    IValue computed = f.call(new Type[] {c.getWrappedValue().getType()}, new IValue[] { c.getWrappedValue() }, null).getValue();
    return CursorFactory.makeCursor(computed, ctx);
  }
View Full Code Here

 
  public IValue getFact(IValue tr, IValue key, IValue name, IEvaluatorContext ctx) {
    if(!(key instanceof IConstructor))
      throw RuntimeExceptionFactory.illegalArgument(key, ctx.getCurrentAST(), ctx.getStackTrace(), "key is not a reified type");

    IValue fact = transaction(tr).getFact(ctx, typeReifier.valueToType((IConstructor) key), name);
    if(fact == null)
      fact = null; // <- put breakpoint here!
    return check(fact, (IConstructor) key, name, ctx);
  }
View Full Code Here

    ProducerWrapper(IEvaluatorContext ctx, ICallableValue fun, ISet keys) {
      this.ctx = ctx;
      this.fun = fun;
      for(IValue v : keys) {
        if(v instanceof ITuple) {
          IValue keyType = ((ITuple)v).get(0);
          IValue nameType = ((ITuple)v).get(1);
          this.keys.add(TypeFactory.getInstance().tupleType(
              typeReifier.valueToType((IConstructor)keyType),
              typeReifier.valueToType((IConstructor)nameType)));
        }
        else {
View Full Code Here

    }
   
    public boolean produce(IRascalMonitor monitor, ITransaction<Type, IValue, IValue> tr,
        Type key, IValue name) {
      Transaction t = (Transaction)tr;
      IValue reifiedKey = reify(ctx, key);
      Result<IValue> result = fun.call(monitor, new Type[] {t.getType(), reifiedKey.getType(), name.getType()},
          new IValue[] {t, reifiedKey, name}, null);
      if(result.getValue() instanceof IBool)
        return ((IBool)result.getValue()).getValue();
      else
        throw new UnexpectedType(TypeFactory.getInstance().boolType(), result.getType(), ctx.getCurrentAST());
View Full Code Here

        Type[] argTypes = new org.eclipse.imp.pdb.facts.type.Type[] {TF.stringType(), TF.sourceLocationType()};
        IValue[] argValues = new IValue[] { mn, sl };
       
        // Invoke the importer, which should generate the text of the module that we need
        // to actually import.
        IValue module = importer.call(argTypes, argValues, null).getValue();
        String moduleText = module.getType().isString() ? ((IString) module).getValue() : TreeAdapter.yield((IConstructor) module);
       
        moduleText = "@generated\n" + moduleText;
       
        try {
          URIResolverRegistry reg = eval.getResolverRegistry();
View Full Code Here

      return writer.done();
    } else {
      RandomValueTypeVisitor visitor = descend();
      ISet set = (ISet) visitor.generate(type);

      IValue element = null;
      int recursionGuard = 0; // Domain of set can be small.
      while ((element == null || set.contains(element))
          && recursionGuard < 1000) {
        recursionGuard += 1;
        element = visitor.generate(type.getElementType());
View Full Code Here

      if (result != null) {
        RandomValueTypeVisitor visitor = descend();
        Map<String, Type> annotations = rootEnv.getStore()
            .getAnnotations(type);
        for (Map.Entry<String, Type> entry : annotations.entrySet()) {
          IValue value = visitor.generate(entry.getValue());
          if (value == null) {
            return null;

          }
          result = result.asAnnotatable().setAnnotation(entry.getKey(), value);
View Full Code Here

    RandomValueTypeVisitor visitor = descend();

    LinkedList<IValue> values = new LinkedList<IValue>();
    for (int i = 0; i < type.getArity(); i++) {
      Type fieldType = type.getFieldType(i);
      IValue argument = visitor.generate(fieldType);
      if (argument == null) {
        return null;
        /*
         * Het is onmogelijk om de constructor te bouwen als ������n
         * argument null is.
         */
      }
      values.add(argument);
    }
    IValue[] params = values.toArray(new IValue[values.size()]);
    if (stRandom.nextBoolean() && type.getKeywordParameterTypes().getArity() > 0) {
      Map<String, IValue> kwParams = new HashMap<>();
      for (String kw:  type.getKeywordParameters()) {
        if (stRandom.nextBoolean()) continue;
        Type fieldType = type.getKeywordParameterType(kw);
        IValue argument = visitor.generate(fieldType);
        if (argument == null) {
          return null;
        }
        kwParams.put(kw, argument);
      }
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.