Package wyvern.tools.typedAST.core.binding

Examples of wyvern.tools.typedAST.core.binding.NameBinding


 
  public Type resolve(Environment env) {
    // System.out.println("Looking at: " + this.typeName);
   
    if (env.lookup(this.typeName) != null) {
      NameBinding n = env.lookup(this.typeName);
   
      // System.out.println("NameBinding = " + n);
      // System.out.println("Its type is " + n.getType());
    }
   
    if (env.lookupType(typeName) == null) {
      if (env.lookup(this.typeName) != null) {
        // Perhaps its first class?
        NameBinding n = env.lookup(this.typeName);
        Type t = n.getType();
        return t;
      }
      throw new RuntimeException("Cannot find "+typeName +" in environment "+env);
    }
    TypeBinding typeBinding = env.lookupType(typeName);
View Full Code Here


  @Override
  protected Type doTypecheck(Environment env, Optional<Type> expected) {
    Type argType = null;
    for (int i = 0; i < bindings.size(); i++) {
      NameBinding bdgs = bindings.get(i);
      bindings.set(i, new NameBindingImpl(bdgs.getName(), TypeResolver.resolve(bdgs.getType(), env)));
    }

    if (bindings.size() == 0)
      argType = Unit.getInstance();
    else if (bindings.size() == 1)
View Full Code Here

    assert opExp.getArgument() == null;
   
    // the operation should exist
    String opName = opExp.getOperationName();

    NameBinding m = typeDeclEnv.get().lookup(opName);

    if (m == null)
      throw new RuntimeException("Invalid operation "+opName+" on type " + this);
   
    // TODO Auto-generated method stub
    return m.getType();
  }
View Full Code Here

   
    TypeBinding tb = typeDeclEnv.get().lookupType(name);
    if (tb == null) {
      // System.out.println("Maybe it is a name?");
     
      NameBinding nm = typeDeclEnv.get().lookup(name);
      // System.out.println(nm.getType());
     
      return new TypeBinding(nm.getName(), nm.getType());
    } else {
      return tb;
    }
  }
View Full Code Here

      throw new RuntimeException(opExp.getLocation().toString());
    assert opExp.getArgument() == null;
   
    // the operation should exist
    String opName = opExp.getOperationName();
    NameBinding m = declEnv.get().lookup(opName);

    if (m == null)
      reportError(OPERATOR_DOES_NOT_APPLY, opExp, opName, this.toString());
   
    // TODO Auto-generated method stub
    return m.getType();
  }
View Full Code Here

  Type resolvedType = null;
  @Override
  public Environment extendName(Environment env, Environment against) {
    for (int i = 0; i < argNames.size(); i++) {
      NameBinding oldBinding = argNames.get(i);
      argNames.set(i, new NameBindingImpl(oldBinding.getName(), TypeResolver.resolve(oldBinding.getType(), against)));
    }
    if (resolvedType == null)
      resolvedType = TypeResolver.resolve(type, against);
    return env.extend(new NameBindingImpl(name, resolvedType));
  }
View Full Code Here

      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

TOP

Related Classes of wyvern.tools.typedAST.core.binding.NameBinding

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.