println("        tmp = factory.makeList(elem, tmp);"); println("      }"); println("      this.term = tmp;"); println("    }"); println("    return this.term;"); println("  }"); println(); }
String head = "reversed.getHead()"; String termHead; if (!getConverter().isReserved(elementType)) { termHead = head + ".toTerm()"; } else { termHead = getConverter().makeBuiltinToATermConversion(elementType, head); } println("        aterm.ATerm elem = " + termHead + ";");  println("        tmp = factory.makeList(elem, tmp);"); println("      }"); println("      this.term = tmp;"); println("    }"); println("    return this.term;"); println("  }"); println(); }
    private void genToTerm() {        String getFactoryMethodName = buildFactoryGetter();        String className = TypeGenerator.className(type);        println("  public aterm.ATerm toTerm() {");        println(            "    aterm.ATermFactory factory = " + getFactoryMethodName + ".getPureFactory();");        println("    if (this.term == null) {");        println("      " + className + " reversed = (" + className + ")this.reverse();");        println("      aterm.ATermList tmp = factory.makeList();");        println("      for (; !reversed.isEmpty(); reversed = reversed.getTail()) {");                String head = "reversed.getHead()";        String termHead;        if (!getConverter().isReserved(elementType)) {            termHead = head + ".toTerm()";        } else {            termHead = getConverter().makeBuiltinToATermConversion(elementType, head);        }        println("        aterm.ATerm elem = " + termHead + ";");        println("        tmp = factory.makeList(elem, tmp);");        println("      }");        println("      this.term = tmp;");        println("    }");        println("    return this.term;");        println("  }");        println();    }