Package wycc.lang

Examples of wycc.lang.NameID


    if (names.size() == 1) {
      return resolveAsName(names.get(0), context);
    } else if (names.size() == 2) {
      String name = names.get(1);
      Path.ID mid = resolveAsModule(names.get(0), context);
      NameID nid = new NameID(mid, name);
      if (builder.isName(nid)) {
        if (isNameVisible(nid, context)) {
          return nid;
        } else {
          throw new ResolveError(nid + " is not visible");
        }
      }
    } else {
      String name = names.get(names.size() - 1);
      String module = names.get(names.size() - 2);
      Path.ID pkg = Trie.ROOT;
      for (int i = 0; i != names.size() - 2; ++i) {
        pkg = pkg.append(names.get(i));
      }
      Path.ID mid = pkg.append(module);
      NameID nid = new NameID(mid, name);
      if (builder.isName(nid)) {
        if (isNameVisible(nid, context)) {
          return nid;
        } else {
          throw new ResolveError(nid + " is not visible");
View Full Code Here


      // what module that is here, and save it for future use.
      // Furthermore, we need to determine whether the name is visible
      // (i.e. non-private) and/or whether the body of the type is visible
      // (i.e. non-protected).
      SyntacticType.Nominal dt = (SyntacticType.Nominal) type;
      NameID nid;
      try {
        // Determine the full qualified name of this nominal type. This
        // will additionally ensure that the name is visible
        nid = resolveAsName(dt.names, context);
View Full Code Here

            qualifications.add(n);
          }
        }
        qualifications.add(c.name);
        try {
          NameID nid = resolveAsName(qualifications, context);
          return resolveAsConstant(nid, visited);
        } catch (ResolveError e) {
          syntaxError(errorMessage(UNKNOWN_VARIABLE), context, expr);
          return null;
        }
View Full Code Here

  }

  private Type expandOneLevel(Type type) throws IOException, ResolveError {
    if (type instanceof Type.Nominal) {
      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;
          r = resolveAsType(td.pattern.toSyntacticType(), td)
              .nominal();
        }
      } else {
        WyilFile m = builder.getModule(mid);
        WyilFile.TypeDeclaration td = m.type(nid.name());
        if (td != null) {
          r = td.type();
        }
      }
      if (r == null) {
View Full Code Here

    //System.out.println("!" + from + " & !" + to + " = "
    //    + intersect(Type.Negation(from), Type.Negation(to)));
  }

  public static Type linkedList(int n) {
    NameID label = new NameID(Trie.fromString(""),"X");
    return Recursive(label,innerLinkedList(n));
  }
View Full Code Here

    return Recursive(label,innerLinkedList(n));
  }

  public static Type innerLinkedList(int n) {
    if(n == 0) {
      return Nominal(new NameID(Trie.fromString(""),"X"));
    } else {
      Type leaf = Reference(innerLinkedList(n-1));
      HashMap<String,Type> fields = new HashMap<String,Type>();
      fields.put("next", Union(T_NULL,leaf));
      fields.put("data", T_BOOL);
View Full Code Here

    public Automaton.State readState() throws IOException {
      Automaton.State state = super.readState();
      if (state.kind == Type.K_NOMINAL) {
        String module = readString();
        String name = readString();
        state.data = new NameID(Trie.fromString(module), name);
      } else if(state.kind == Type.K_RECORD) {
        boolean isOpen = reader.read_bit();
        int nfields = reader.read_uv();
        Record.State fields = new Record.State(isOpen);
        for(int i=0;i!=nfields;++i) {
View Full Code Here

    }

    public void write(Automaton.State state) throws IOException {
      super.write(state);
      if (state.kind == Type.K_NOMINAL) {
        NameID name = (NameID) state.data;
        writeString(name.module().toString());
        writeString(name.name());
      } else if(state.kind == Type.K_RECORD) {
        Record.State fields = (Record.State) state.data;
        writer.write_bit(fields.isOpen);
        writer.write_uv(fields.size());
        for(String field : fields) {
View Full Code Here

   */
  private WyilFile.TypeDeclaration generate(WhileyFile.Type td) throws Exception {
    Code.Block invariant = null;

    if(td.invariant != null) {
      NameID nid = new NameID(td.file().module,td.name());
      invariant = generate(nid);
    }

    return new WyilFile.TypeDeclaration(td.modifiers(), td.name(),
        td.resolvedType.raw(), invariant);
View Full Code Here

      return null;
    } else if (t instanceof SyntacticType.Nominal) {
      SyntacticType.Nominal dt = (SyntacticType.Nominal) t;

      try {
        NameID nid = resolver.resolveAsName(dt.names,context);
        Code.Block other = generate(nid);
        if(other != null) {
          Code.Block blk = new Code.Block(1);
          blk.addAll(other);
          return blk;
View Full Code Here

TOP

Related Classes of wycc.lang.NameID

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.