Package wyvern.tools.typedAST.core.binding

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


    return isClass;
  }
 
  public ValDeclaration(String name, TypedAST definition, FileLocation location) {
    this.definition=definition;
    binding = new NameBindingImpl(name, null);
    this.location = location;
  }
View Full Code Here


    this.location = location;
  }
 
  public ValDeclaration(String name, Type type, TypedAST definition, FileLocation location) {
    this.definition=definition;
    binding = new NameBindingImpl(name, type);
    this.location = location;
  }
View Full Code Here

    if (this.definition != null)
      this.definitionType = this.definition.typecheck(env, Optional.ofNullable(resolved));
    if (resolved == null)
      resolved = definitionType;

    binding = new NameBindingImpl(binding.getName(), resolved);
    if (binding.getType() == null) {
      this.binding = new NameBindingImpl(binding.getName(), resolved);
    } else if (this.definitionType != null && !this.definitionType.subtype(resolved)){
      ToolError.reportError(ErrorMessage.NOT_SUBTYPE, this, this.definitionType.toString(), binding.getType().toString());
    }
   
    return binding.getType();
View Full Code Here

        typecheckSelf(against);
      resolved = definitionType;
    }
    definitionType = resolved;

    return env.extend(new NameBindingImpl(getName(), resolved));
  }
View Full Code Here

      .map(oeb->oeb.getStore())
      .orElse(Environment.getEmptyEnvironment());

    List<NameBinding> newBindings = new ArrayList<>();
    for (NameBinding binding : bindings)
      newBindings.add(new NameBindingImpl(binding.getName(), TypeResolver.resolve(binding.getType(), env)));
    bindings = newBindings;


    Optional<Type> resType = expected.map(type -> ((Arrow) type).getResult());
View Full Code Here

    Class[] args = m.getParameterTypes();
    List<String> names = getNames(m);
    ArrayList<NameBinding> output = new ArrayList<NameBinding>();
    int i = 0;
    for (Class arg : args) {
      output.add(new NameBindingImpl(names.get(i++), Util.javaToWyvType(arg)));
    }
    return output;

  }
View Full Code Here

  private static List<NameBinding> getNameBindings(List<String> paramNames, Class[] parameterTypes) {
    ArrayList<NameBinding> output = new ArrayList<NameBinding>();
    int i = 0;
    for (Class arg : parameterTypes) {
      output.add(new NameBindingImpl(paramNames.get(i++), Util.javaToWyvType(arg)));
    }
    return output;

  }
View Full Code Here

  @Override
  public Environment extend(Environment env, Environment against) {
    return env
        .extend(new TypeBinding(name, equivType))
        .extend(new NameBindingImpl(name, equivType));
  }
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

  private void writeBindings(String prefix, HashMap<String, Type> map, List<Binding> bindings) {
    int i = 0;
    for (Binding b : bindings) {
      if (b instanceof NameBindingImpl) {
        NameBindingImpl ni = (NameBindingImpl)b;
        map.put(prefix+":"+i++ +":ni:"+ni.getName(), ni.getType());
      } else if (b instanceof TypeBinding) {
        TypeBinding tb = (TypeBinding)b;
        map.put(prefix+":"+i++ +":tb:"+tb.getName(), tb.getType());
      } else {
        throw new RuntimeException("Unexpected binding");
View Full Code Here

TOP

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

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.