Package wyvern.tools.types

Examples of wyvern.tools.types.Environment


    return Unit.getInstance();
  }

  private Type getObjectType() {
    Environment declEnv = getInstanceMembersEnv();
    Environment objTee = TypeDeclUtils.getTypeEquivalentEnvironment(declEnv);
    return new ClassType(instanceMembersEnv, new Reference<Environment>(objTee) {
      @Override
      public Environment get() {
        return TypeDeclUtils.getTypeEquivalentEnvironment(instanceMembersEnv.get());
      }
View Full Code Here


    }, new LinkedList<>(), this.getName());
  }
 
  @Override
  protected Environment doExtend(Environment old, Environment against) {
    Environment newEnv = old.extend(nameBinding).extend(typeBinding);
   
    // FIXME: Currently allow this and class in both class and object methods. :(
    //newEnv = newEnv.extend(new TypeBinding("class", typeBinding.getType()));
    //newEnv = newEnv.extend(new NameBindingImpl("this", nameBinding.getType()));
   
    //extend with tag information
    if (isTagged()) {
      //type-test the tag information
     
      //TODO: fix this
     
      //first get/ create the binding
      TagBinding tagBinding = TagBinding.getOrCreate(taggedInfo.getTagName());
      newEnv = newEnv.extend(tagBinding);
     
      //now handle case-of and comprises clauses
      if (taggedInfo.getCaseOfTag() != null) {
        String caseOf = taggedInfo.getCaseOfTag();
       
View Full Code Here

    return newEnv;
  }

  @Override
  public Environment extendWithValue(Environment old) {
    Environment newEnv = old.extend(new ValueBinding(nameBinding.getName(), nameBinding.getType()));
   
    return newEnv;
  }
View Full Code Here

    ValueBinding vb = (ValueBinding) declEnv.lookup(nameBinding.getName());
    vb.setValue(classObj);
  }
 
  public Environment evaluateDeclarations(Environment addtlEnv) {
    Environment thisEnv = decls.extendWithDecls(Environment.getEmptyEnvironment());
    decls.bindDecls(declEvalEnv.extend(addtlEnv), thisEnv);
   
    return thisEnv;
  }
View Full Code Here

    return thisEnv;
  }
 
  public Environment getClassEnv(Environment extEvalEnv) {
   
    Environment classEnv = Environment.getEmptyEnvironment();

    if (decls == null)
      return classEnv;

    for (Declaration decl : decls.getDeclIterator()) {
      if (decl.isClassMember()){
        classEnv = decl.doExtendWithValue(classEnv);
      }
    }
   
    ClassBinding thisBinding = new ClassBinding("class", this);
    Environment evalEnv = classEnv.extend(thisBinding);
   
    for (Declaration decl : decls.getDeclIterator())
      if (decl.isClassMember()){
        decl.bindDecl(extEvalEnv.extend(evalEnv),classEnv);
      }
View Full Code Here

  public void initalize() {
    if (initalized)
      return;
    initalized = true;
    super.decls = getDecls(this.clazz);
    Environment emptyEnvironment = Environment.getEmptyEnvironment();
    super.classMembersEnv.set(super.decls.extend(emptyEnvironment, emptyEnvironment));
    super.declEvalEnv = emptyEnvironment;
    updateEnv();
  }
View Full Code Here

  public void updateEnv() {
    if (envDone)
      return;
    envDone = true;
    initalize();
    Environment declEnv = Environment.getEmptyEnvironment();
    Environment objEnv = getObjEnvV();
    if (declEnv == null)
      declEnv = Environment.getEmptyEnvironment();
    if (objEnv == null)
      objEnv = Environment.getEmptyEnvironment();
    for (Declaration decl : this.getDecls().getDeclIterator()) {
View Full Code Here

    super(decl);
  }

  @Override
  public Type typecheck(Environment env, Optional<Type> expected) {
    Environment ienv = env;
    Environment wtypes = extendType(env, env);
    env = extendName(wtypes, wtypes);
    for (Declaration d : this.getDeclIterator()) {
      Environment againstEnv = env;
      if ((d instanceof ValDeclaration) || (d instanceof VarDeclaration))
        againstEnv = ienv;
      env = d.extend(env, againstEnv);
    }
View Full Code Here

    ToolError.reportError(ErrorMessage.UNEXPECTED_INPUT, ast);
    return null;
  }

  public final Environment extendWithDecls(Environment env) {
    Environment newEnv = env;
    for (Declaration d : this.getDeclIterator()) {
      newEnv = d.extendWithValue(newEnv);
    }
    return newEnv;
  }
View Full Code Here

  public final Environment evalDecls(Environment env) {
    return bindDecls(extendWithDecls(env));
  }
 
  public final Environment bindDecls(Environment env) {
    Environment newEnv = env;
    for (Declaration d : this.getDeclIterator()) {
      d.evalDecl(newEnv, newEnv);
    }
    return newEnv;
  }
View Full Code Here

TOP

Related Classes of wyvern.tools.types.Environment

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.