Ejemplo n.º 1
0
  protected void outputDelegatingForCase(
      NodeType t,
      TabPrintWriter writer,
      NodeType root,
      String retType,
      String suff,
      String defaultMethod) {
    outputForCaseHeader(t, writer, retType, suff);
    writer.indent();

    if (!retType.equals("void")) {
      writer.startLine("return ");
    } else {
      writer.startLine();
    }

    Option<NodeType> sup = ast.parent(t);
    if (sup.isSome() && !t.equals(root)) {
      writer.print(visitorMethodName(sup.unwrap()) + suff + "(that);");
    } else {
      writer.print(defaultMethod + "(that);");
    }
    writer.unindent();
    writer.startLine("}");
    writer.println();
  }
Ejemplo n.º 2
0
 protected void outputAbstractVisitorCases(NodeType root, TabPrintWriter writer, String retType) {
   // Write out case methods for each concrete class
   for (NodeType t : ast.descendents(root)) {
     if (!t.isAbstract()) {
       writer.println();
       writer.startLine("/** Process an instance of " + t.name() + ". */");
       writer.startLine(
           "public abstract " + retType + " " + visitorMethodName(t) + "(" + t.name() + " that);");
     }
   }
 }