Package wyvern.tools.types

Examples of wyvern.tools.types.Environment.extend()


    env = env.extend(new TypeBinding("Bool", Bool.getInstance()));
    env = env.extend(new TypeBinding("Str", Str.getInstance()));
   
    env = env.extend(new ValueBinding("null", UnitVal.getInstance(FileLocation.UNKNOWN))); // How to represent  shock/horror  null!?
    env = env.extend(new ValueBinding("true", new BooleanConstant(true)));
    env = env.extend(new ValueBinding("false", new BooleanConstant(false)));
   
    env = env.extend(new ValueBinding("print", new ExternalFunction(arrow(str, unit), (env1, argument) -> {
      System.out.println(((StringConstant)argument).getValue());
      return UnitVal.getInstance(FileLocation.UNKNOWN); // Fake line number! FIXME:
    })));
View Full Code Here


   
    env = env.extend(new ValueBinding("null", UnitVal.getInstance(FileLocation.UNKNOWN))); // How to represent  shock/horror  null!?
    env = env.extend(new ValueBinding("true", new BooleanConstant(true)));
    env = env.extend(new ValueBinding("false", new BooleanConstant(false)));
   
    env = env.extend(new ValueBinding("print", new ExternalFunction(arrow(str, unit), (env1, argument) -> {
      System.out.println(((StringConstant)argument).getValue());
      return UnitVal.getInstance(FileLocation.UNKNOWN); // Fake line number! FIXME:
    })));
    env = env.extend(new ValueBinding("printInteger", new ExternalFunction(arrow(integer, unit), (env1, argument) -> {
      System.out.println(((IntegerConstant)argument).getValue());
View Full Code Here

   
    env = env.extend(new ValueBinding("print", new ExternalFunction(arrow(str, unit), (env1, argument) -> {
      System.out.println(((StringConstant)argument).getValue());
      return UnitVal.getInstance(FileLocation.UNKNOWN); // Fake line number! FIXME:
    })));
    env = env.extend(new ValueBinding("printInteger", new ExternalFunction(arrow(integer, unit), (env1, argument) -> {
      System.out.println(((IntegerConstant)argument).getValue());
      return UnitVal.getInstance(FileLocation.UNKNOWN); // Fake line number! FIXME:
    })));
    return env;
  }
View Full Code Here

    bindings = newBindings;


    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

     
      if (b instanceof AssignableNameBinding) {
        //Indicates that there is a settable value
        String name = b.getName();
        Type type = b.getType();
        tev = tev.extend(
            new NameBindingImpl("set" + name.substring(0,1).toUpperCase() + name.substring(1),
            new Arrow(type, Unit.getInstance())));
        continue;
      }
View Full Code Here

        continue;
      }

      if (b instanceof TypeBinding) {
        if (b.getType() instanceof TypeType) {
          tev = tev.extend(b);
          continue;
        }
        if (b.getType() instanceof ClassType) {
          TypeType tt = ((ClassType) b.getType()).getEquivType();
          tev = tev.extend(new NameBindingImpl(b.getName(), tt));
View Full Code Here

          tev = tev.extend(b);
          continue;
        }
        if (b.getType() instanceof ClassType) {
          TypeType tt = ((ClassType) b.getType()).getEquivType();
          tev = tev.extend(new NameBindingImpl(b.getName(), tt));
          continue;
        }
        continue;
      }
View Full Code Here

  }

  public MetadataInnerBinding from(Environment env) {
    Environment oldEnv = env.lookupBinding("metaVal", MetadataInnerBinding.class)
        .map(MetadataInnerBinding::getInnerEnv).orElse(Environment.getEmptyEnvironment());
    return new MetadataInnerBinding(new Reference<>(() -> oldEnv.extend(innerEnv.get())));
  }

  @Override
  public String getName() {
    return "metaEnv";
View Full Code Here

      // TODO: implement multiple args
      throw new RuntimeException("tuple args not implemented");
   
    Environment extEnv = env;
    for (NameBinding bind : bindings) {
      extEnv = extEnv.extend(bind);
    }

    Type resultType = body.typecheck(extEnv, expected.map(exp -> ((Arrow)exp).getResult()));
    return new Arrow(argType, resultType);
  }
View Full Code Here

      for (Declaration decl : decls.getDeclIterator()) {
        TypeBinding binding = new TypeBinding(nameBinding.getName(), getObjectType());
        if (decl.isClassMember()) {
          decl.typecheckSelf(genv.extend(binding));
        } else {
          decl.typecheckSelf(oenv.extend(binding));
        }
      }
    }
   
    // check the implements and class implements
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.