Package wyvern.tools.types

Examples of wyvern.tools.types.Type


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

  @Override
  protected Type doTypecheck(Environment env) {
    Type resolved = null;
    if (binding.getType() != null)
      resolved = TypeResolver.resolve(binding.getType(), env);
    if (this.definition != null)
      this.definitionType = this.definition.typecheck(env, Optional.ofNullable(resolved));
    if (resolved == null)
View Full Code Here


  @Override
  public Environment extendName(Environment env, Environment against) {
    // System.out.println("Resolving ValDeclaration using extendName: " + this.getName());
   
    Type resolved;
    if (binding.getType() != null) {
     
      // System.out.println("Inside ValDeclaration resolving type: " + binding.getType());
      // System.out.println("Inside ValDeclaration resolving type: " + binding.getType().getClass());
     
View Full Code Here

    return null;
  }

  @Override
  public Type typecheck(Environment env, Optional<Type> expected) {
    Type dslType = expected.orElseGet(this::getDefaultType);

    Value vparser =
        Util.invokeValue(((MetaType) dslType).getMetaObj(),
            "getParser", UnitVal.getInstance(FileLocation.UNKNOWN));
    ExtParser parser = (ExtParser) Util.toJavaObject(vparser, ExtParser.class);
View Full Code Here


    Optional<Type> resType = expected.map(type -> ((Arrow) type).getResult());

    outerEnv = outerEnv.extend(bindings.stream().reduce(Environment.getEmptyEnvironment(), Environment::extend, (a,b)->b.extend(a)));
    Type exnType = exn.typecheck(outerEnv, resType);
    cached = Optional.of(exnType);
    return getType();
  }
View Full Code Here

    //Path path = Paths.get(args[0]);
    //Files.lines(path).forEach(s -> System.out.println(s));
   
    try (FileInputStream fis = new FileInputStream(file)) {
      TypedAST res = (TypedAST)new Wyvern().parse(new InputStreamReader(fis), "test input");
      Type checkedType = res.typecheck(Globals.getStandardEnv(), Optional.empty());
      System.out.println("Result type: "+checkedType);
      res = new DSLTransformer().transform(res);
      Value finalV = res.evaluate(Globals.getStandardEnv());
      System.out.println("Result: "+finalV);
    }
View Full Code Here

  @Override
  public Type typecheck(Environment env, Optional<Type> expected) {
    Environment outerEnv = env.lookupBinding("oev", TSLBlock.OuterEnviromentBinding.class)
      .map(oeb->oeb.getStore())
      .orElse(Environment.getEmptyEnvironment());
    Type exnType = exn.typecheck(outerEnv, expected);
    cached = Optional.of(exnType);
    return exnType;
  }
View Full Code Here

    }
  }

  public static SpliceType spliceType(ParseBuffer inpType) {
    try {
      Type res = (Type)new TypeParser().parse(new StringReader(inpType.getSrcString()), "inner type");
      return new SpliceType(res);
    } catch (IOException | CopperParserException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

  @Override
  protected Type doTypecheck(Environment env, Optional<Type> expected) {
    decl.typecheck(env, Optional.empty());
    Environment newEnv = decl.extendWithDecls(env);
    Type bodyType = body.typecheck(newEnv, Optional.empty());
    return bodyType;
  }
View Full Code Here

    public Type typecheck(Environment env) {
      if (typechecking) {
        throw new RuntimeException("Cyclic dependency");
      }
      typechecking = true;
      Type resu = res.typecheck(env, Optional.<Type>empty());

      if (res instanceof EnvironmentExtender) {
        MiBEnv = ((EnvironmentExtender) res).evalDecl(MiBEnv);
      }
      typechecking = false;
View Full Code Here

            "val n:MyNum = { 5 }\n" +
            "n.getValue()";

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");

    Type parserType = Util.javaToWyvType(ExtParser.class);
    Type metaType = Util.javaToWyvType(HasParser.class);


    final ExtParser parseri = str -> {
      New newv = new New(new HashMap<>(), null);
      TypedAST dbody = new IntegerConstant(Integer.parseInt(str.getSrcString().trim()));
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.