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
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
LabComm
Commits
046d7a95
Commit
046d7a95
authored
10 years ago
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
cherry-pick 7f014efd9
parent
415a7153
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
compiler/Java_CodeGen.jrag
+23
-29
23 additions, 29 deletions
compiler/Java_CodeGen.jrag
compiler/TypeReferences.jrag
+35
-0
35 additions, 0 deletions
compiler/TypeReferences.jrag
with
58 additions
and
29 deletions
compiler/Java_CodeGen.jrag
+
23
−
29
View file @
046d7a95
...
...
@@ -320,27 +320,6 @@ aspect Java_Register {
}
}
aspect User_Types {
syn String Type.getTypeName();
eq Type.getTypeName() = getClass().getName();
eq PrimType.getTypeName() = getName();
eq UserType.getTypeName() = getName();
syn boolean Type.isUserType();
eq Type.isUserType() = false;
eq UserType.isUserType() = true;
coll Set<Decl> Decl.references() [new HashSet<Decl>()] with add;
Field contributes ((UserType)getType()).decl()
when parentDecl() != null && getType().isUserType()
to Decl.references()
for parentDecl();
syn boolean Decl.hasReferences();
eq Decl.hasReferences() = !references().isEmpty();
}
aspect Java_Class {
...
...
@@ -356,13 +335,14 @@ aspect Java_Class {
pp(env.getPrintStream());
Java_emitUserTypeDeps(env, null, false);
Java_emitUserTypeRefs(env, null, false);
env.println("*/");
}
public void Decl.Java_emitUserTypeDeps(Java_env env, String via, boolean outputCode) {
if( has
Refer
ences() ) {
Iterator<Decl> it =
refer
ences().iterator();
if( has
Depend
enc
i
es() ) {
Iterator<Decl> it =
type_depend
enc
i
es().iterator();
while(it.hasNext()) {
Decl t = it.next();
...
...
@@ -376,10 +356,24 @@ aspect Java_Class {
}
}
}
// else {
// env.println(" //no more deps ");
// }
}
public void Decl.Java_emitUserTypeRefs(Java_env env, String via, boolean outputCode) {
if( isReferenced() ) {
Iterator<Decl> it = type_references().iterator();
while(it.hasNext()) {
Decl t = it.next();
t.Java_emitUserTypeRefs(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(" //Is referenced by ("+refpath+") on "+t.getName() );
}
}
}
}
public void Decl.Java_emitRegisterEncoder(Java_env env) {
env.println("public static void register(Encoder e) throws IOException {");
...
...
@@ -403,19 +397,19 @@ aspect Java_Class {
env.println("import java.io.IOException;");
env.println("import se.lth.control.labcomm"+env.verStr+".Decoder;");
}
if (getType().Java_needInstance() || has
Refer
ences()) {
if (getType().Java_needInstance() || has
Depend
enc
i
es()) {
env.println("import se.lth.control.labcomm"+env.verStr+".Encoder;");
env.println();
}
// For types without
refer
ences and not needing an instance,
// For types without
type_depend
enc
i
es and not needing an instance,
// currently just an empty class is generated
env.println("public class " + getName() + " implements SampleType {");
env.println();
env.indent();
if(hasReference
s
()) {
if(has
Dependencies() || is
Reference
d
()) {
// XXX Java_emitRegisterEncoder(env);
// XXX Java_emitDispatcher(env, false);
}
...
...
This diff is collapsed.
Click to expand it.
compiler/TypeReferences.jrag
0 → 100644
+
35
−
0
View file @
046d7a95
aspect User_Types {
syn String Type.getTypeName();
eq Type.getTypeName() = getClass().getName();
eq PrimType.getTypeName() = getName();
eq UserType.getTypeName() = getName();
syn boolean Type.isUserType();
eq Type.isUserType() = false;
eq UserType.isUserType() = true;
}
aspect Type_References {
// The dependencies on other type declarations for a Decl.
coll Set<Decl> Decl.type_dependencies() [new HashSet<Decl>()] with add;
Field contributes ((UserType)getType()).decl()
when parentDecl() != null && getType().isUserType()
to Decl.type_dependencies()
for parentDecl();
// The references from other type declarations to a Decl.
coll Set<Decl> Decl.type_references() [new HashSet<Decl>()] with add;
Decl contributes this
to Decl.type_references()
for each type_dependencies();
syn boolean Decl.hasDependencies();
eq Decl.hasDependencies() = !type_dependencies().isEmpty();
syn boolean Decl.isReferenced();
eq Decl.isReferenced() = !type_references().isEmpty();
}
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