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

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


      UnresolvedType ut = (UnresolvedType) this.innerType;
      Type t = ut.resolve(env);
     
      // System.out.println("GOT: " + t);
    }
    TypeBinding fetched = ((RecordType) innerType).getInnerType(invName);

    if (fetched.getMetadata().isPresent() && fetched.getMetadata().get().get() != null)
      return new MetadataWrapper(fetched.getUse(), fetched.getMetadata().get());
    else return fetched.getUse();
  }
View Full Code Here


      public ExtParser getParser() {
        return parseri;
      }
    };

    TypeDeclaration.attrEvalEnv = Environment.getEmptyEnvironment().extend(new ValueBinding("myNumMetadata", Util.toWyvObj(inner))).extend(new TypeBinding("HasParser", metaType));
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv().extend(new NameBindingImpl("myNumMetadata", metaType)), Optional.empty()), Int.getInstance());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv().extend(new ValueBinding("myNumMetadata", Util.toWyvObj(inner)))).toString(), "IntegerConstant(5)");
  }
View Full Code Here

    this.name = name;
    this.body = new EnvironmentExtInner(fileLocation) {
      @Override
      public Environment extendType(Environment env, Environment against) {
        Type type = TypeResolver.resolve(body, against);
        return env.extend(new TypeBinding(name, type, metadataObj))
            .extend(new LateNameBinding(name, () -> metadataObj.get().getType()));
      }


View Full Code Here

        continue;
      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

  @Override
  protected Environment doExtend(Environment old, Environment against) {
    if (!extGuard) {
      dclEnv.set(inner.extend(dclEnv.get(), old.extend(dclEnv.get())));
    }
    return old.extend(new NameBindingImpl(name, selfType)).extend(new TypeBinding(name, subTypeType));
  }
View Full Code Here

              Globals.getStandardEnv().extend(importEnv.get()).extend(dclEnv.get())));
        }
      }
      nameGuard = true;
    }
    return env.extend(new NameBindingImpl(name, selfType)).extend(new TypeBinding(name, subTypeType));
  }
View Full Code Here

 
    public TypeDeclaration(String name, DeclSequence decls, Reference<Value> metadata, FileLocation clsNameLine) {
      // System.out.println("Initialising TypeDeclaration ( " + name + "): decls" + decls);
    this.decls = decls;
    nameBinding = new NameBindingImpl(name, null);
    typeBinding = new TypeBinding(name, null, metadata);
    Type objectType = new TypeType(this);
    attrEnv.set(attrEnv.get().extend(new TypeDeclBinding("type", this)));
   
    Type classType = new ClassType(attrEnv, attrEnv, new LinkedList<String>(), getName()); // TODO set this to a class type that has the class members
    nameBinding = new LateNameBinding(nameBinding.getName(), () -> metadata.get().getType());

    typeBinding = new TypeBinding(nameBinding.getName(), objectType, metadata);
   
    // System.out.println("TypeDeclaration: " + nameBinding.getName() + " is now bound to type: " + objectType);
   
    this.location = clsNameLine;
    this.metaValue = metadata;
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.