Examples of NameBindingImpl


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

  private Environment getEnvForDict(Map<String, Type> newChildren, Environment ndEnv, ArrayList<String> list) {
    for (String key : list) {
      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");
      }
View Full Code Here

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

    // System.out.println("classVarTypeBinding = " + classVarTypeBinding);

    if (classVarTypeBinding != null) { //In a class method
      Environment declEnv = classVarTypeBinding.getClassDecl().getInstanceMembersEnv();
      Environment innerEnv = seq.extendName(Environment.getEmptyEnvironment(), env).extend(declEnv);
      seq.typecheck(env.extend(new NameBindingImpl("this", new ClassType(new Reference<>(innerEnv), new Reference<>(innerEnv), new LinkedList<>(), classVarTypeBinding.getClassDecl().getName()))), Optional.empty());


      Environment environment = seq.extendType(declEnv, declEnv.extend(env));
      environment = seq.extendName(environment, environment.extend(env));
      Environment nnames = seq.extend(environment, environment);

      Environment objTee = TypeDeclUtils.getTypeEquivalentEnvironment(nnames.extend(declEnv));
      Type classVarType = new ClassType(new Reference<>(nnames.extend(declEnv)), new Reference<>(objTee), new LinkedList<>(), classVarTypeBinding.getClassDecl().getName());
      if (!(classVarType instanceof ClassType)) {
        // System.out.println("Type checking classVarType: " + classVarType + " and clsVar = " + clsVar);
        ToolError.reportError(ErrorMessage.MUST_BE_LITERAL_CLASS, this, classVarType.toString());
      }

      // TODO SMELL: do I really need to store this?  Can get it any time from the type
      cls = classVarTypeBinding.getClassDecl();
      ct = classVarType;

      return classVarType;
    } else { // Standalone
     
      isGeneric = true;
      Environment innerEnv = seq.extendType(Environment.getEmptyEnvironment(), env);
      Environment savedInner = env.extend(innerEnv);
      innerEnv = seq.extendName(innerEnv, savedInner);

      Environment declEnv = env.extend(new NameBindingImpl("this", new ClassType(new Reference<>(innerEnv), new Reference<>(innerEnv), new LinkedList<>(), null)));
      final Environment ideclEnv = StreamSupport.stream(seq.getDeclIterator().spliterator(), false).
          reduce(declEnv, (oenv,decl)->(decl instanceof ClassDeclaration)?decl.extend(oenv, savedInner):oenv,(a,b)->a.extend(b));
      seq.getDeclIterator().forEach(decl -> decl.typecheck(ideclEnv, Optional.<Type>empty()));

View Full Code Here

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

  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
TOP
Copyright © 2018 www.massapi.com. 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.