Charj: add facility for gathering up needed include file dependencies
authorAaron Becker <akbecker@gmail.com>
Fri, 21 May 2010 22:02:19 +0000 (17:02 -0500)
committerAaron Becker <akbecker@gmail.com>
Fri, 21 May 2010 22:02:19 +0000 (17:02 -0500)
src/langs/charj/src/charj/translator/Charj.stg
src/langs/charj/src/charj/translator/ClassSymbol.java

index d0c6b24e7300c8624fb7f366e77cabdf7f6234ea..9370053d1a3f5a05bb06a552abab30ad7b67c017 100644 (file)
@@ -73,6 +73,7 @@ interfaceExtends(ts) ::=
 
 classDeclaration_h(sym, ident, ext, csds) ::=
 <<
+<sym.IncludeString>
 <sym.NamespaceOpeningString>
 <if(ext)>
 class <ident> : public <ext> {
index c5e5835fd9cc1f24f922f6d39630ddb6082db4e1..676197a8d4c74d5974c0e8c30661725b9e0a7d40 100644 (file)
@@ -10,6 +10,7 @@ public class ClassSymbol extends SymbolWithScope implements Scope {
 
     Map<String, PackageScope> imports = 
         new LinkedHashMap<String, PackageScope>();
+    List<String> includes = new ArrayList<String>();
 
     /** List of all fields and methods */
     public Map<String, Symbol> members = new LinkedHashMap<String, Symbol>();
@@ -243,6 +244,18 @@ public class ClassSymbol extends SymbolWithScope implements Scope {
         return name;
     }
 
+    public void addInclude(String includeName) {
+        includes.add(includeName);
+    }
+
+    public String getIncludeString() {
+        String includeString = "";
+        for (String include : includes) {
+            includeString += "#include<" + include + ">\n";
+        }
+        return includeString;
+    }
+
     public String getNamespaceOpeningString() {
         Scope currentScope = scope;
         String namespace = "";