Permalink
Browse files

Fixed class ordering bug

  • Loading branch information...
1 parent 1bb0b5f commit 9d8b56e2f37217d275a64258b9cfab78677f5830 thomashuston committed Dec 18, 2011
Showing with 5 additions and 3 deletions.
  1. +1 −2 src/pcp/translator/JavaFile.java
  2. +4 −1 src/pcp/translator/JavaPackage.java
@@ -170,7 +170,7 @@ public void orderClasses() {
private void order(JavaClass cls) {
if (allClasses.contains(cls))
return;
- if (cls.hasParent())
+ if (cls.hasParent() && cls.getParent().getFile() == this)
order(cls.getParent());
allClasses.add(cls);
}
@@ -263,7 +263,6 @@ public void visitPackageDeclaration(GNode n) {
* @return The output stream.
*/
public Printer translate(Printer out) {
- orderClasses();
for (JavaClass cls : allClasses) {
cls.translate(out).pln();
}
@@ -300,6 +300,7 @@ public Printer translateHeader(Printer out) {
// Declare the class structs
for (JavaFile file : files) {
+ file.orderClasses();
for (JavaClass cls : file.getClasses()) {
String className = cls.getName();
out.indent().p("struct __").p(className).pln(";");
@@ -352,7 +353,9 @@ public Printer translate(Printer out) {
// Print all the files in the package
for (JavaFile f : files) {
- f.translate(out);
+ for (JavaClass cls : f.getClasses()) {
+ cls.translate(out).pln();
+ }
out.pln();
}

0 comments on commit 9d8b56e

Please sign in to comment.