Package wyvern.tools.typedAST.core.binding.objects

Examples of wyvern.tools.typedAST.core.binding.objects.ClassBinding



    // FIXME: Currently allow this and class in both class and object methods. :(


    Environment genv = env.extend(new ClassBinding("class", this));
    Environment oenv = genv.extend(new NameBindingImpl("this", getObjectType()));



    if (decls != null) {
View Full Code Here


      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);
      }
   
    classEnv = classEnv.extend(new ClassBinding("claasdasdass", this));
   
    return classEnv;
  }
View Full Code Here

  @Override
  protected Type doTypecheck(Environment env, Optional<Type> expected) {
    // TODO check arg types
    // Type argTypes = args.typecheck();
   
    ClassBinding classVarTypeBinding = (ClassBinding) env.lookupBinding("class", ClassBinding.class).orElse(null);

    // 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
     
View Full Code Here

  public Value evaluate(Environment env) {
    Environment argValEnv = Environment.getEmptyEnvironment();
    for (Entry<String, TypedAST> elem : args.entrySet())
      argValEnv = argValEnv.extend(new ValueBinding(elem.getKey(), elem.getValue().evaluate(env)));

    ClassBinding classVarTypeBinding = (ClassBinding) env.lookupBinding("class", ClassBinding.class).orElse(null);
    ClassDeclaration classDecl;
    if (classVarTypeBinding != null)
      classDecl = classVarTypeBinding.getClassDecl();
    else {

      Environment mockEnv = Environment.getEmptyEnvironment();

      LinkedList<Declaration> decls = new LinkedList<>();
View Full Code Here

TOP

Related Classes of wyvern.tools.typedAST.core.binding.objects.ClassBinding

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.