Commit dbae91b4 authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

cherry-pick 271122318

parent 92f98cf6
......@@ -352,26 +352,42 @@ aspect Java_Class {
env.println("/* ");
pp(env.getPrintStream());
// temporary experiment with listing user type dependencies
// This should generate actual register(...) code
if( !references().isEmpty() ) {
Iterator<Decl> it = references().iterator();
while(it.hasNext()) {
Decl t = it.next();
env.println(" //Depends (directly) on "+t.getName() + " (" + t +") " );
//TODO: traverse AST to find indirect dependencies
Iterator<Decl> iit = t.references().iterator();
while(iit.hasNext()) {
Decl tt = iit.next();
env.println(" //Depends (indirectly) on "+tt.getName() + " (" + tt +") " );
}
}
} else {
env.println(" //no user type dependencies ");
}
Java_emitUserTypeDeps(env, null, false);
env.println("*/");
}
public void Decl.Java_emitUserTypeDeps(Java_env env, String via, boolean outputCode) {
if( !references().isEmpty() ) {
Iterator<Decl> it = references().iterator();
while(it.hasNext()) {
Decl t = it.next();
t.Java_emitUserTypeDeps(env, t.getName(), outputCode);
if(outputCode) {
env.println(t.getName()+".register(e);");
} else { // Just output a comment
String refpath = (via == null) ? "directly" : "indirectly via "+via;
//env.println(" //Depends ("+refpath+") on "+t.getName() + " (" + t +") " );
env.println(" //Depends ("+refpath+") on "+t.getName() );
}
}
}
// else {
// env.println(" //no more deps ");
// }
}
public void Decl.Java_emitRegisterEncoder(Java_env env) {
env.println("public static void register(Encoder e) throws IOException {");
env.indent();
Java_emitUserTypeDeps(env, null, false); //XXX false -> generate no code
env.println("e.register(new Dispatcher());");
env.unindent();
env.println("}");
env.println();
}
public void TypeDecl.Java_emitClass(Java_env env, String pack) {
Java_emitDeclPP(env);
......@@ -444,27 +460,7 @@ aspect Java_Class {
env.println("}");
env.println();
env.println("public static void register(Encoder e) throws IOException {");
env.indent();
if( !references().isEmpty() ) {
Iterator<Decl> it = references().iterator();
while(it.hasNext()) {
Decl t = it.next();
env.println(" //Depends (directly) on "+t.getName() + " (" + t +") " );
Iterator<Decl> iit = t.references().iterator();
while(iit.hasNext()) {
Decl tt = iit.next();
env.println(" //Depends (indirectly) on "+tt.getName() + " (" + tt +") " );
}
}
} else {
env.println(" //no more deps ");
}
env.println("e.register(new Dispatcher());");
env.unindent();
env.println("}");
env.println();
Java_emitRegisterEncoder(env);
env.println("private static class Dispatcher implements SampleDispatcher {");
env.indent();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment