Package org.eclipse.imp.pdb.facts.type

Examples of org.eclipse.imp.pdb.facts.type.Type


    out.println("Test " + name + " failed due to\n\tmissing exception: " + msg + "\n");
    return false;
  }

  public void resetGenerator(IValue type) {
    Type reified = Cobra.reifyType(type);
    generators.remove(reified);
  }
View Full Code Here


    generators.remove(reified);
  }

  public void setGenerator(IValue f) {
    FunctionType functionType = (FunctionType) f.getType();
    Type returnType = functionType.getReturnType();

    ICallableValue generator = (ICallableValue) f;

    generators.put(returnType, generator);
  }
View Full Code Here

    } else {
      int posArityMinusOne = function.nformals - 2; // The number of positional arguments minus one
      for(int i = 0; i < posArityMinusOne; i++) {
        this.stack[this.sp++] = stack[start + i];
      }
      Type argTypes = ((FunctionType) function.ftype).getArgumentTypes();
      if(function.nformals == arity && ((IValue) stack[start + posArityMinusOne]).getType().isSubtypeOf(argTypes.getFieldType(posArityMinusOne))) {
        this.stack[this.sp++] = stack[start + posArityMinusOne];
      } else {
        IListWriter writer = ValueFactoryFactory.getValueFactory().listWriter();
        for(int i = posArityMinusOne; i < arity - 1; i++) {
          writer.append((IValue) stack[start + i]);
View Full Code Here

    return rtf.functionType(getType(maxDepth), getTupleType(maxDepth), tf.voidType());
  }
 
  public Type getOverloadedFunctionType(int maxDepth) {
    // TODO: add keyword parameter generation
    Type returnType = getType(maxDepth);
    List<Type> l = getTypeList(maxDepth, 2);
    Set<FunctionType> alternatives = new HashSet<FunctionType>();
    for(Type t : l) {
      if(t.isTuple()) {
        alternatives.add((FunctionType)rtf.functionType(returnType, t, tf.voidType()));
View Full Code Here

      if (timer.hasExpired()) {
        throw RuntimeExceptionFactory.timeout(null, null);
      }

      if (expected != null) {
        Type typ = tr.valueToType((IConstructor) expected);
        if (!result.getType().isSubtypeOf(typ)) {
          throw new UnexpectedType(typ, result.getType(), ctx.getCurrentAST());
        }
      }
      return result;
View Full Code Here

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

    Type keyType = typeReifier.valueToType((IConstructor) key);
    if(!value.getType().isSubtypeOf(keyType))
      throw new UnexpectedType(keyType, value.getType(), ctx.getCurrentAST());
    else
      transaction(tr).setFact(keyType, name, value);
  }
View Full Code Here

    ArrayList<String> labels = new ArrayList<>();
    ArrayList<Type> types = new ArrayList<>();
    // TODO: I am not sure this is what we want. Double names will end up twice in the tuple type...
   
    for (AbstractFunction c : primaryCandidates) {
      Type args = c.getKeywordArgumentTypes();
     
      if (args != null && args.hasFieldNames()) {
        for (String label : args.getFieldNames()) {
          labels.add(label);
          types.add(args.getFieldType(label));
        }
      }
    }
   
    for (AbstractFunction c : defaultCandidates) {
      Type args = c.getKeywordArgumentTypes();

      if (args != null && args.hasFieldNames()) {
        for (String label : args.getFieldNames()) {
          labels.add(label);
          types.add(args.getFieldType(label));
       
      }
    }
   
    return TF.tupleType(types.toArray(new Type[types.size()]), labels.toArray(new String[labels.size()]));
View Full Code Here

    Iterator<AbstractFunction> iter = candidates.iterator();
    if(!iter.hasNext()) {
      return TF.voidType();
    }
    FunctionType first = iter.next().getFunctionType();
    Type returnType = first.getReturnType();
    alternatives.add(first);
   
    AbstractFunction l = null;
    while(iter.hasNext()) {
      l = iter.next();
View Full Code Here

  }

  private void initMethodAndStatusValues(final IEvaluatorContext ctx) {
    if (methodValues.isEmpty() || statusValues.isEmpty()) {
      Environment env = ctx.getHeap().getModule("util::Webserver");
      Type methodType = env.getAbstractDataType("Method");
      TypeFactory tf = TypeFactory.getInstance();
      methodValues.put(Method.DELETE, vf.constructor(env.getConstructor(methodType, "delete", tf.voidType())));
      methodValues.put(Method.GET, vf.constructor(env.getConstructor(methodType, "get", tf.voidType())));
      methodValues.put(Method.HEAD, vf.constructor(env.getConstructor(methodType, "head", tf.voidType())));
      methodValues.put(Method.POST, vf.constructor(env.getConstructor(methodType, "post", tf.voidType())));
      methodValues.put(Method.PUT, vf.constructor(env.getConstructor(methodType, "put", tf.voidType())));
     
      Type statusType = env.getAbstractDataType("Status");
                       
      statusValues.put(vf.constructor(env.getConstructor(statusType, "ok", tf.voidType())), Status.OK);
      statusValues.put(vf.constructor(env.getConstructor(statusType, "created", tf.voidType())), Status.CREATED);
      statusValues.put(vf.constructor(env.getConstructor(statusType, "accepted", tf.voidType())), Status.ACCEPTED);
      statusValues.put(vf.constructor(env.getConstructor(statusType, "noContent", tf.voidType())), Status.NO_CONTENT);
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.type.Type

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.