From: bdemsky Date: Fri, 15 Apr 2011 04:51:48 +0000 (+0000) Subject: changes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7947f56e2dd6932e200e675c43f452a4ab6c4fa5;p=IRC.git changes --- diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index cd514fe4..a981d9de 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -143,20 +143,7 @@ public class BuildCode { /* Output Structures */ outputStructs(outstructs); - // Output the C class declarations - // These could mutually reference each other - - outglobaldefs.println("#ifndef __GLOBALDEF_H_"); - outglobaldefs.println("#define __GLOBALDEF_H_"); - outglobaldefs.println(""); - outglobaldefs.println("struct global_defs_t {"); - outglobaldefs.println(" int size;"); - outglobaldefs.println(" void * next;"); - outglobaldefs.println(" struct ArrayObject * classobjs;"); - outglobaldefsprim.println("#ifndef __GLOBALDEFPRIM_H_"); - outglobaldefsprim.println("#define __GLOBALDEFPRIM_H_"); - outglobaldefsprim.println(""); - outglobaldefsprim.println("struct global_defsprim_t {"); + initOutputGlobals(outglobaldefs, outglobaldefsprim); outclassdefs.println("#ifndef __CLASSDEF_H_"); outclassdefs.println("#define __CLASSDEF_H_"); @@ -172,20 +159,8 @@ public class BuildCode { outclassdefs.println("#include \"globaldefsprim.h\""); outclassdefs.println("#endif"); outclassdefs.close(); - - outglobaldefs.println("};"); - outglobaldefs.println(""); - outglobaldefs.println("extern struct global_defs_t * global_defs_p;"); - outglobaldefs.println("#endif"); - outglobaldefs.flush(); - outglobaldefs.close(); - outglobaldefsprim.println("};"); - outglobaldefsprim.println(""); - outglobaldefsprim.println("extern struct global_defsprim_t * global_defsprim_p;"); - outglobaldefsprim.println("#endif"); - outglobaldefsprim.flush(); - outglobaldefsprim.close(); + finalOutputGlobals(outglobaldefs, outglobaldefsprim); if (state.TASK) { /* Map flags to integers */ @@ -203,7 +178,6 @@ public class BuildCode { outputTaskTypes(outtask); } - // an opportunity for subclasses to do extra // initialization preCodeGenInitialization(); @@ -214,10 +188,7 @@ public class BuildCode { State.logEvent("End outputMethods"); // opportunity for subclasses to gen extra code - additionalCodeGen(outmethodheader, - outstructs, - outmethod); - + additionalCodeGen(outmethodheader, outstructs, outmethod); if (state.TASK) { /* Output code for tasks */ @@ -249,12 +220,42 @@ public class BuildCode { outstructs.println("#endif"); outstructs.close(); - - postCodeGenCleanUp(); State.logEvent("End of buildCode"); } + protected void initOutputGlobals(PrintWriter outglobaldefs, PrintWriter outglobaldefsprim) { + // Output the C class declarations + // These could mutually reference each other + outglobaldefs.println("#ifndef __GLOBALDEF_H_"); + outglobaldefs.println("#define __GLOBALDEF_H_"); + outglobaldefs.println(""); + outglobaldefs.println("struct global_defs_t {"); + outglobaldefs.println(" int size;"); + outglobaldefs.println(" void * next;"); + outglobaldefs.println(" struct ArrayObject * classobjs;"); + outglobaldefsprim.println("#ifndef __GLOBALDEFPRIM_H_"); + outglobaldefsprim.println("#define __GLOBALDEFPRIM_H_"); + outglobaldefsprim.println(""); + outglobaldefsprim.println("struct global_defsprim_t {"); + } + + protected void finalOutputGlobals(PrintWriter outglobaldefs, PrintWriter outglobaldefsprim) { + outglobaldefs.println("};"); + outglobaldefs.println(""); + outglobaldefs.println("extern struct global_defs_t * global_defs_p;"); + outglobaldefs.println("#endif"); + outglobaldefs.flush(); + outglobaldefs.close(); + + outglobaldefsprim.println("};"); + outglobaldefsprim.println(""); + outglobaldefsprim.println("extern struct global_defsprim_t * global_defsprim_p;"); + outglobaldefsprim.println("#endif"); + outglobaldefsprim.flush(); + outglobaldefsprim.close(); + } + /* This method goes though the call graph and tag those methods that are * invoked inside static blocks */ @@ -1428,25 +1429,20 @@ public class BuildCode { fieldorder.put(cn,fields); Vector fieldvec=cn.getFieldVec(); + fldloop: for(int i=0; i