Package wyil.lang

Examples of wyil.lang.Type$Record$State


  public Nominal.FunctionOrMethod expandAsFunctionOrMethod(Nominal lhs)
      throws IOException, ResolveError {
    Type.FunctionOrMethod raw = Type.effectiveFunctionOrMethod(lhs.raw());
    if (raw != null) {
      Type nominal = expandOneLevel(lhs.nominal());
      if (!(nominal instanceof Type.FunctionOrMethod)) {
        nominal = raw; // discard nominal information
      }
      return (Nominal.FunctionOrMethod) Nominal.construct(nominal, raw);
    } else {
View Full Code Here


      Type.Nominal nt = (Type.Nominal) type;
      NameID nid = nt.name();
      Path.ID mid = nid.module();

      WhileyFile wf = builder.getSourceFile(mid);
      Type r = null;

      if (wf != null) {
        WhileyFile.Declaration decl = wf.declaration(nid.name());
        if (decl instanceof WhileyFile.Type) {
          WhileyFile.Type td = (WhileyFile.Type) decl;
View Full Code Here

  @Test public void test_2498() { checkNotSubtype("[int]|int","any"); }
  @Test public void test_2499() { checkNotSubtype("[int]|int","[null]|null"); }
  @Test public void test_2500() { checkIsSubtype("[int]|int","[int]|int"); }

  private void checkIsSubtype(String from, String to) {
    Type ft = Type.fromString(from);
    Type tt = Type.fromString(to);
    assertTrue(Type.isSubtype(ft,tt));
  }
View Full Code Here

    Type ft = Type.fromString(from);
    Type tt = Type.fromString(to);
    assertTrue(Type.isSubtype(ft,tt));
  }
  private void checkNotSubtype(String from, String to) {
    Type ft = Type.fromString(from);
    Type tt = Type.fromString(to);
    assertFalse(Type.isSubtype(ft,tt));
  }
View Full Code Here

  @Test public void test_5774() { checkNotSubtype("{int f2}|int","{null f2}|null"); }
  @Test public void test_5775() { checkNotSubtype("{int f2}|int","{int f1}|int"); }
  @Test public void test_5776() { checkIsSubtype("{int f2}|int","{int f2}|int"); }

  private void checkIsSubtype(String from, String to) {
    Type ft = Type.fromString(from);
    Type tt = Type.fromString(to);
    assertTrue(Type.isSubtype(ft,tt));
  }
View Full Code Here

    Type ft = Type.fromString(from);
    Type tt = Type.fromString(to);
    assertTrue(Type.isSubtype(ft,tt));
  }
  private void checkNotSubtype(String from, String to) {
    Type ft = Type.fromString(from);
    Type tt = Type.fromString(to);
    assertFalse(Type.isSubtype(ft,tt));
  }
View Full Code Here

  public Type parse() {
    return parse(new HashSet<String>());
  }

  public Type parse(HashSet<String> typeVariables) {
    Type term = parseFunctionTerm(typeVariables);
    skipWhiteSpace();
    while (index < str.length()
        && (str.charAt(index) == '|')) {
      // union type
      match("|");
View Full Code Here

    }
    return term;
  }

  public Type parseFunctionTerm(HashSet<String> typeVariables) {
    Type t = parseNotTerm(typeVariables);
    if(index >= str.length()) { return t; }
    char lookahead = str.charAt(index);
    if(lookahead == '(') {
      // this is a tuple, not a bracketed type.
      match("(");
View Full Code Here

  public Type parseBraceTerm(HashSet<String> typeVariables) {
    skipWhiteSpace();
    char lookahead = str.charAt(index);
    if(lookahead == '(') {
      match("(");
      Type t = parse(typeVariables);
      skipWhiteSpace();
      lookahead = str.charAt(index);
      if(lookahead == ',') {
        // this is a tuple, not a bracketed type.
        ArrayList<Type> elems = new ArrayList();
View Full Code Here

      match("string");
      return T_STRING;
    case '[':
    {
      match("[");
      Type elem = parse(typeVariables);
      match("]");
      return List(elem, false);
    }
    case '{':
    {
      match("{");
      Type elem = parse(typeVariables);
      skipWhiteSpace();
      if(index < str.length() && str.charAt(index) == '-') {
        // dictionary
        match("->");
        Type value = parse(typeVariables);
        match("}");
        return Map(elem,value);

      } else if(index < str.length() && str.charAt(index) != '}') {
        // record
        HashMap<String,Type> fields = new HashMap<String,Type>();
        String id = parseIdentifier();
        fields.put(id, elem);
        skipWhiteSpace();
        boolean isOpen = false;
        while(index < str.length() && str.charAt(index) == ',') {
          match(",");
          if(str.charAt(index) == '.') {
            match("...");
            isOpen=true;
            break;
          }
          elem = parse(typeVariables);
          id = parseIdentifier();
          fields.put(id, elem);
          skipWhiteSpace();
        }
        match("}");
        return Record(isOpen,fields);
      }
      match("}");
      return Set(elem,false);
    }
    default:
    {
      String typeVariable = parseIdentifier();
      if(typeVariables.contains(typeVariable)) {
        return Nominal(new NameID(Trie.fromString("$"),
            typeVariable));
      } else {
        typeVariables = new HashSet<String>(typeVariables);
        typeVariables.add(typeVariable);
        match("<");
        Type t = parse(typeVariables);
        match(">");
        NameID label = new NameID(Trie.fromString("$"),
            typeVariable);
        return Recursive(label, t);
      }
View Full Code Here

TOP

Related Classes of wyil.lang.Type$Record$State

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.