Package wyvern.tools.types

Examples of wyvern.tools.types.Type


    Environment extEnv = env;
    for (NameBinding bind : argNames) {
      extEnv = extEnv.extend(bind);
    }
    if (body != null) {
      Type bodyType = body.typecheck(extEnv, Optional.of(((Arrow)type).getResult())); // Can be null for def inside type!
      type = TypeResolver.resolve(type, env);
     
      Type retType = ((Arrow)type).getResult();
     
      // System.out.println("bodyType = " + bodyType);
      // System.out.println("retType = " + retType);
     
      if (bodyType != null && !bodyType.subtype(retType))
View Full Code Here


      }
    }
   
   
    // Variable we're matching must exist and be a tagged type
    Type matchingOverType = matchingOver.getType();
   
    String className = getTypeName(matchingOverType);
   
    if (className == null){
      //TODO change this to an error message
      throw new RuntimeException("variable matching over must be a Class or Type");
    }
   
    TagBinding matchBinding = TagBinding.get(className);
   
    if (matchBinding == null) {
      //TODO change this to a typecheck error
      throw new RuntimeException("Value is not tagged.");
    }
   
    //All things we match over must be tagged types
    for (Case c : cases) {
      if (c.isDefault()) continue;
     
      String tagName = c.getTaggedTypeMatch();
     
      Optional<ClassType> type = env.lookupBinding(tagName, ClassType.class);
      NameBinding binding = env.lookup(tagName);
     
      if (binding == null) {
        // type wasn't declared...
        ToolError.reportError(ErrorMessage.UNKNOWN_TAG, matchingOver);
      }
     
      Type t = binding.getType();
     
      if (t instanceof ClassType) {
        ClassType classType = (ClassType) t;
       
        String name = classType.getName();
View Full Code Here

    writer.writeArgs(binding.getName());   
  }

  @Override
  public Type typecheck(Environment env, Optional<Type> expected) {
    Type type = getType();
    if (type == null) {
      String name = binding.getName();
      binding = env.lookup(name);
      if (binding == null)
        reportError(VARIABLE_NOT_DECLARED, this, name);
View Full Code Here

  }

  @Override
  protected Type doTypecheck(Environment env) {
    if (this.definition != null) {
      Type varType = definitionType;
      boolean defType = this.definition.typecheck(env, Optional.of(varType)).subtype(varType);
      if (!defType)
        ToolError.reportError(ErrorMessage.ACTUAL_FORMAL_TYPE_MISMATCH, this);
    }
    return binding.getType();
View Full Code Here

    writer.writeArgs(function, argument);
  }

  @Override
  protected Type doTypecheck(Environment env, Optional<Type> expected) {
    Type fnType = function.typecheck(env, Optional.empty());

    Type argument = null;
    if (fnType instanceof Arrow)
      argument = ((Arrow) fnType).getArgument();
    else if (fnType instanceof Intersection) {
      List<Type> args = fnType.getChildren().values().stream()
          .filter(tpe -> tpe instanceof Arrow).map(tpe->((Arrow)tpe).getArgument())
View Full Code Here

TOP

Related Classes of wyvern.tools.types.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.