changes
authorbdemsky <bdemsky>
Mon, 28 Feb 2011 06:45:25 +0000 (06:45 +0000)
committerbdemsky <bdemsky>
Mon, 28 Feb 2011 06:45:25 +0000 (06:45 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/BuildCodeMGC.java

index 6b64d4e62e4aa8d4ce5b7673f1380a46ad9836b9..baf08966cec041b8c5662a8d662a9ec2f732ec1b 100644 (file)
@@ -287,7 +287,28 @@ public class BuildCode {
    * initialization.*/
   protected void outputStaticBlocks(PrintWriter outmethod) {
     //  execute all the static blocks and all the static field initializations
-    // TODO
+        // execute all the static blocks and all the static field initializations
+    SymbolTable sctbl = this.state.getSClassSymbolTable();
+    Iterator it_sclasses = sctbl.getDescriptorsIterator();
+    if(it_sclasses.hasNext()) {
+      outmethod.println("#define MGC_STATIC_INIT_CHECK");
+      while(it_sclasses.hasNext()) {
+        ClassDescriptor t_cd = (ClassDescriptor)it_sclasses.next();
+        MethodDescriptor t_md = (MethodDescriptor)t_cd.getMethodTable().get("staticblocks");
+        if(t_md != null) {
+          outmethod.println("   {");
+          if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+            outmethod.print("       struct "+t_cd.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"_params __parameterlist__={");
+            outmethod.println("0, NULL};");
+            outmethod.println("     "+t_cd.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"(& __parameterlist__);");
+          } else {
+            outmethod.println("     "+t_cd.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();");
+          }
+          outmethod.println("   }");
+        }
+      }
+      outmethod.println("#undef MGC_STATIC_INIT_CHECK");
+    }
   }
 
   /* This code generates code to create a Class object for each class for
@@ -295,7 +316,18 @@ public class BuildCode {
    * */
   protected void outputClassObjects(PrintWriter outmethod) {
     // for each class, initialize its Class object
-    // TODO
+    SymbolTable ctbl = this.state.getClassSymbolTable();
+    for(Iterator it_classes = ctbl.getDescriptorsIterator();it_classes.hasNext();) {
+      ClassDescriptor t_cd = (ClassDescriptor)it_classes.next();
+      outmethod.println(" {");
+      if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+       outmethod.println("    struct garbagelist dummy={0,NULL};");
+       outmethod.println("    global_defs_p->"+t_cd.getSafeSymbol()+"classobj = allocate_new(&dummy, " + typeutil.getClass(TypeUtil.ObjectClass).getId() + ");");
+      } else 
+       outmethod.println("    global_defs_p->"+t_cd.getSafeSymbol()+"classobj = allocate_new("+typeutil.getClass(TypeUtil.ObjectClass).getId() + ");");
+      outmethod.println("    global_defs_p->"+t_cd.getSafeSymbol()+"classobj->type = " + t_cd.getId() + ";");
+      outmethod.println(" }");
+    }
   }
 
   /* This code just generates the main C method for java programs.
index 6931f85f88e1bcc423034f5d962925e070d756c2..b00f1750bb11e59d43800259429bd267a9b1f9f5 100644 (file)
@@ -187,31 +187,6 @@ public class BuildCodeMGC extends BuildCode {
     outmethod.println("}");
   }
   
-  protected void outputStaticBlocks(PrintWriter outmethod) {
-    // execute all the static blocks and all the static field initializations
-    SymbolTable sctbl = this.state.getSClassSymbolTable();
-    Iterator it_sclasses = sctbl.getDescriptorsIterator();
-    if(it_sclasses.hasNext()) {
-      outmethod.println("#define MGC_STATIC_INIT_CHECK");
-      while(it_sclasses.hasNext()) {
-        ClassDescriptor t_cd = (ClassDescriptor)it_sclasses.next();
-        MethodDescriptor t_md = (MethodDescriptor)t_cd.getMethodTable().get("staticblocks");
-        if(t_md != null) {
-          outmethod.println("   {");
-          if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
-            outmethod.print("       struct "+t_cd.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"_params __parameterlist__={");
-            outmethod.println("1, NULL};");
-            outmethod.println("     "+t_cd.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"(& __parameterlist__);");
-          } else {
-            outmethod.println("     "+t_cd.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();");
-          }
-          outmethod.println("   }");
-        }
-      }
-      outmethod.println("#undef MGC_STATIC_INIT_CHECK");
-    }
-  }
-  
   protected void outputClassObjects(PrintWriter outmethod) {
     // for each class, initialize its Class object
     if(state.MGC) {