Package wyvern.tools.types

Examples of wyvern.tools.types.Type


      String newName = getNextName(methNum, prod.getName());

      //Parse the input code
      SpliceBindExn spliced = LangUtil.spliceBinding(new IParseBuffer(prod.getCode()), bindings);

      Type resType = lhsEnv.lookup(prod.getLhs().getName().toString()).getType();

      //Save it to the external dict
      toGen.put(newName, new Pair<>(resType, spliced));

      //Code to invoke the equivalent function
View Full Code Here


  public Type resolve(Environment env) {
    // System.out.println("Inside TypeInv innerType = " + innerType + " and its class is " + innerType.getClass());
   
    if (this.innerType instanceof UnresolvedType) {
      UnresolvedType ut = (UnresolvedType) this.innerType;
      Type t = ut.resolve(env);
     
      // System.out.println("GOT: " + t);
    }
    TypeBinding fetched = ((RecordType) innerType).getInnerType(invName);
View Full Code Here

  public TypeVarDecl(String name, Type body, TypedAST metadata, FileLocation fileLocation) {
    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

    return retType;
  }

  @Override
  public Type typecheck(Environment env, Optional<Type> expected) {
    Type lastType = wyvern.tools.types.extensions.Unit.getInstance();
    for (TypedAST t : exps) {
      lastType = t.typecheck(env, (exps.getLast() == t)?expected:Optional.empty());
      if (t instanceof EnvironmentExtender)
        env = ((EnvironmentExtender) t).extend(env, env);
    }
View Full Code Here

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

    writer.writeArgs(binding.getName());   
  }

  @Override
  public Type typecheck(Environment env, Optional<Type> expected) {
    Type type = getType();
    if (type == null) {
      String name = binding.getName();
      binding = env.lookupType(name);
      if (binding == null)
        reportError(TYPE_NOT_DECLARED, this, name);
View Full Code Here

    writer.writeArgs(receiver, operationName, argument);
  }

  @Override
  protected Type doTypecheck(Environment env, Optional<Type> expected) {
    Type receiverType = receiver.typecheck(env, Optional.empty());
   
    if (argument != null)
      argument.typecheck(env, Optional.empty());
   
    if (receiverType instanceof OperatableType) {
      return ((OperatableType)receiverType).checkOperator(this,env);
    } else {
      ToolError.reportError(ErrorMessage.OPERATOR_DOES_NOT_APPLY, this, "Trying to call a function on non OperatableType!", receiverType.toString());
      return null;
    }
  }
View Full Code Here

    visitor.visit(this);
  }

  @Override
  public void checkAssignment(Assignment ass, Environment env) {
    Type recType = receiver.typecheck(env, Optional.empty());
    if (!(recType instanceof ClassType)) //TODO: Hack
      throw new RuntimeException("Cannot assign to a field on a type without fields!");
    ((ClassType) recType).getEnv().lookupBinding(operationName, AssignableNameBinding.class).get();
  }
View Full Code Here

    this.location = location;
  }


  public static Arrow getMethodType(List<NameBinding> args, Type returnType) {
    Type argType = null;
    if (args.size() == 0) {
      argType = Unit.getInstance();
    } else if (args.size() == 1) {
      argType = args.get(0).getType();
    } else {
View Full Code Here

TOP

Related Classes of wyvern.tools.types.Type

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.