Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sven Gestegård Robertz
LabComm
Commits
dbae91b4
Commit
dbae91b4
authored
11 years ago
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
cherry-pick 271122318
parent
92f98cf6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
compiler/Java_CodeGen.jrag
+34
-38
34 additions, 38 deletions
compiler/Java_CodeGen.jrag
with
34 additions
and
38 deletions
compiler/Java_CodeGen.jrag
+
34
−
38
View file @
dbae91b4
...
...
@@ -352,25 +352,41 @@ aspect Java_Class {
env.println("/* ");
pp(env.getPrintStream());
// temporary experiment with listing user type dependencies
// This should generate actual register(...) code
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();
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 +") " );
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 user type dependencies ");
}
env.println("*/");
// 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) {
...
...
@@ -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();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment