Package wyvern.tools.typedAST.core.binding.typechecking

Examples of wyvern.tools.typedAST.core.binding.typechecking.TypeBinding


  public static Environment getStandardEnv() {
    Environment env = Environment.getEmptyEnvironment();
    env = env.extend(new ImportResolverBinding("java",JavaResolver.getInstance()));
    env = env.extend(new ImportResolverBinding("wyv", WyvernResolver.getInstance()));

    env = env.extend(new TypeBinding("Unit", Unit.getInstance()));
    env = env.extend(new TypeBinding("Int", Int.getInstance()));
    env = env.extend(new TypeBinding("Bool", Bool.getInstance()));
    env = env.extend(new TypeBinding("Str", Str.getInstance()));
   
    env = env.extend(new ValueBinding("null", UnitVal.getInstance(FileLocation.UNKNOWN))); // How to represent  shock/horror  null!?
    env = env.extend(new ValueBinding("true", new BooleanConstant(true)));
    env = env.extend(new ValueBinding("false", new BooleanConstant(false)));
   
View Full Code Here


        Type t = n.getType();
        return t;
      }
      throw new RuntimeException("Cannot find "+typeName +" in environment "+env);
    }
    TypeBinding typeBinding = env.lookupType(typeName);
    if (typeBinding.getMetadata().isPresent() && typeBinding.getMetadata().get().get() != null)
      return new MetadataWrapper(typeBinding.getUse(), typeBinding.getMetadata().get());
    else
      return typeBinding.getUse();
  }
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

    this.decls = decls;
    this.typeParams = typeParams;
    typeEquivalentEnvironmentRef = new Reference<>();
    classMembersEnv = new Reference<>();
    nameBinding = new NameBindingImpl(name, null);
    typeBinding = new TypeBinding(name, getObjType());
    nameBinding = new NameBindingImpl(name, getClassType());
    this.implementsName = implementsName;
    this.implementsClassName = implementsClassName;
    this.location = location;
  }
View Full Code Here

    if (decls != null) {
      if (this.typeEquivalentEnvironmentRef.get() == null)
        typeEquivalentEnvironmentRef.set(TypeDeclUtils.getTypeEquivalentEnvironment(decls,true));
      for (Declaration decl : decls.getDeclIterator()) {
        TypeBinding binding = new TypeBinding(nameBinding.getName(), getObjectType());
        if (decl.isClassMember()) {
          decl.typecheckSelf(genv.extend(binding));
        } else {
          decl.typecheckSelf(oenv.extend(binding));
        }
View Full Code Here

  }

  boolean envGuard = false;
  @Override
  public Environment extendName(Environment env, Environment against) {
    TypeBinding objBinding = new LateTypeBinding(nameBinding.getName(), this::getObjectType);

    if (!envGuard && decls != null) {
      classMembersEnv.set(Environment.getEmptyEnvironment());
      for (Declaration decl : decls.getDeclIterator()) {
        if (decl.isClassMember())
View Full Code Here

    // System.out.println("Looking up (inside getInnerType) name " + name);
    // System.out.println("Currently inside TypeType: " + this);
    // System.out.println("this.decl.getName = " + this.decl.getName());
    // System.out.println("this.getMembers() = " + this.getMembers());
   
    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

    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

      String[] kSplit = key.split(":");
      Type nt = newChildren.get(key);
      if(kSplit[2].equals("ni")) {
        ndEnv = ndEnv.extend(new NameBindingImpl(kSplit[3], nt));
      } else if (kSplit[2].equals("tb")) {
        ndEnv = ndEnv.extend(new TypeBinding(kSplit[3], nt));
      } else {
        throw new RuntimeException("Unexpected binding");
      }
    }
    return ndEnv;
View Full Code Here

        .filter(meth->meth.getName().equals("meta$get"))
        .filter(meth -> meth.getParameterCount() == 0)
        .findFirst();

    if (creator.isPresent())
        typeBinding = new TypeBinding(typeBinding.getName(), typeBinding.getType(), new Reference<Value>() {
          @Override
          public Value get() {
            try {
              return Util.toWyvObj(creator.get().invoke(null));
            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of wyvern.tools.typedAST.core.binding.typechecking.TypeBinding

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.