Charj: initial collection of class field types
authorAaron Becker <akbecker@gmail.com>
Tue, 25 May 2010 23:25:03 +0000 (18:25 -0500)
committerAaron Becker <akbecker@gmail.com>
Tue, 25 May 2010 23:25:03 +0000 (18:25 -0500)
src/langs/charj/src/charj/translator/Charj.stg
src/langs/charj/src/charj/translator/ClassSymbol.java

index ed7140bb163b6d7314bce7563c355921608cc47a..1e8e8be515c4b3d6d2949f971d99451d636a668b 100644 (file)
@@ -58,6 +58,7 @@ interfaceExtends(ts) ::=
 classDeclaration_h(sym, ident, ext, csds) ::=
 <<
 <sym.IncludeString>
+<sym.MemberTypeNames:{name| class <name>; separator = "\n"}>
 <classDeclaration_h_cont(pds = sym.packageNames, sym = sym, ident = ident, ext = ext, csds = csds)>
 >>
 
index 297e39c8d92f38a782b95d02ca8b77410f576668..0c9ab1be068d3eed89872fe66b94b8acf664bcd7 100644 (file)
@@ -198,7 +198,7 @@ public class ClassSymbol extends SymbolWithScope implements Scope {
             parent = scope.getFullyQualifiedName();
         }
         if ( parent!=null ) {
-            return parent+"."+name;
+            return parent+"::"+name;
         }
         return name;
     }
@@ -226,6 +226,27 @@ public class ClassSymbol extends SymbolWithScope implements Scope {
         return list;
     }
 
+    private Set<ClassSymbol> getMemberTypes()
+    {
+        Set<ClassSymbol> types = new HashSet<ClassSymbol>();
+        for (Map.Entry<String, VariableSymbol> entry : fields.entrySet()) {
+            types.add(((VariableSymbol)entry.getValue()).type);
+        }
+        return types;
+    }
+
+    public List<String> getMemberTypeNames()
+    {
+        System.out.println("Looking for type names...");
+        System.out.println("Found " + fields.size() + " fields...");
+        List<String> names = new ArrayList<String>();
+        for (ClassSymbol c : getMemberTypes()) {
+            names.add(c.getFullyQualifiedName());
+            System.out.println("Found type " + c.getFullyQualifiedName());
+        }
+        return names;
+    }
+
     public String getName()
     {
         return name;