Package org.rascalmpl.interpreter.types

Examples of org.rascalmpl.interpreter.types.FunctionType


    Type reified = Cobra.reifyType(type);
    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


    Set<FunctionType> alternatives = new HashSet<FunctionType>();
    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

   
    List<Expression> formals = func.getSignature().getParameters().getFormals().getFormals();
    int arity = formals.size();
    Type[] types = new Type[arity];
    String[] labels = new String[arity];
    FunctionType ft = getFunctionType();
   
    for (int i = 0; i < arity; i++) {
      types[i] = ft.getFieldType(i);
      assert formals.get(i).isTypedVariable(); // Java methods only have normal parameters as in `int i, int j`
      labels[i] = Names.name(formals.get(i).getName());
    }
   
    return TF.tupleType(types, labels);
View Full Code Here

           }
         }
        
         if(t1 instanceof FunctionType
             && t2 instanceof FunctionType && t1 != t2) {
           FunctionType f1 = (FunctionType) t1;
           FunctionType f2 = (FunctionType) t2;
           Type lub = f1.lub(f2);
           Type glb = f1.glb(f2);
           // System.out.println("Checking subtyping: " + f1 + " and " + f2 + "; lub and glb: " + lub + ", " + glb);
           if(f1.isSubtypeOf(f2)) {
             assertTrue(f1.getReturnType().isSubtypeOf(f2.getReturnType()));
             assertTrue(f2.getArgumentTypes().isSubtypeOf(f1.getArgumentTypes()));
           }
           if(f2.isSubtypeOf(f1)) {
             assertTrue(f2.getReturnType().isSubtypeOf(f1.getReturnType()));
             assertTrue(f1.getArgumentTypes().isSubtypeOf(f2.getArgumentTypes()));
           }
           if(lub instanceof FunctionType) {
             FunctionType flub = (FunctionType) lub;
             assertTrue(f1.getReturnType().isSubtypeOf(flub.getReturnType()));
             assertTrue(flub.getArgumentTypes().isSubtypeOf(f1.getArgumentTypes()));
             assertTrue(f2.getReturnType().isSubtypeOf(flub.getReturnType()));
             assertTrue(flub.getArgumentTypes().isSubtypeOf(f2.getArgumentTypes()));
           }
           if(glb instanceof FunctionType) {
             FunctionType fglb = (FunctionType) glb;
             assertTrue(fglb.getReturnType().isSubtypeOf(f1.getReturnType()));
             assertTrue(f1.getArgumentTypes().isSubtypeOf(fglb.getArgumentTypes()));
             assertTrue(fglb.getReturnType().isSubtypeOf(f2.getReturnType()));
             assertTrue(f2.getArgumentTypes().isSubtypeOf(fglb.getArgumentTypes()));
           }
         }
      }
    }
   
View Full Code Here

TOP

Related Classes of org.rascalmpl.interpreter.types.FunctionType

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.