From 5aa8ae8815bcc36a81f4abdd601895749a313870 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 13 Mar 2006 18:54:22 +0000 Subject: [PATCH] more code --- Robust/src/IR/Flat/BuildCode.java | 156 ++++++++++++++++++++++- Robust/src/IR/Flat/FlatMethod.java | 30 +++++ Robust/src/IR/Flat/ParamsObject.java | 64 ++++++++++ Robust/src/IR/Flat/TempDescriptor.java | 6 +- Robust/src/IR/Flat/TempObject.java | 66 ++++++++++ Robust/src/IR/Tree/AssignmentNode.java | 5 + Robust/src/IR/Tree/MethodInvokeNode.java | 5 + Robust/src/IR/TypeDescriptor.java | 22 ++++ Robust/src/Main/Main.java | 2 +- 9 files changed, 349 insertions(+), 7 deletions(-) create mode 100644 Robust/src/IR/Flat/ParamsObject.java create mode 100644 Robust/src/IR/Flat/TempObject.java diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 996eb55d..4b3df19f 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1,29 +1,179 @@ package IR.Flat; import IR.*; import java.util.*; +import java.io.*; public class BuildCode { State state; Hashtable temptovar; + Hashtable paramstable; + Hashtable tempstable; + int tag=0; + private static final boolean GENERATEPRECISEGC=true; public BuildCode(State st, Hashtable temptovar) { state=st; this.temptovar=temptovar; + paramstable=new Hashtable(); + tempstable=new Hashtable(); } - + public void buildCode() { Iterator it=state.getClassSymbolTable().getDescriptorsIterator(); + PrintWriter outclassdefs=null; + PrintWriter outstructs=null; + PrintWriter outmethodheader=null; + try { + OutputStream str=new FileOutputStream("structdefs.h"); + outstructs=new java.io.PrintWriter(str, true); + str=new FileOutputStream("methodheaders.h"); + outmethodheader=new java.io.PrintWriter(str, true); + str=new FileOutputStream("classdefs.h"); + outclassdefs=new java.io.PrintWriter(str, true); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + outstructs.println("#include \"classdefs.h\""); + outmethodheader.println("#include \"structdefs.h\""); while(it.hasNext()) { ClassDescriptor cn=(ClassDescriptor)it.next(); - generateCallStructs(cn); + generateCallStructs(cn, outclassdefs, outstructs, outmethodheader); + } + outstructs.close(); + outmethodheader.close(); + } + + private void generateTempStructs(FlatMethod fm) { + MethodDescriptor md=fm.getMethod(); + ParamsObject objectparams=new ParamsObject(md,tag++); + paramstable.put(md, objectparams); + for(int i=0;i