// gentracevis.beh -- generate code for TraceVisitor. // $Id: gentracevis.beh,v 1.1 1998/03/11 22:28:00 dougo Exp $ Program { /** Add a "TraceVisitor" class to the set of class definitions. Don't call this until after buildClassDefTable()! */ void addTraceVisitor(String name) (@ addClassDef(ClassDef.parse("notparsed visitor " + name + " = int.")); @) /** Generate the behavior file for TraceVisitor. */ void generateTraceVisitor(String name, File file) = allParts { before Program (@ host.openOutputFile(file); Program.out.println(host.genericOutputVisitorPreamble(name)); @) (@ ClassName classname; @) before ClassDef (@ classname = host.get_classname(); Program.out.println(classname.makeBefore( " out.println(\"before " + classname + "\");\n" +" indent++;\n" +" for (int i = 0; i < indent; i++) out.print(\" \");\n")); Program.out.println(classname.makeAfter( " out.println(\"after " + classname + "\");\n" +" indent--;\n" +" for (int i = 0; i < indent; i++) out.print(\" \");\n")); @) before Part (@ String part = "-> " + classname + ", " + host.get_partname() + ", " + host.get_classname(); Program.out.println(host.makeBefore(classname, " out.println(\"before " + part + " \");\n" +" indent++;\n" +" for (int i = 0; i < indent; i++) out.print(\" \");\n")); Program.out.println(host.makeAfter(classname, " out.println(\"after " + part + " \");\n" +" indent--;\n" +" for (int i = 0; i < indent; i++) out.print(\" \");\n")); @) after Program (@ Program.out.println("}"); host.closeOutputFile(); @) } }