예제 #1
0
 /**
  * Returns a string of the modules in the compile stack, beginning with the the specified module
  * and ending with the module at the top of the stack. The modules have arrows between them to
  * indicate dependencies. This method is used when reporting a circular module dependency error.
  */
 public String printStackPath(ModuleID id) {
   StringBuffer sb = new StringBuffer();
   Stack<ModuleID> stack2 = new Stack<ModuleID>();
   boolean printID = false;
   ModuleID id2 = null;
   while (!stack.isEmpty()) {
     id2 = stack.pop();
     stack2.push(id2);
   }
   sb.append("(");
   while (!stack2.isEmpty()) {
     id2 = stack2.pop();
     if (id2 == id) {
       printID = true;
     }
     if (printID) {
       sb.append(id2.toString());
       if (!stack2.isEmpty()) {
         sb.append(" -> ");
       }
     }
     stack.push(id2);
   }
   sb.append(")");
   return sb.toString();
 }
예제 #2
0
  /**
   * Constructs a record containing the module id, the file, and the module dec, and places it in
   * the module environment. Also places the module into a stack that indicates compilation has
   * begun on this module but has not completed.
   */
  public void constructRecord(ModuleID id, File file, ModuleDec dec) {
    ModuleRecord record = new ModuleRecord(id, file);
    record.setModuleDec(dec);
    assert !map.containsKey(id) : "map already contains key";
    assert !fmap.containsKey(file) : "fmap already contains file";
    map.put(id, record);
    fmap.put(file, id);
    stack.push(id);

    if (!debugOff) {
      err.message("Construct record: " + id.toString()); // DEBUG
    }
  }