Checking in changes that:
authorbdemsky <bdemsky>
Sat, 30 Oct 2004 01:13:26 +0000 (01:13 +0000)
committerbdemsky <bdemsky>
Sat, 30 Oct 2004 01:13:26 +0000 (01:13 +0000)
1) Generate C99 code instead of C++ code.  The code should still work with a C++ compiler.
2) PrintWrapper class to enable putting declarations at top of
functions so we can make old versions of gcc work.

30 files changed:
Repair/RepairCompiler/MCC/CRuntime/SimpleHash.c
Repair/RepairCompiler/MCC/CRuntime/SimpleHash.h
Repair/RepairCompiler/MCC/CRuntime/size.h
Repair/RepairCompiler/MCC/Compiler.java
Repair/RepairCompiler/MCC/IR/DotExpr.java
Repair/RepairCompiler/MCC/IR/ElementOfExpr.java
Repair/RepairCompiler/MCC/IR/ImageSetExpr.java
Repair/RepairCompiler/MCC/IR/LogicStatement.java
Repair/RepairCompiler/MCC/IR/MetaInclusion.java
Repair/RepairCompiler/MCC/IR/NaiveGenerator.java
Repair/RepairCompiler/MCC/IR/OpExpr.java
Repair/RepairCompiler/MCC/IR/PrintWrapper.java [new file with mode: 0755]
Repair/RepairCompiler/MCC/IR/RelationExpr.java
Repair/RepairCompiler/MCC/IR/RelationFunctionExpr.java
Repair/RepairCompiler/MCC/IR/RelationInclusion.java
Repair/RepairCompiler/MCC/IR/RelationQuantifier.java
Repair/RepairCompiler/MCC/IR/RepairGenerator.java
Repair/RepairCompiler/MCC/IR/SetExpr.java
Repair/RepairCompiler/MCC/IR/SetInclusion.java
Repair/RepairCompiler/MCC/IR/SetQuantifier.java
Repair/RepairCompiler/MCC/IR/SizeofFunction.java
Repair/RepairCompiler/MCC/IR/StructureGenerator.java
Repair/RepairCompiler/MCC/IR/SumExpr.java
Repair/RepairCompiler/MCC/IR/TupleOfExpr.java
Repair/RepairCompiler/MCC/IR/UpdateNode.java
Repair/RepairCompiler/MCC/IR/VarExpr.java
Repair/RepairCompiler/MCC/IR/WorkList.java
Repair/RepairCompiler/MCC/IR/WorklistGenerator.java
Repair/RepairCompiler/MCC/Makefile
Repair/RepairCompiler/MCC/Runtime/size.h

index b238c22541f0a3af2e844bee80ecb2fa0a34b1a2..187d70ffee5f28cb07d428ac9b4dc0e51d1460bc 100755 (executable)
@@ -151,11 +151,11 @@ void WorkListadd(struct WorkList *thisvar, int id,int type, int lvalue, int rval
 }
 
 /* SIMPLE HASH ********************************************************/
-struct SimpleIterator* createiterator(struct SimpleHash * thisvar) {
+struct SimpleIterator* SimpleHashcreateiterator(struct SimpleHash * thisvar) {
     return allocateSimpleIterator(thisvar->listhead,thisvar->listtail,thisvar->tailindex/*,thisvar*/);
 }
 
-void iterator(struct SimpleHash *thisvar, struct SimpleIterator * it) {
+void SimpleHashiterator(struct SimpleHash *thisvar, struct SimpleIterator * it) {
   it->cur=thisvar->listhead;
   it->index=0;
   it->tailindex=thisvar->tailindex;
@@ -453,11 +453,11 @@ void freeRepairHash(struct RepairHash *thisvar) {
 
 #define SETFLAG (1<<31)
 
-int addset(struct RepairHash *thisvar, int setv, int rule, int value, int data) {
-  return addrelation(thisvar, setv||SETFLAG, rule, value,0,data);
+int RepairHashaddset(struct RepairHash *thisvar, int setv, int rule, int value, int data) {
+  return RepairHashaddrelation(thisvar, setv||SETFLAG, rule, value,0,data);
 }
 
-int addrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue, int rvalue, int data) {
+int RepairHashaddrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue, int rvalue, int data) {
     unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
 
     struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
@@ -483,7 +483,7 @@ int addrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue,
     return 1;
 }
 
-int addrelation2(struct RepairHash *thisvar, int relation, int rule, int lvalue, int rvalue, int data, int data2) {
+int RepairHashaddrelation2(struct RepairHash *thisvar, int relation, int rule, int lvalue, int rvalue, int data, int data2) {
     unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
 
     struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
@@ -509,11 +509,11 @@ int addrelation2(struct RepairHash *thisvar, int relation, int rule, int lvalue,
     return 1;
 }
 
-bool containsset(struct RepairHash *thisvar, int setv, int rule, int value) {
-  return containsrelation(thisvar, setv||SETFLAG, rule, value,0);
+bool RepairHashcontainsset(struct RepairHash *thisvar, int setv, int rule, int value) {
+  return RepairHashcontainsrelation(thisvar, setv||SETFLAG, rule, value,0);
 }
 
-bool containsrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue, int rvalue) {
+bool RepairHashcontainsrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue, int rvalue) {
     unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
 
     struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
@@ -532,11 +532,11 @@ bool containsrelation(struct RepairHash *thisvar, int relation, int rule, int lv
     return false;
 }
 
-int getset(struct RepairHash *thisvar, int setv, int rule, int value) {
-  return getrelation(thisvar, setv||SETFLAG, rule, value,0);
+int RepairHashgetset(struct RepairHash *thisvar, int setv, int rule, int value) {
+  return RepairHashgetrelation(thisvar, setv||SETFLAG, rule, value,0);
 }
 
-int ismodify(struct RepairHash *thisvar, int relation, int rule, int lvalue,int rvalue) {
+int RepairHashismodify(struct RepairHash *thisvar, int relation, int rule, int lvalue,int rvalue) {
     unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
 
     struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
@@ -555,7 +555,7 @@ int ismodify(struct RepairHash *thisvar, int relation, int rule, int lvalue,int
     return 0;
 }
 
-int getrelation2(struct RepairHash *thisvar, int relation, int rule, int lvalue,int rvalue) {
+int RepairHashgetrelation2(struct RepairHash *thisvar, int relation, int rule, int lvalue,int rvalue) {
     unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
 
     struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
@@ -574,7 +574,7 @@ int getrelation2(struct RepairHash *thisvar, int relation, int rule, int lvalue,
     return 0;
 }
 
-int getrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue,int rvalue) {
+int RepairHashgetrelation(struct RepairHash *thisvar, int relation, int rule, int lvalue,int rvalue) {
     unsigned int hashkey = ((unsigned int)(relation ^ rule ^ lvalue ^ rvalue)) % thisvar->size;
 
     struct RepairHashNode **ptr = &thisvar->bucket[hashkey];
index e87ed7b655ef024acde9beccda0f7b4507a4ab03..48439bc8db14d117d88354e676949daa1ae9e059 100755 (executable)
@@ -87,7 +87,7 @@ int SimpleHashget(struct SimpleHash *,int key, int* data);
 int SimpleHashcountdata(struct SimpleHash *,int data);
 void SimpleHashaddParent(struct SimpleHash *,struct SimpleHash* parent);
 int SimpleHashfirstkey(struct SimpleHash *);
-struct SimpleIterator* SimpleHashcreateiterator(struct SimpleHash *, struct SimpleHash *);
+struct SimpleIterator* SimpleHashcreateiterator(struct SimpleHash *);
 void SimpleHashiterator(struct SimpleHash *, struct SimpleIterator * it);
 int SimpleHashcount(struct SimpleHash *, int key);
 void SimpleHashaddAll(struct SimpleHash *, struct SimpleHash * set);
@@ -106,7 +106,7 @@ struct SimpleHash {
     int tailindex;
 };
 
-inline int count(struct SimpleHash * thisvar) {
+inline int SimpleHashcountset(struct SimpleHash * thisvar) {
     return thisvar->numelements;
 }
 
@@ -191,15 +191,15 @@ struct RepairHashNode {
 struct RepairHash * noargallocateRepairHash();
 struct RepairHash * allocateRepairHash(int size);
 void freeRepairHash(struct RepairHash *);
-int addset(struct RepairHash *, int setv, int rule, int value, int data);
-int addrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue, int data);
-int addrelation2(struct RepairHash *, int relation, int rule, int lvalue, int rvalue, int data, int data2);
-bool containsset(struct RepairHash *, int setv, int rule, int value);
-bool containsrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
-int getset(struct RepairHash *, int setv, int rule, int value);
-int getrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
-int getrelation2(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
-int ismodify(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
+int RepairHashaddset(struct RepairHash *, int setv, int rule, int value, int data);
+int RepairHashaddrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue, int data);
+int RepairHashaddrelation2(struct RepairHash *, int relation, int rule, int lvalue, int rvalue, int data, int data2);
+bool RepairHashcontainsset(struct RepairHash *, int setv, int rule, int value);
+bool RepairHashcontainsrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
+int RepairHashgetset(struct RepairHash *, int setv, int rule, int value);
+int RepairHashgetrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
+int RepairHashgetrelation2(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
+int RepairHashismodify(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
 
 struct RepairHash {
     int numelements;
index 5b11610a3ff01c0f34e183863989d85c4d208588..b672d5df98d05c5efb87869f4feb8afb4858a822 100755 (executable)
@@ -1,4 +1,4 @@
-struct foo_state {int l;};
+#include "specs/x86/cache_aux.h"
 int getfield(int type, int fieldindex);
 int isArray(int type, int fieldindex);
 int isPtr(int type, int fieldindex);
index 04ad0bad552606b1f42f608d689d717009a34272..41794e712df1590a9ee44e1976cbef7567612a4d 100755 (executable)
@@ -9,11 +9,11 @@ import MCC.IR.*;
  * <ul>
  *  <li>
  *   nothing.
- *  </li> 
+ *  </li>
  * <ul>
  *
  * @author <b>Daniel Roy</b> droy (at) mit (dot) edu
- * @version %I, %G 
+ * @version %I, %G
  */
 
 public class Compiler {
@@ -26,7 +26,7 @@ public class Compiler {
     public static boolean GENERATEINSTRUMENT=false;
     public static boolean ALLOCATECPLUSPLUS=false;
     public static boolean TIME=false;
-    
+
     public static Vector debuggraphs=new Vector();
 
     public static void main(String[] args) {
@@ -54,52 +54,52 @@ public class Compiler {
            System.err.println("\nError: no input file specified");
            System.exit(-1);
        }
-        
+
        if (state.debug) {
            System.out.println("Compiling " + cli.infile + ".");
        }
-       
+
        success = scan(state) || error(state, "Scanning failed, not attempting to parse.");
        success = parse(state) || error(state, "Parsing failed, not attempting semantic analysis.");
        success = semantics(state) || error(state, "Semantic analysis failed, not attempting variable initialization.");
-       
-       
+
+
        state.setanalysis=new SetAnalysis(state);
        Termination termination=null;
        /* Check partition constraints */
        (new ImplicitSchema(state)).update();
        termination=new Termination(state);
-       
+
        state.printall();
        (new DependencyBuilder(state)).calculate();
-       
+
        try {
            Vector nodes = new Vector(state.constraintnodes.values());
            nodes.addAll(state.rulenodes.values());
-           
+
            FileOutputStream dotfile;
            dotfile = new FileOutputStream(cli.infile + ".dependencies.edgelabels.dot");
            GraphNode.useEdgeLabels = true;
            GraphNode.DOTVisitor.visit(dotfile, nodes);
            dotfile.close();
-           
+
            dotfile = new FileOutputStream(cli.infile + ".dependencies.dot");
            GraphNode.useEdgeLabels = false;
-           GraphNode.DOTVisitor.visit(dotfile, nodes);                
+           GraphNode.DOTVisitor.visit(dotfile, nodes);
            dotfile.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
-       
+
        try {
-           FileOutputStream gcode = new FileOutputStream(cli.infile + ".cc");
-           
-           
+           FileOutputStream gcode = new FileOutputStream(cli.infile + ".c");
+
+
            // do model optimizations
            //(new Optimizer(state)).optimize();
-           
-           FileOutputStream gcode2 = new FileOutputStream(cli.infile + "_aux.cc");
+
+           FileOutputStream gcode2 = new FileOutputStream(cli.infile + "_aux.c");
            FileOutputStream gcode3 = new FileOutputStream(cli.infile + "_aux.h");
            RepairGenerator wg = new RepairGenerator(state,termination);
            wg.generate(gcode,gcode2,gcode3, cli.infile + "_aux.h");
@@ -116,7 +116,7 @@ public class Compiler {
            e.printStackTrace();
            System.exit(-1);
        }
-       
+
        if (state.debug) {
            System.out.println("Compilation of " + state.infile + " successful.");
            System.out.println("#SUCCESS#");
@@ -187,7 +187,7 @@ public class Compiler {
     }
 
     public static boolean parse(State state) {
-        
+
         /* parse structure file */
         try {
             debugMessage(1, "Parsing structure file");
@@ -260,39 +260,39 @@ public class Compiler {
            return false;
        }
 
-        boolean success = 
-            !CUP$TDLParser$actions.errors && 
-            !CUP$SDLParser$actions.errors && 
-            !CUP$CDLParser$actions.errors && 
+        boolean success =
+            !CUP$TDLParser$actions.errors &&
+            !CUP$SDLParser$actions.errors &&
+            !CUP$CDLParser$actions.errors &&
             !CUP$MDLParser$actions.errors;
 
-                
+
         // if verbosity is on, then output parse trees as .dot files
         if (success && state.verbose > 0) {
             try {
                 FileOutputStream dotfile;
 
                 dotfile = new FileOutputStream(state.infile + ".struct.dot");
-                ParseNodeDOTVisitor.visit(dotfile, state.ptStructures);                
+                ParseNodeDOTVisitor.visit(dotfile, state.ptStructures);
                 dotfile.close();
 
                 dotfile = new FileOutputStream(state.infile + ".model.dot");
-                ParseNodeDOTVisitor.visit(dotfile, state.ptModel);                
+                ParseNodeDOTVisitor.visit(dotfile, state.ptModel);
                 dotfile.close();
 
                 dotfile = new FileOutputStream(state.infile + ".space.dot");
-                ParseNodeDOTVisitor.visit(dotfile, state.ptSpace);                
+                ParseNodeDOTVisitor.visit(dotfile, state.ptSpace);
                 dotfile.close();
 
                 dotfile = new FileOutputStream(state.infile + ".constraints.dot");
-                ParseNodeDOTVisitor.visit(dotfile, state.ptConstraints);                
+                ParseNodeDOTVisitor.visit(dotfile, state.ptConstraints);
                 dotfile.close();
             } catch (Exception e) {
                 e.printStackTrace();
                 return false;
             }
         }
-            
+
        return success;
     }
 
@@ -318,22 +318,22 @@ public class Compiler {
                 System.err.println("Unable to open file: " + filename);
                 System.exit(-1);
             }
-            
+
             lexer = new Lexer(infile);
 
-            
+
             try {
                 while (true) {
                     java_cup.runtime.Symbol symbol;
-                    
+
                     symbol = lexer.next_token();
-                    
+
                     if (symbol.sym == Sym.EOF) {
                         break;
                     } else if (symbol.sym == Sym.BAD) {
                         errors = true;
                     }
-                    
+
                     if (State.verbose > 2) {
                         System.out.println("Got token: " + symbol.value);
                     }
@@ -348,4 +348,3 @@ public class Compiler {
 
 
 }
-
index 6503f0b8e70e430da104d2f37e9c8d1bf337cb4a..be4341561fe19513de825e9f9292ca41a71e27cc 100755 (executable)
@@ -4,16 +4,16 @@ import java.util.*;
 import MCC.Compiler;
 
 public class DotExpr extends Expr {
-    
+
     Expr left;
     String field;
     Expr index;
-    
+
     static boolean DOMEMCHECKS=false;
     static boolean DOTYPECHECKS=false;
     static boolean DONULL=false;
 
-    
+
     public DotExpr(Expr left, String field, Expr index) {
         this.left = left;
         this.field = field;
@@ -99,7 +99,7 @@ public class DotExpr extends Expr {
            name+="["+index.name()+"]";
        return name;
     }
-    
+
     public void findmatch(Descriptor d, Set s) {
        if (d==fd)
            s.add(this);
@@ -143,7 +143,7 @@ public class DotExpr extends Expr {
 
     public Set getRequiredDescriptors() {
         Set v = left.getRequiredDescriptors();
-        
+
         if (intindex != null) {
             v.addAll(intindex.getRequiredDescriptors());
         }
@@ -167,31 +167,31 @@ public class DotExpr extends Expr {
 
        if (writer.getInvariantValue()!=null&&
            writer.getInvariantValue().isInvariant(this)) {
-           writer.outputline("maybe="+writer.getInvariantValue().getMaybe(this).getSafeSymbol()+";");
            writer.outputline(getType().getGenerateType().getSafeSymbol()+
                              " "+dest.getSafeSymbol()+"="+writer.getInvariantValue().getValue(this).getSafeSymbol()+";");
+           writer.outputline("maybe="+writer.getInvariantValue().getMaybe(this).getSafeSymbol()+";");
            return;
        }
 
-        writer.output("// " +  leftd.getSafeSymbol() + " <-- ");
+        writer.output("/* " +  leftd.getSafeSymbol() + " <-- ");
         left.prettyPrint(writer);
-        writer.outputline("");
+        writer.outputline("*/");
 
         left.generate(writer, leftd);
 
-        writer.output("// " +  leftd.getSafeSymbol() + " = ");
+        writer.output("/* " +  leftd.getSafeSymbol() + " = ");
         left.prettyPrint(writer);
-        writer.outputline("");
-      
+        writer.outputline("*/");
+
         StructureTypeDescriptor struct = (StructureTypeDescriptor) left.getType();
         Expr offsetbits;
 
         // #ATTN#: getOffsetExpr needs to be called with the fielddescriptor object that is in the vector list
-        // this means that if the field is an arraydescriptor you have to call getOffsetExpr with the array 
+        // this means that if the field is an arraydescriptor you have to call getOffsetExpr with the array
         // descriptor not the underlying field descriptor
 
         /* we calculate the offset in bits */
-        
+
         offsetbits = struct.getOffsetExpr(fd);
 
        FieldDescriptor fd=this.fd;
@@ -212,24 +212,24 @@ public class DotExpr extends Expr {
                    indexvd.setType(ReservedTypeDescriptor.INT);
                    writer.getSymbolTable().add(indexvd);
 
-                   writer.output("// " + indexvd.getSafeSymbol() + " <-- ");
+                   writer.output("/* " + indexvd.getSafeSymbol() + " <-- ");
 
                    intindex.prettyPrint(writer);
-                   writer.outputline("");
+                   writer.outputline("*/");
                    intindex.generate(writer, indexvd);
-                   writer.output("// " + indexvd.getSafeSymbol() + " = ");
+                   writer.output("/* " + indexvd.getSafeSymbol() + " = ");
                    intindex.prettyPrint(writer);
-                   writer.outputline("");
+                   writer.outputline("*/");
                    Expr indexbound=((ArrayDescriptor)this.fd).getIndexBound();
                    VarDescriptor indexboundvd=VarDescriptor.makeNew("indexbound");
 
                    indexbound.generate(writer,indexboundvd);
-                   
+
                    writer.outputline("if ("+indexvd.getSafeSymbol()+">=0 &&"+indexvd.getSafeSymbol()+"<"+indexboundvd.getSafeSymbol()+")");
                    writer.startblock();
                    VarExpr indexve=new VarExpr(indexvd);
                    offsetbits = new OpExpr(Opcode.ADD, offsetbits, new OpExpr(Opcode.MULT, basesize, indexve));
-                   
+
                    performedboundscheck=true;
                } else
                    offsetbits = new OpExpr(Opcode.ADD, offsetbits, new OpExpr(Opcode.MULT, basesize, intindex));
@@ -241,47 +241,47 @@ public class DotExpr extends Expr {
                public IRErrorReporter getErrorReporter() { throw new IRException("badness"); }
                public SymbolTable getSymbolTable() { return st; }
            });
-       
+
         if (td2 == null) {
            throw new IRException();
         } else if (td2 != ReservedTypeDescriptor.INT) {
            throw new IRException();
        }
-               
+
         boolean dotypecheck = false;
 
        VarDescriptor ob = VarDescriptor.makeNew("offsetinbits");
-       writer.output("// " + ob.getSafeSymbol() + " <-- ");
+       writer.output("/* " + ob.getSafeSymbol() + " <-- ");
        offsetbits.prettyPrint(writer);
-       writer.outputline("");
+       writer.outputline("*/");
        offsetbits.generate(writer, ob);
-       writer.output("// " + ob.getSafeSymbol() + " = ");
+       writer.output("/* " + ob.getSafeSymbol() + " = ");
        offsetbits.prettyPrint(writer);
-       writer.outputline("");
-       
+       writer.outputline("*/");
+
        /* derive offset in bytes */
        VarDescriptor offset = VarDescriptor.makeNew("offset");
        writer.outputline("int " + offset.getSafeSymbol() + " = " + ob.getSafeSymbol() + " >> 3;");
-       
+
        if (fd.getType() instanceof ReservedTypeDescriptor && !fd.getPtr()) {
            VarDescriptor shift = VarDescriptor.makeNew("shift");
-           writer.outputline("int " + shift.getSafeSymbol() + " = " + ob.getSafeSymbol() + 
+           writer.outputline("int " + shift.getSafeSymbol() + " = " + ob.getSafeSymbol() +
                              " - (" + offset.getSafeSymbol() + " << 3);");
            int mask = bitmask(((IntegerLiteralExpr)fd.getType().getSizeExpr()).getValue());
-           
+
            /* type var = ((*(int *) (base + offset)) >> shift) & mask */
            writer.outputline("if ("+leftd.getSafeSymbol()+")");
-           writer.outputline(dest.getSafeSymbol() + " = ((*(int *)" + 
-                             "(" + leftd.getSafeSymbol() + " + " + offset.getSafeSymbol() + ")) " + 
-                             " >> " + shift.getSafeSymbol() + ") & 0x" + Integer.toHexString(mask) + ";");  
+           writer.outputline(dest.getSafeSymbol() + " = ((*(int *)" +
+                             "(" + leftd.getSafeSymbol() + " + " + offset.getSafeSymbol() + ")) " +
+                             " >> " + shift.getSafeSymbol() + ") & 0x" + Integer.toHexString(mask) + ";");
            writer.outputline("else maybe=1;");
        } else { /* a structure address or a ptr */
            String ptr = fd.getPtr() ? "*(int *)" : "";
            /* type var = [*(int *)] (base + offset) */
            writer.outputline("if ("+leftd.getSafeSymbol()+")");
            writer.startblock();
-           writer.outputline(dest.getSafeSymbol() + 
-                             " = " + ptr + "(" + leftd.getSafeSymbol() + " + " + offset.getSafeSymbol() + ");");  
+           writer.outputline(dest.getSafeSymbol() +
+                             " = " + ptr + "(" + leftd.getSafeSymbol() + " + " + offset.getSafeSymbol() + ");");
            if (fd.getPtr()) {
                writer.outputline("if ("+dest.getSafeSymbol()+")");
                writer.startblock();
@@ -321,13 +321,13 @@ public class DotExpr extends Expr {
 
     private int bitmask(int bits) {
         int mask = 0;
-        
+
         for (int i = 0; i < bits; i++) {
             mask <<= 1;
             mask += 1;
         }
 
-        return mask;            
+        return mask;
     }
 
     public void prettyPrint(PrettyPrinter pp) {
@@ -346,7 +346,7 @@ public class DotExpr extends Expr {
            tmpfd=((ArrayDescriptor)tmpfd).getField();
        return (tmpfd.getPtr()||(tmpfd.getType() instanceof ReservedTypeDescriptor));
     }
-    
+
     public boolean isPtr() {
        FieldDescriptor tmpfd=fd;
        if (tmpfd instanceof ArrayDescriptor)
@@ -361,7 +361,7 @@ public class DotExpr extends Expr {
        else typechecked=true;
         TypeDescriptor lefttype = left.typecheck(sa);
         TypeDescriptor indextype = index == null ? null : index.typecheck(sa);
-       
+
        {
            /* finished typechecking...so we can fill the fields in */
            StructureTypeDescriptor struct = (StructureTypeDescriptor) left.getType();
@@ -394,7 +394,7 @@ public class DotExpr extends Expr {
             }
         }
 
-        if (lefttype instanceof StructureTypeDescriptor) {            
+        if (lefttype instanceof StructureTypeDescriptor) {
             StructureTypeDescriptor struct = (StructureTypeDescriptor) lefttype;
             FieldDescriptor fd = struct.getField(field);
             LabelDescriptor ld = struct.getLabel(field);
@@ -404,21 +404,21 @@ public class DotExpr extends Expr {
 
                 if (indextype == null && fd instanceof ArrayDescriptor) {
                     sa.getErrorReporter().report(null, "Must specify an index what accessing array field '" + struct.getSymbol() + "." + fd.getSymbol() + "'");
-                    return null;                
+                    return null;
                 } else if (indextype != null && !(fd instanceof ArrayDescriptor)) {
                     sa.getErrorReporter().report(null, "Cannot specify an index when accessing non-array field '" + struct.getSymbol() + "." + fd.getSymbol() + "'");
                     return null;
                 }
-                
+
                 this.td = fd.getType();
             } else if (ld != null) { /* label */
                 assert fd == null;
 
-                if (index != null) { 
+                if (index != null) {
                     sa.getErrorReporter().report(null, "A label cannot be accessed as an array");
                     return null;
                 }
-                
+
                 this.td = ld.getType();
             } else {
                 sa.getErrorReporter().report(null, "No such field or label '" + field + "' in structure '" + struct.getSymbol() + "'");
@@ -439,4 +439,3 @@ public class DotExpr extends Expr {
         }
     }
 }
-        
index 9630688fec8633768c1eb6ef8a894452c932cca2..6de61f4de9718c337e345a214b9b93eb9bae2a43 100755 (executable)
@@ -55,10 +55,9 @@ public class ElementOfExpr extends Expr {
     public void generate(CodeWriter writer, VarDescriptor dest) {
         VarDescriptor ed = VarDescriptor.makeNew("element");
         element.generate(writer, ed);
-        writer.outputline("int " + dest.getSafeSymbol() + " = " + 
-                          set.getSafeSymbol() + "_hash->contains(" + ed.getSafeSymbol() + ");");
+        writer.outputline("int " + dest.getSafeSymbol() + " = SimpleHashcontainskey("+set.getSafeSymbol() +"_hash ,"+ ed.getSafeSymbol() + ");");
     }
-    
+
     public void prettyPrint(PrettyPrinter pp) {
         element.prettyPrint(pp);
         pp.output(" in? " + set.getSafeSymbol());
@@ -66,7 +65,7 @@ public class ElementOfExpr extends Expr {
 
     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
         TypeDescriptor td = element.typecheck(sa);
-        
+
         if (td == null) {
             return null;
         }
@@ -77,10 +76,9 @@ public class ElementOfExpr extends Expr {
             sa.getErrorReporter().report(null, "Type mismatch: attempting to test for types '" + td.getSymbol() + "' in set of type '" + settype.getSymbol() + "'");
             return null;
         }
-        
+
         this.td = ReservedTypeDescriptor.INT;
         return this.td;
     }
 
 }
-
index e1aec13de9a07744e9eed9c78827e8f8ab682dd7..7c5dc064f9dbd494d56798584336899d6f29cc7b 100755 (executable)
@@ -122,13 +122,13 @@ public class ImageSetExpr extends SetExpr {
     }
 
     public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
-        String hash = inverse ? "_hashinv->contains(" : "_hash->contains(" ;
+        String hash = inverse ? "_hashinv, " : "_hash, " ;
        if (!isimageset) {
-           writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ", " + element.getSafeSymbol() + ");");
+           writer.outputline("int " + dest.getSafeSymbol() + " = SimpleHashcontainskeydata(" + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ", " + element.getSafeSymbol() + ");");
        } else {
            VarDescriptor newset=VarDescriptor.makeNew("newset");
            generate_set(writer,newset);
-           writer.outputline("int "+dest.getSafeSymbol()+"="+newset.getSafeSymbol()+"->contains("+element.getSafeSymbol()+");");
+           writer.outputline("int "+dest.getSafeSymbol()+"=SimpleHashcontainskey("+newset.getSafeSymbol()+","+element.getSafeSymbol()+");");
            writer.outputline("delete "+newset.getSafeSymbol()+";");
        }
     }
@@ -137,14 +137,14 @@ public class ImageSetExpr extends SetExpr {
         assert dest != null;
         assert rd != null;
        if (!isimageset) {
-           String hash = inverse ? "_hashinv->count(" : "_hash->count(" ;
-           writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ");");
+           String hash = inverse ? "_hashinv, " : "_hash, " ;
+           writer.outputline("int " + dest.getSafeSymbol() + " = SimpleHashcount(" + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ");");
        } else {
            VarDescriptor newset=VarDescriptor.makeNew("newset");
            generate_set(writer,newset);
-           writer.outputline("int "+dest.getSafeSymbol()+"="+newset.getSafeSymbol()+"->count();");
+           writer.outputline("int "+dest.getSafeSymbol()+"=SimpleHashcountset("+newset.getSafeSymbol()+");");
            writer.outputline("delete "+newset.getSafeSymbol()+";");
-       } 
+       }
     }
 
     public void generate_leftside(CodeWriter writer, VarDescriptor dest) {
@@ -153,37 +153,37 @@ public class ImageSetExpr extends SetExpr {
        } else {
            VarDescriptor iseset=VarDescriptor.makeNew("set");
            ise.generate_set(writer,iseset);
-           writer.outputline("int "+dest.getSafeSymbol()+" = "+iseset.getSafeSymbol()+"->firstkey();");
+           writer.outputline("int "+dest.getSafeSymbol()+" = SimpleHashfirstkey("+iseset.getSafeSymbol()+");");
            writer.outputline("delete "+iseset.getSafeSymbol()+";");
        }
     }
 
     public void generate_set(CodeWriter writer, VarDescriptor dest) {
        if (!isimageset) {
-           String hash = inverse ? "_hashinv->imageSet(" : "_hash->imageSet(" ;
-           writer.outputline("SimpleHash * "+dest.getSafeSymbol()+"="+rd.getSafeSymbol()+hash+vd.getSafeSymbol()+");");
+           String hash = inverse ? "_hashinv, " : "_hash, " ;
+           writer.outputline("struct SimpleHash * "+dest.getSafeSymbol()+"=SimpleHashimageSet("+rd.getSafeSymbol()+hash+vd.getSafeSymbol()+");");
        } else {
            VarDescriptor iseset=VarDescriptor.makeNew("set");
            ise.generate_set(writer,iseset);
 
            VarDescriptor itvd=VarDescriptor.makeNew("iterator");
-           writer.outputline("SimpleIterator "+itvd.getSafeSymbol()+";");
-           writer.outputline(iseset.getSafeSymbol()+"->iterator("+itvd.getSafeSymbol()+");");
+           writer.outputline("struct SimpleIterator "+itvd.getSafeSymbol()+";");
+           writer.outputline("SimpleHashiterator("+iseset.getSafeSymbol()+",&"+itvd.getSafeSymbol()+");");
+
+           writer.outputline("struct SimpleHash *"+dest.getSafeSymbol()+"=allocateSimpleHash(10);");
+           writer.outputline("while (hasNext(&"+itvd.getSafeSymbol()+")) {");
 
-           writer.outputline("SimpleHash *"+dest.getSafeSymbol()+"=new SimpleHash(10);");
-           writer.outputline("while ("+itvd.getSafeSymbol()+".hasNext()) {");
-           
            VarDescriptor keyvd=VarDescriptor.makeNew("key");
-           
-           writer.outputline("int "+keyvd.getSafeSymbol()+"="+itvd.getSafeSymbol()+".next();");
-           String hash = inverse ? "_hashinv->imageSet(" : "_hash->imageSet(" ;
+
+           writer.outputline("int "+keyvd.getSafeSymbol()+"=next(&"+itvd.getSafeSymbol()+");");
+           String hash = inverse ? "_hashinv, " : "_hash, " ;
            VarDescriptor newset=VarDescriptor.makeNew("newset");
-           writer.outputline("SimpleHash * "+newset.getSafeSymbol()+"="+rd.getSafeSymbol()+hash+keyvd.getSafeSymbol()+");");
-           writer.outputline(dest.getSafeSymbol()+"->addAll("+newset.getSafeSymbol()+");");
-           writer.outputline("delete "+newset.getSafeSymbol()+";");
+           writer.outputline("SimpleHash * "+newset.getSafeSymbol()+"=SimpleHashimageSet("+rd.getSafeSymbol()+hash+keyvd.getSafeSymbol()+");");
+           writer.outputline("SimpleHashaddAll("+dest.getSafeSymbol()+", "+ newset.getSafeSymbol()+");");
+           writer.outputline("freeSimpleHash("+newset.getSafeSymbol()+");");
            writer.outputline("}");
-           writer.outputline("delete "+iseset.getSafeSymbol()+";");
-       } 
+           writer.outputline("freeSimpleHash("+iseset.getSafeSymbol()+");");
+       }
     }
 
     public void prettyPrint(PrettyPrinter pp) {
index f31c81555df7aa7ac9c1a683620e51c77967ed12..7d520cd6bb716585554c2ff824286d234c5440a8 100755 (executable)
@@ -28,7 +28,7 @@ public class LogicStatement {
         }
         return set;
     }
-    
+
     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
        TypeDescriptor lt=left.typecheck(sa);
        if (lt!=ReservedTypeDescriptor.INT)
@@ -110,7 +110,7 @@ public class LogicStatement {
             VarDescriptor leftd = VarDescriptor.makeNew("leftboolean");
             left.generate(writer, leftd);
 
-            writer.outputline("// 3-valued NOT");
+            writer.outputline("/* 3-valued NOT*/");
            //            writer.outputline("if (!maybe)"); //this isn't really necessary
             writer.startblock();
             writer.outputline(dest.getSafeSymbol() + " =  !" + leftd.getSafeSymbol() + ";");
@@ -131,10 +131,10 @@ public class LogicStatement {
 
             String l = leftd.getSafeSymbol();
             String r = rightd.getSafeSymbol();
-            
+
             if (op == AND) {
 
-                /* 
+                /*
                  * 3-value AND LOGIC
                  *
                  * LRLR
@@ -160,14 +160,14 @@ public class LogicStatement {
                  * M = (L*RM) + (R*LM) + (LM*RM)
                  * O = (L*R)
                  */
-               
+
                 // maybe = (l && rm) || (r && lm) || (lm && rm)
                 writer.outputline("maybe = (" + l + " && " + rm + ") || (" + r + " && " + lm + ") || (" + lm + " && " + rm + ");");
                 writer.outputline(dest.getSafeSymbol() + " = " + l + " && " + r + ";");
 
             } else if (op == OR) {
 
-                /* 
+                /*
                  * 3-value OR LOGIC
                  *
                  * LRLR
@@ -199,20 +199,7 @@ public class LogicStatement {
                 writer.outputline(dest.getSafeSymbol() + " = " + l + " || " + r + ";");
             } else {
                 throw new IRException();
-            }        
+            }
         }
-    }   
+    }
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
index 3d00bbf726fbbcb7c47df1c642c5718720a8760e..e8e4359677f2dd01f1a7deadebacf5fad608138f 100755 (executable)
@@ -3,7 +3,7 @@ package MCC.IR;
 import java.util.*;
 
 public class MetaInclusion extends Inclusion {
-    
+
     Inclusion inclusion;
     Vector rules;
     Vector constraints;
@@ -48,12 +48,12 @@ public class MetaInclusion extends Inclusion {
     }
 
     public void generate(CodeWriter cr) {
-        
+
         this.inclusion.generate(cr);
 
         // for each of the rules, since they are guaranteed to be single quantifiers, and in fact,
-        // even stricter, there only quantifier is the same quantifier just generated by 
-        // the inclusion constraint, we only need to bind each of there vardescriptors in there 
+        // even stricter, there only quantifier is the same quantifier just generated by
+        // the inclusion constraint, we only need to bind each of there vardescriptors in there
         // own blocks (to avoid name space clashes) to the newly quantified variable.
 
         // we know that the inclusion is a  setinlusion
@@ -64,36 +64,36 @@ public class MetaInclusion extends Inclusion {
 
         cr.outputline("if (" + addeditem + ")");
         cr.startblock();
-        
+
         ListIterator allrules = rules.listIterator();
         while (allrules.hasNext()) {
             Rule rule = (Rule) allrules.next();
-            
+
             // we need to grab the vardescriptor of the first quantifeir (which is a setquantifier)
             // and we need to instantiate it inside a new block scope and set it equal to the value
             // in "result" .... we then need to generate the guard and inclusion inside of inner rule
-            
+
             cr.startblock();{
 
-                cr.outputline("// embedding " + rule.getLabel() );
-                
+                cr.outputline("/* embedding " + rule.getLabel() +"*/");
+
                 SetQuantifier sq = (SetQuantifier) rule.quantifiers().next(); // get first qunatifier
                 VarDescriptor vd = sq.getVar();
                 cr.outputline("int " + vd.getSafeSymbol() + " = " + result + ";");
 
                 cr.pushSymbolTable(rule.getSymbolTable());
-                
+
                 VarDescriptor guardval = VarDescriptor.makeNew();
                 rule.getGuardExpr().generate(cr, guardval);
-                
+
                 cr.outputline("if (" + guardval.getSafeSymbol() + ")");
                 cr.startblock(); {
                     rule.getInclusion().generate(cr);
                 } cr.endblock();
 
                 cr.popSymbolTable();
-           
-            } cr.endblock();                
+
+            } cr.endblock();
         }
 
         cr.endblock();
@@ -103,7 +103,7 @@ public class MetaInclusion extends Inclusion {
         ListIterator allconstraints = constraints.listIterator();
         while (allconstraints.hasNext()) {
             Constraint constraint = (Constraint) allconstraints.next();
-            
+
             // ok... um... we need to grab teh vardescripntor of the first quantifier which is guaranteed
             // to be a setquantifier... we then need to bind it to variable, generatedresult.
             // once this is done we can generated the logicstatement and we can then test for pass/fail
@@ -111,32 +111,32 @@ public class MetaInclusion extends Inclusion {
 
             cr.startblock(); {
 
-                cr.outputline("// checking embedded " + constraint.getLabel() );
-                
+                cr.outputline("/* checking embedded " + constraint.getLabel()+"*/" );
+
                 SetQuantifier sq = (SetQuantifier) constraint.quantifiers().next(); // get first qunatifier
                 VarDescriptor vd = sq.getVar();
                 cr.outputline("int " + vd.getSafeSymbol() + " = " + result + ";");
 
                 cr.pushSymbolTable(constraint.getSymbolTable());
-                
+
                 cr.outputline("int maybe = 0;");
-                
+
                 /* now we have to generate the guard test */
-                
+
                 VarDescriptor constraintboolean = VarDescriptor.makeNew("constraintboolean");
                 constraint.getLogicStatement().generate(cr, constraintboolean);
-                
+
                 cr.outputline("if (maybe)");
                 cr.startblock(); {
 
                     cr.outputline("__Success = 0;");
                     cr.outputline("printf(\"maybe fail " + constraint.getNum() + ". \");");
                     cr.outputline("exit(1);");
-           
+
                 } cr.endblock();
-                cr.outputline("else if (!" + constraintboolean.getSafeSymbol() + ")");                
+                cr.outputline("else if (!" + constraintboolean.getSafeSymbol() + ")");
                 cr.startblock(); {
-                
+
                     cr.outputline("__Success = 0;");
                     cr.outputline("printf(\"fail " + constraint.getNum() + ". \");");
                     cr.outputline("exit(1);");
@@ -144,12 +144,11 @@ public class MetaInclusion extends Inclusion {
                 } cr.endblock();
 
                 cr.popSymbolTable();
-           
-            } cr.endblock();                                      
+
+            } cr.endblock();
 
         }
 
     }
 
 }
-
index 08ed84d6325ddd44a83d3a90faed431f3d758cf5..505217e4b9f8cff674e316c82c71df32df7f485d 100755 (executable)
@@ -8,14 +8,14 @@ public class NaiveGenerator {
 
     State state;
     java.io.PrintWriter output = null;
-            
+
     public NaiveGenerator(State state) {
         this.state = state;
     }
 
     public void generate(java.io.OutputStream output) {
-        this.output = new java.io.PrintWriter(output, true); 
-        
+        this.output = new java.io.PrintWriter(output, true);
+
         generate_tokentable();
         generate_hashtables();
         generate_rules();
@@ -26,16 +26,16 @@ public class NaiveGenerator {
 
     private void generate_tokentable() {
 
-        CodeWriter cr = new StandardCodeWriter(output);        
-        Iterator tokens = TokenLiteralExpr.tokens.keySet().iterator();        
+        CodeWriter cr = new StandardCodeWriter(output);
+        Iterator tokens = TokenLiteralExpr.tokens.keySet().iterator();
 
         cr.outputline("");
-        cr.outputline("// Token values");
+        cr.outputline("/* Token values*/");
         cr.outputline("");
 
         while (tokens.hasNext()) {
             Object token = tokens.next();
-            cr.outputline("// " + token.toString() + " = " + TokenLiteralExpr.tokens.get(token).toString());            
+            cr.outputline("/* " + token.toString() + " = " + TokenLiteralExpr.tokens.get(token).toString()+"*/");
         }
 
         cr.outputline("");
@@ -45,48 +45,48 @@ public class NaiveGenerator {
     private void generate_hashtables() {
 
         CodeWriter cr = new StandardCodeWriter(output);
-        cr.outputline("int __Success = 1;\n");       
-        cr.outputline("// creating hashtables ");
-        
+        cr.outputline("int __Success = 1;\n");
+        cr.outputline("/* creating hashtables */");
+
         /* build all the hashtables */
         Hashtable hashtables = new Hashtable();
 
         /* build sets */
         Iterator sets = state.stSets.descriptors();
-        
+
         /* first pass create all the hash tables */
         while (sets.hasNext()) {
             SetDescriptor set = (SetDescriptor) sets.next();
             cr.outputline("SimpleHash* " + set.getSafeSymbol() + "_hash = new SimpleHash();");
-        } 
-        
+        }
+
         /* second pass build relationships between hashtables */
         sets = state.stSets.descriptors();
-        
+
         while (sets.hasNext()) {
             SetDescriptor set = (SetDescriptor) sets.next();
             Iterator subsets = set.subsets();
-            
+
             while (subsets.hasNext()) {
-                SetDescriptor subset = (SetDescriptor) subsets.next();                
+                SetDescriptor subset = (SetDescriptor) subsets.next();
                 cr.outputline(subset.getSafeSymbol() + "_hash->addParent(" + set.getSafeSymbol() + "_hash);");
             }
-        } 
+        }
 
         /* build relations */
         Iterator relations = state.stRelations.descriptors();
-        
+
         /* first pass create all the hash tables */
         while (relations.hasNext()) {
             RelationDescriptor relation = (RelationDescriptor) relations.next();
-            
+
             if (relation.testUsage(RelationDescriptor.IMAGE)) {
                 cr.outputline("SimpleHash* " + relation.getSafeSymbol() + "_hash = new SimpleHash();");
             }
 
             if (relation.testUsage(RelationDescriptor.INVIMAGE)) {
                 cr.outputline("SimpleHash* " + relation.getSafeSymbol() + "_hashinv = new SimpleHash();");
-            } 
+            }
         }
 
         cr.outputline("");
@@ -106,16 +106,16 @@ public class NaiveGenerator {
                     return g2.getFinishingTime() - g1.getFinishingTime();
                 }
             });
-        
-        topologicalsort.addAll(state.rulenodes.values());        
+
+        topologicalsort.addAll(state.rulenodes.values());
 
         /* build all the rules */
         Iterator rules = topologicalsort.iterator();
-                
+
         while (rules.hasNext()) {
 
             GraphNode rulenode = (GraphNode) rules.next();
-            Rule rule = (Rule) rulenode.getOwner();            
+            Rule rule = (Rule) rulenode.getOwner();
 
             if (!state.vRules.contains(rule)) {
                 // this is no longer a top-level rule
@@ -125,28 +125,28 @@ public class NaiveGenerator {
             {
 
                 CodeWriter cr = new StandardCodeWriter(output);
-                cr.pushSymbolTable(rule.getSymbolTable()); 
-                
-                cr.outputline("// build " + rule.getLabel());
+                cr.pushSymbolTable(rule.getSymbolTable());
+
+                cr.outputline("/* build " + rule.getLabel()+"*/");
                 cr.startblock();
 
                 ListIterator quantifiers = rule.quantifiers();
 
                 while (quantifiers.hasNext()) {
-                    Quantifier quantifier = (Quantifier) quantifiers.next();                   
+                    Quantifier quantifier = (Quantifier) quantifiers.next();
                     quantifier.generate_open(cr);
-                }            
-                        
+                }
+
                 /* pretty print! */
-                cr.output("//");
+                cr.output("/*");
                 rule.getGuardExpr().prettyPrint(cr);
-                cr.outputline("");
+                cr.outputline("*/");
 
                 /* now we have to generate the guard test */
-        
+
                 VarDescriptor guardval = VarDescriptor.makeNew();
                 rule.getGuardExpr().generate(cr, guardval);
-                
+
                 cr.outputline("if (" + guardval.getSafeSymbol() + ")");
                 cr.startblock();
 
@@ -172,9 +172,9 @@ public class NaiveGenerator {
     private void generate_implicit_checks() {
 
         /* do post checks */
-         
+
         CodeWriter cr = new StandardCodeWriter(output);
-           
+
         // #TBD#: these should be implicit checks added to the set of constraints
         //output.println("check multiplicity");
     }
@@ -186,30 +186,30 @@ public class NaiveGenerator {
 
         for (int i = 0; i < constraints.size(); i++) {
 
-            Constraint constraint = (Constraint) constraints.elementAt(i); 
+            Constraint constraint = (Constraint) constraints.elementAt(i);
 
             {
 
                 CodeWriter cr = new StandardCodeWriter(output);
                 cr.pushSymbolTable(constraint.getSymbolTable());
-                
-                cr.outputline("// checking " + constraint.getLabel());
+
+                cr.outputline("/* checking " + constraint.getLabel()+"*/");
                 cr.startblock();
 
                 ListIterator quantifiers = constraint.quantifiers();
 
                 while (quantifiers.hasNext()) {
-                    Quantifier quantifier = (Quantifier) quantifiers.next();                   
+                    Quantifier quantifier = (Quantifier) quantifiers.next();
                     quantifier.generate_open(cr);
-                }            
+                }
 
                 cr.outputline("int maybe = 0;");
-                        
+
                 /* now we have to generate the guard test */
-        
+
                 VarDescriptor constraintboolean = VarDescriptor.makeNew("constraintboolean");
                 constraint.getLogicStatement().generate(cr, constraintboolean);
-                
+
                 cr.outputline("if (maybe)");
                 cr.startblock();
                 cr.outputline("__Success = 0;");
@@ -234,13 +234,10 @@ public class NaiveGenerator {
                 cr.outputline("");
                 cr.outputline("");
             }
-            
+
         }
 
-        output.println("//if (__Success) { printf(\"all tests passed\"); }");
-    }    
+        output.println("/*if (__Success) { printf(\"all tests passed\"); }*/");
+    }
 
 }
-
-
-
index 4c0971cdd452a141a5cf057acd858e55c4c5fe44..0c5082b485040794909712d7823624b9f5b3a40e 100755 (executable)
@@ -246,7 +246,7 @@ public class OpExpr extends Expr {
            newset.addAll(right.useDescriptor(d));
        return newset;
     }
-    
+
     public int[] getRepairs(boolean negated, Termination t) {
        if (left instanceof RelationExpr)
            return new int[] {AbstractRepair.MODIFYRELATION};
@@ -284,7 +284,7 @@ public class OpExpr extends Expr {
                                          AbstractRepair.REMOVEFROMRELATION};
                    }
                } else if (op==Opcode.GE||op==Opcode.GT) {
-                   return new int[]{AbstractRepair.ADDTORELATION}; 
+                   return new int[]{AbstractRepair.ADDTORELATION};
                } else if (op==Opcode.LE||op==Opcode.LT) {
                    if ((op==Opcode.LT&&maxsize!=-1&&maxsize<size)||(op==Opcode.LE&&maxsize!=-1&&maxsize<=size))
                        return new int[0];
@@ -297,7 +297,7 @@ public class OpExpr extends Expr {
            } else {
                if (op==Opcode.EQ) {
                    if (size==0)
-                       return new int[] {AbstractRepair.REMOVEFROMSET};                        
+                       return new int[] {AbstractRepair.REMOVEFROMSET};
                    else {
                        if (maxsize<=size&&maxsize!=-1)
                            return new int[] {AbstractRepair.ADDTOSET};
@@ -305,7 +305,7 @@ public class OpExpr extends Expr {
                                              AbstractRepair.REMOVEFROMSET};
                    }
                } else if (op==Opcode.GE||op==Opcode.GT) {
-                   return new int[] {AbstractRepair.ADDTOSET}; 
+                   return new int[] {AbstractRepair.ADDTOSET};
                } else if (op==Opcode.LE||op==Opcode.LT) {
                    if ((op==Opcode.LT&&maxsize<size&&maxsize!=-1)||(op==Opcode.LE&&maxsize<=size&&maxsize!=-1))
                        return new int[0];
@@ -319,7 +319,7 @@ public class OpExpr extends Expr {
        }
        throw new Error("BAD");
     }
-    
+
     public Descriptor getDescriptor() {
        return left.getDescriptor();
     }
@@ -338,21 +338,21 @@ public class OpExpr extends Expr {
 
     public Set getRequiredDescriptors() {
         Set v = left.getRequiredDescriptors();
-     
+
         if (right != null) {
             v.addAll(right.getRequiredDescriptors());
         }
 
         return v;
-    }   
+    }
 
     public void generate(CodeWriter writer, VarDescriptor dest) {
         VarDescriptor ld = VarDescriptor.makeNew("leftop");
        /* Check for loop invariant hoisting. */
        if (writer.getInvariantValue()!=null&&
            writer.getInvariantValue().isInvariant(this)) {
-           writer.outputline("maybe="+writer.getInvariantValue().getMaybe(this).getSafeSymbol()+";");
            writer.outputline("int "+dest.getSafeSymbol()+"="+writer.getInvariantValue().getValue(this).getSafeSymbol()+";");
+           writer.outputline("maybe="+writer.getInvariantValue().getMaybe(this).getSafeSymbol()+";");
            return;
        }
 
@@ -391,7 +391,7 @@ public class OpExpr extends Expr {
            writer.outputline("int "+dest.getSafeSymbol() + " = " + ld.getSafeSymbol() + " || " + rd.getSafeSymbol() + ";");
        } else if (opcode != Opcode.NOT) { /* two operands */
             assert rd != null;
-           writer.outputline("int " + dest.getSafeSymbol() + " = " + 
+           writer.outputline("int " + dest.getSafeSymbol() + " = " +
                              ld.getSafeSymbol() + " " + opcode.toString() + " " + rd.getSafeSymbol() + ";");
         } else if (opcode == Opcode.NOT) {
             writer.outputline("int " + dest.getSafeSymbol() + " = !" + ld.getSafeSymbol() + ";");
@@ -408,7 +408,7 @@ public class OpExpr extends Expr {
        } else if (opcode == Opcode.RND) {
            pp.output("RND ");
             left.prettyPrint(pp);
-        } else {           
+        } else {
             left.prettyPrint(pp);
             pp.output(" " + opcode.toString() + " ");
             assert right != null;
diff --git a/Repair/RepairCompiler/MCC/IR/PrintWrapper.java b/Repair/RepairCompiler/MCC/IR/PrintWrapper.java
new file mode 100755 (executable)
index 0000000..8a649b5
--- /dev/null
@@ -0,0 +1,56 @@
+package MCC.IR;
+import java.util.*;
+
+public class PrintWrapper {
+  java.io.PrintWriter output;
+  String buffered="";
+  boolean buffer=false;
+  Hashtable vartable=new Hashtable();
+
+  public PrintWrapper(java.io.PrintWriter output) {
+    this.output=output;
+  }
+  void print(String s) {
+    if (buffer)
+      buffered+=s;
+    else
+      output.print(s);
+  }
+  void flush() {
+    if (!buffer)
+      output.flush();
+  }
+  void println(String s) {
+    if (buffer)
+      buffered+=s+"\n";
+    else
+      output.println(s);
+  }
+  void startBuffer() {
+    buffer=true;
+  }
+  void emptyBuffer() {
+    //Print out declarations
+    for(Iterator it=vartable.keySet().iterator();it.hasNext();) {
+      String var=(String)it.next();
+      output.println(((String)vartable.get(var))+" "+var+";");
+    }
+    output.print(buffered);
+    buffered="";
+    vartable=new Hashtable();
+    buffer=false;
+  }
+  void addDeclaration(String type, String varname) {
+    if (buffer) {
+      if (vartable.containsKey(varname)) {
+        String oldtype=(String)vartable.get(varname);
+        if (!oldtype.equals(type)) {
+          throw new Error("Internal error: Inconsistent declarations for:"+varname);
+        }
+      } else {
+        vartable.put(varname,type);
+      }
+    } else
+      output.println(type+" "+varname+";");
+  }
+}
index 1f2bb48991788278c474d48ecafda4c81144d997..4eefc7005b6c3f83176c991454fcebc3d81c15dc 100755 (executable)
@@ -14,7 +14,7 @@ public class RelationExpr extends Expr {
        if (exprfunctions!=null)
            functions.addAll(exprfunctions);
        functions.add(new ConstraintDependence.Function(relation,expr.getSet(),inverse,this));
-       
+
        return functions;
     }
 
@@ -74,7 +74,7 @@ public class RelationExpr extends Expr {
        newset.addAll(expr.useDescriptor(rd));
        return newset;
     }
-    
+
     public RelationDescriptor getRelation() {
         return relation;
     }
@@ -96,7 +96,7 @@ public class RelationExpr extends Expr {
     }
 
     public Set getRequiredDescriptors() {
-        Set v = expr.getRequiredDescriptors();        
+        Set v = expr.getRequiredDescriptors();
         v.add(relation);
         return v;
     }
@@ -107,14 +107,14 @@ public class RelationExpr extends Expr {
         String found = (VarDescriptor.makeNew("found")).getSafeSymbol();
         expr.generate(writer, domain);
         writer.outputline(relation.getRange().getType().getGenerateType().getSafeSymbol() + " " + dest.getSafeSymbol() + ";");
-       writer.outputline("int "+found+" = "+relation.getSafeSymbol() + "_hash" + strinverse + "->get(" + domain.getSafeSymbol() + ", " + dest.getSafeSymbol() + ");");
+       writer.outputline("int "+found+" = SimpleHashget(" +relation.getSafeSymbol()+"_hash"+strinverse+", "+ domain.getSafeSymbol() + ", & " + dest.getSafeSymbol() + ");");
        writer.outputline("if (!" + found + ") { maybe = 1; }");
     }
 
     public void prettyPrint(PrettyPrinter pp) {
         expr.prettyPrint(pp);
         pp.output(".");
-        
+
         if (inverse) {
             pp.output("~");
         }
@@ -125,7 +125,7 @@ public class RelationExpr extends Expr {
     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
 
         TypeDescriptor type = expr.typecheck(sa);
-        
+
         if (type == null) {
             return null;
         }
@@ -133,22 +133,22 @@ public class RelationExpr extends Expr {
         /* check to make sure that the types of the relation match up */
         if (inverse) {
             TypeDescriptor rangetype = relation.getRange().getType();
-            
+
             if (rangetype != type) {
-                sa.getErrorReporter().report(null, "Type of left side of relation operator '.' is '" + type.getSymbol() + 
-                                    "' but must be '" + rangetype.getSymbol() + 
+                sa.getErrorReporter().report(null, "Type of left side of relation operator '.' is '" + type.getSymbol() +
+                                    "' but must be '" + rangetype.getSymbol() +
                                     "', the type of the range of the relation '" + relation.getSymbol() + "'");
                 return null;
             }
-            
+
             this.td = relation.getDomain().getType();
             return this.td;
         } else { /* not inverse */
             TypeDescriptor domaintype = relation.getDomain().getType();
-            
+
             if (domaintype != type) {
-                sa.getErrorReporter().report(null, "Type of left side of relation operator '.' is '" + type.getSymbol() + 
-                                    "' but must be '" + domaintype.getSymbol() + 
+                sa.getErrorReporter().report(null, "Type of left side of relation operator '.' is '" + type.getSymbol() +
+                                    "' but must be '" + domaintype.getSymbol() +
                                     "', the type of the domain of the relation '" + relation.getSymbol() + "'");
                 return null;
             }
index f7e37cf0eea44a433c0073599cbc37d267716c6f..2ae18f9cba948eb9ec145b25cca25325673319c2 100755 (executable)
@@ -34,7 +34,7 @@ public class RelationFunctionExpr extends Expr {
     }
 
     public Set getRequiredDescriptors() {
-        Set v = expr.getRequiredDescriptors();        
+        Set v = expr.getRequiredDescriptors();
         v.add(relation);
         return v;
     }
@@ -47,13 +47,13 @@ public class RelationFunctionExpr extends Expr {
     }
 
     public void generate(CodeWriter cr, VarDescriptor dest) {
-        
+
         String destname = dest.getSafeSymbol();
         cr.outputline("int " + destname + ";");
 
-        // ok... destination is declared... we gotta expand this rule inplace... and instead of the inclusion we 
+        // ok... destination is declared... we gotta expand this rule inplace... and instead of the inclusion we
         // set the destination in the guard ... otherwise maybe!
-        
+
         VarDescriptor domain = VarDescriptor.makeNew("domain");
         expr.generate(cr, domain);
 
@@ -64,34 +64,34 @@ public class RelationFunctionExpr extends Expr {
             SetQuantifier sq = ((SetQuantifier) rule.quantifiers().next());
             VarDescriptor rulebinding = sq.getVar();
             String tempvar = (VarDescriptor.makeNew("tempvar")).getSafeSymbol();
-            
+
             // this is to be safe about name overlap because int t = t; sets t to 0!
             cr.outputline("int " + tempvar + " = " + domain.getSafeSymbol() + ";");
             cr.outputline("int " + rulebinding.getSafeSymbol() + " = " + tempvar + ";");
-            
+
             /* pretty print! */
-            cr.outputline("// about to inbed relational function");
-            cr.output("// ");
+            cr.outputline("/* about to inbed relational function*/");
+            cr.output("/* ");
             rule.getGuardExpr().prettyPrint(cr);
-            cr.outputline("");
-            
+            cr.outputline("*/");
+
             /* now we have to generate the guard test */
             VarDescriptor guardval = VarDescriptor.makeNew();
             rule.getGuardExpr().generate(cr, guardval);
-            
+
             cr.outputline("if (" + guardval.getSafeSymbol() + ")");
             cr.startblock(); {
-                
+
                 /* now we have to generate the inclusion code */
                 RelationInclusion ri = (RelationInclusion) rule.getInclusion();
-                
-                // basically, destname = righthandside<r, r.field>            
+
+                // basically, destname = righthandside<r, r.field>
                 VarDescriptor tempdest = VarDescriptor.makeNew("tempdest");
                 Expr rhs = ri.getRightExpr();
                 rhs.generate(cr, tempdest);
-                
+
                 cr.outputline(destname + " = " + tempdest.getSafeSymbol() + ";");
-                
+
             } cr.endblock();
             cr.outputline("else");
             cr.startblock(); {
index b31700c8aadd0ce51f0f74004f3e94f02d4a59e4..0615b2528c9b44b224948f8bf31c7849b0ea4b3d 100755 (executable)
@@ -3,7 +3,7 @@ import MCC.Compiler;
 import java.util.*;
 
 public class RelationInclusion extends Inclusion {
-    
+
     Expr leftelementexpr, rightelementexpr;
     RelationDescriptor relation;
 
@@ -33,7 +33,7 @@ public class RelationInclusion extends Inclusion {
     public Expr getLeftExpr() {
         return leftelementexpr;
     }
-    
+
     public Expr getRightExpr() {
         return rightelementexpr;
     }
@@ -73,11 +73,11 @@ public class RelationInclusion extends Inclusion {
             String check = "int " + typesafecheck + " = " ;
 
             if (!(relation.getDomain() instanceof ReservedSetDescriptor)) {
-                check += relation.getDomain().getSafeSymbol() + "_hash->contains(" + ld.getSafeSymbol() + ") && ";
+                check += "SimpleHashcontainskey("+relation.getDomain().getSafeSymbol() + "_hash, "+ld.getSafeSymbol() + ") && ";
             }
 
             if (!(relation.getRange() instanceof ReservedSetDescriptor)) {
-                check += relation.getRange().getSafeSymbol() + "_hash->contains(" + rd.getSafeSymbol() + ") && ";
+                check += "SimpleHashcontainskey("+relation.getRange().getSafeSymbol() +"_hash, "+ rd.getSafeSymbol() + ") && ";
             }
 
             check += "1;"; // terminate boolean expression
@@ -88,19 +88,8 @@ public class RelationInclusion extends Inclusion {
         }
 
         String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
-       /*      if (!Compiler.REPAIR) {
-           writer.outputline("int " + addeditem + ";");
-           if (relation.testUsage(RelationDescriptor.IMAGE)) {
-               writer.outputline(addeditem + " = " + relation.getSafeSymbol() + "_hash->add((int)" + ld.getSafeSymbol() + ", (int)" + rd.getSafeSymbol() + ");");
-           }
-           
-           if (relation.testUsage(RelationDescriptor.INVIMAGE)) {
-               writer.outputline(addeditem + " = " + relation.getSafeSymbol() + "_hashinv->add((int)" + rd.getSafeSymbol() + ", (int)" + ld.getSafeSymbol() + ");");
-           }
-           } else {*/
-           Repair.generate_dispatch(writer, relation, ld.getSafeSymbol(), rd.getSafeSymbol());
-           //  }
-       
+        Repair.generate_dispatch(writer, relation, ld.getSafeSymbol(), rd.getSafeSymbol());
+
         if (RelationInclusion.worklist) {
             writer.outputline("if (" + addeditem + ")");
             writer.startblock(); {
@@ -119,18 +108,18 @@ public class RelationInclusion extends Inclusion {
     public boolean typecheck(SemanticAnalyzer sa) {
         TypeDescriptor ld = leftelementexpr.typecheck(sa);
         TypeDescriptor rd = rightelementexpr.typecheck(sa);
-        
+
         if (ld == null || rd == null) {
             return false;
         }
 
         boolean ok = true;
 
-        /* #ATTN#: this check makes sure that the types match up, 
-           a runtime check needs to made that the set relationships 
+        /* #ATTN#: this check makes sure that the types match up,
+           a runtime check needs to made that the set relationships
            are correct */
 
-        if (ld != relation.getDomain().getType()) { 
+        if (ld != relation.getDomain().getType()) {
             sa.getErrorReporter().report(null, "Type of left element '" + ld.getSymbol() + "' must match domain type '" + relation.getDomain().getType().getSymbol() + "'");
             ok = false;
         }
index 48959afc7e426a9fee455214ce83c0cef10fdf27..e759aa768c65466753e188dcfc6bbc7cf863bcdf 100755 (executable)
@@ -10,7 +10,7 @@ public class RelationQuantifier extends Quantifier {
     public RelationQuantifier() {}
 
     public void setRelation(RelationDescriptor rd) {
-        relation = rd; 
+        relation = rd;
     }
 
     public RelationDescriptor getRelation() {
@@ -33,22 +33,22 @@ public class RelationQuantifier extends Quantifier {
     }
 
     public void generate_open(CodeWriter writer) {
-       writer.outputline("SimpleIterator "+x.getSafeSymbol()+"_iterator;");
-        writer.outputline("for ("+relation.getSafeSymbol() + "_hash->iterator("+x.getSafeSymbol()+"_iterator); " + x.getSafeSymbol() + "_iterator.hasNext(); )");
+       writer.outputline("struct SimpleIterator "+x.getSafeSymbol()+"_iterator;");
+        writer.outputline("for (SimpleHashiterator("+relation.getSafeSymbol()+"_hash, "+x.getSafeSymbol()+"_iterator); hasNext("+x.getSafeSymbol()+"_iterator); )");
         writer.startblock();
-        writer.outputline(y.getType().getGenerateType() + " " + y.getSafeSymbol() + " = (" + y.getType().getGenerateType() + ") " + x.getSafeSymbol() + "_iterator.next();");        
-        // #ATTN#: key is called second because next() forwards ptr and key does not! 
-        writer.outputline(x.getType().getGenerateType() + " " + x.getSafeSymbol() + " = (" + x.getType().getGenerateType() + ") " + x.getSafeSymbol() + "_iterator.key();");
+        writer.outputline(y.getType().getGenerateType() + " " + y.getSafeSymbol() + " = (" + y.getType().getGenerateType() + ") next("+x.getSafeSymbol()+"_iterator);");
+        // #ATTN#: key is called second because next() forwards ptr and key does not!
+        writer.outputline(x.getType().getGenerateType() + " " + x.getSafeSymbol() + " = (" + x.getType().getGenerateType() + ") key("+x.getSafeSymbol()+"_iterator);");
     }
 
     public void generate_open(CodeWriter writer, String type,int number, String left,String right) {
        VarDescriptor tmp=VarDescriptor.makeNew("flag");
-        writer.outputline("SimpleIterator* " + x.getSafeSymbol() + "_iterator = " + relation.getSafeSymbol() + "_hash->iterator();");
+        writer.outputline("struct SimpleIterator * " + x.getSafeSymbol() + "_iterator = SimpleHashcreateiterator("+relation.getSafeSymbol()+"_hash);");
        writer.outputline("int "+tmp.getSafeSymbol()+"=0;");
        writer.outputline("if ("+type+"=="+number+")");
        writer.outputline(tmp.getSafeSymbol()+"=1;");
-       
-       writer.outputline("while("+tmp.getSafeSymbol()+"||(("+type+"!="+number+")&&"+x.getSafeSymbol() + "_iterator->hasNext()))");
+
+       writer.outputline("while("+tmp.getSafeSymbol()+"||(("+type+"!="+number+")&& hasNext("+x.getSafeSymbol()+"_iterator)))");
         writer.startblock();
         writer.outputline(x.getType().getGenerateType() + " " + x.getSafeSymbol() + ";");
         writer.outputline(y.getType().getGenerateType() + " " + y.getSafeSymbol() + ";");
@@ -60,25 +60,25 @@ public class RelationQuantifier extends Quantifier {
        writer.endblock();
        writer.outputline("else");
        writer.startblock();
-        writer.outputline(y.getSafeSymbol() + " = (" + y.getType().getGenerateType() + ") " + x.getSafeSymbol() + "_iterator->next();");        
-        writer.outputline(x.getSafeSymbol() + " = (" + x.getType().getGenerateType() + ") " + x.getSafeSymbol() + "_iterator->key();");
+        writer.outputline(y.getSafeSymbol() + " = (" + y.getType().getGenerateType() + ") next("+x.getSafeSymbol()+"_iterator);");
+        writer.outputline(x.getSafeSymbol() + " = (" + x.getType().getGenerateType() + ") key("+x.getSafeSymbol()+"_iterator);");
        writer.endblock();
     }
 
-    public int generate_worklistload(CodeWriter writer, int offset) {        
+    public int generate_worklistload(CodeWriter writer, int offset) {
         String varx = x.getSafeSymbol();
         String vary = y.getSafeSymbol();
-        writer.outputline("int " + varx + " = wi->word" + offset + "; // r1"); 
-        writer.outputline("int " + vary + " = wi->word" + (offset + 1) + "; //r2"); 
-        return offset + 2;       
+        writer.outputline("int " + varx + " = wi->word" + offset + "; /* r1*/");
+        writer.outputline("int " + vary + " = wi->word" + (offset + 1) + "; /*r2*/");
+        return offset + 2;
     }
 
-    public int generate_workliststore(CodeWriter writer, int offset) {        
+    public int generate_workliststore(CodeWriter writer, int offset) {
         String varx = x.getSafeSymbol();
         String vary = y.getSafeSymbol();
-        writer.outputline("wi->word" + offset + " = " + varx + "; // r1");
-        writer.outputline("wi->word" + (offset+1) + " = " + vary + "; // r2");
-        return offset + 2;       
+        writer.outputline("wi->word" + offset + " = " + varx + "; /* r1*/");
+        writer.outputline("wi->word" + (offset+1) + " = " + vary + "; /* r2*/");
+        return offset + 2;
     }
 
 
index bba7b78055d77b9aa88dc76d077d9cf57d55cb51..332e58cd3932b2151e277e1be5a3b998ea8b35c6 100755 (executable)
@@ -77,12 +77,26 @@ public class RepairGenerator {
         this.outputrepair = new java.io.PrintWriter(outputrepair, true);
         this.outputaux = new java.io.PrintWriter(outputaux, true);
         this.outputhead = new java.io.PrintWriter(outputhead, true);
+
         headername=st;
        name_updates();
        generatetypechecks(true);
         generate_tokentable();
+       RelationDescriptor.prefix = "thisvar->";
+       SetDescriptor.prefix = "thisvar->";
+
         generate_hashtables();
        generate_stateobject();
+
+
+       /* Rewrite globals */
+        CodeWriter craux = new StandardCodeWriter(this.outputaux);
+       for (Iterator it=this.state.stGlobals.descriptors();it.hasNext();) {
+           VarDescriptor vd=(VarDescriptor)it.next();
+           craux.outputline("#define "+vd.getSafeSymbol()+" thisvar->"+vd.getSafeSymbol());
+       }
+
+
        generate_call();
        generate_start();
         generate_rules();
@@ -92,8 +106,7 @@ public class RepairGenerator {
         generate_checks();
         generate_teardown();
        CodeWriter crhead = new StandardCodeWriter(this.outputhead);
-       CodeWriter craux = new StandardCodeWriter(this.outputaux);
-       crhead.outputline("};");
+       craux = new StandardCodeWriter(this.outputaux);
        craux.outputline("}");
 
        if (Compiler.GENERATEDEBUGHOOKS) {
@@ -129,6 +142,7 @@ public class RepairGenerator {
 
        for (Iterator it=this.state.stGlobals.descriptors();it.hasNext();) {
            VarDescriptor vd=(VarDescriptor)it.next();
+            craux.outputline("#undef "+vd.getSafeSymbol());
            craux.outputline("#define "+vd.getSafeSymbol()+" "+ststate+"->"+vd.getSafeSymbol());
        }
 
@@ -145,11 +159,11 @@ public class RepairGenerator {
                switch(mun.op) {
                case MultUpdateNode.ADD:
                    if (isrelation) {
-                       crhead.outputline("void "+methodname+"("+name+"_state * " +ststate+","+name+" * "+stmodel+", RepairHash * "+strepairtable+", int "+stleft+", int "+stright+");");
-                       craux.outputline("void "+methodname+"("+name+"_state * "+ ststate+","+name+" * "+stmodel+", RepairHash * "+strepairtable+", int "+stleft+", int "+stright+")");
+                       crhead.outputline("void "+methodname+"(struct "+name+"_state * " +ststate+",struct "+name+" * "+stmodel+", struct RepairHash * "+strepairtable+", int "+stleft+", int "+stright+");");
+                       craux.outputline("void "+methodname+"(struct "+name+"_state * "+ ststate+", struct "+name+" * "+stmodel+", struct RepairHash * "+strepairtable+", int "+stleft+", int "+stright+")");
                    } else {
-                       crhead.outputline("void "+methodname+"("+name+"_state * "+ ststate+","+name+" * "+stmodel+", RepairHash * "+strepairtable+", int "+stleft+");");
-                       craux.outputline("void "+methodname+"("+name+"_state * "+ststate+","+name+" * "+stmodel+", RepairHash * "+strepairtable+", int "+stleft+")");
+                       crhead.outputline("void "+methodname+"(struct "+name+"_state * "+ ststate+", struct "+name+" * "+stmodel+", struct RepairHash * "+strepairtable+", int "+stleft+");");
+                       craux.outputline("void "+methodname+"(struct "+name+"_state * "+ststate+", struct "+name+" * "+stmodel+", struct RepairHash * "+strepairtable+", int "+stleft+")");
                    }
                    craux.startblock();
                    craux.outputline("int maybe=0;");
@@ -166,7 +180,7 @@ public class RepairGenerator {
                    break;
                case MultUpdateNode.REMOVE: {
                    Rule r=un.getRule();
-                   String methodcall="void "+methodname+"("+name+"_state * "+ststate+","+name+" * "+stmodel+", RepairHash * "+strepairtable;
+                   String methodcall="void "+methodname+"(struct "+name+"_state * "+ststate+", struct "+name+" * "+stmodel+", struct RepairHash * "+strepairtable;
                    for(int j=0;j<r.numQuantifiers();j++) {
                        Quantifier q=r.getQuantifier(j);
                        if (q instanceof SetQuantifier) {
@@ -200,7 +214,7 @@ public class RepairGenerator {
                    break;
                case MultUpdateNode.MODIFY: {
                    Rule r=un.getRule();
-                   String methodcall="void "+methodname+"("+name+"_state * "+ststate+","+name+" * "+stmodel+", RepairHash * "+strepairtable;
+                   String methodcall="void "+methodname+"(struct "+name+"_state * "+ststate+", struct "+name+" * "+stmodel+", struct RepairHash * "+strepairtable;
                    for(int j=0;j<r.numQuantifiers();j++) {
                        Quantifier q=r.getQuantifier(j);
                        if (q instanceof SetQuantifier) {
@@ -244,20 +258,20 @@ public class RepairGenerator {
     private void generate_call() {
         CodeWriter cr = new StandardCodeWriter(outputrepair);
        VarDescriptor vdstate=VarDescriptor.makeNew("repairstate");
-       cr.outputline(name+"_state * "+vdstate.getSafeSymbol()+"=new "+name+"_state();");
+       cr.outputline("struct "+ name+"_state * "+vdstate.getSafeSymbol()+"=allocate"+name+"_state();");
        Iterator globals=state.stGlobals.descriptors();
        while (globals.hasNext()) {
            VarDescriptor vd=(VarDescriptor) globals.next();
            cr.outputline(vdstate.getSafeSymbol()+"->"+vd.getSafeSymbol()+"=("+vd.getType().getGenerateType().getSafeSymbol()+")"+vd.getSafeSymbol()+";");
        }
        /* Insert repair here */
-       cr.outputline(vdstate.getSafeSymbol()+"->doanalysis();");
+       cr.outputline("doanalysis("+vdstate.getSafeSymbol()+");");
        globals=state.stGlobals.descriptors();
        while (globals.hasNext()) {
            VarDescriptor vd=(VarDescriptor) globals.next();
            cr.outputline("*(("+vd.getType().getGenerateType().getSafeSymbol()+"*) &"+vd.getSafeSymbol()+")="+vdstate.getSafeSymbol()+"->"+vd.getSafeSymbol()+";");
        }
-       cr.outputline("delete "+vdstate.getSafeSymbol()+";");
+       cr.outputline("free"+name+"_state("+vdstate.getSafeSymbol()+");");
     }
 
     private void generate_tokentable() {
@@ -265,12 +279,12 @@ public class RepairGenerator {
         Iterator tokens = TokenLiteralExpr.tokens.keySet().iterator();
 
         cr.outputline("");
-        cr.outputline("// Token values");
+        cr.outputline("/* Token values*/");
         cr.outputline("");
 
         while (tokens.hasNext()) {
             Object token = tokens.next();
-            cr.outputline("// " + token.toString() + " = " + TokenLiteralExpr.tokens.get(token).toString());
+            cr.outputline("/* " + token.toString() + " = " + TokenLiteralExpr.tokens.get(token).toString()+"*/");
         }
 
         cr.outputline("");
@@ -279,15 +293,15 @@ public class RepairGenerator {
 
     private void generate_stateobject() {
         CodeWriter crhead = new StandardCodeWriter(outputhead);
-       crhead.outputline("class "+name+"_state {");
-       crhead.outputline("public:");
+       crhead.outputline("struct "+name+"_state {");
        Iterator globals=state.stGlobals.descriptors();
        while (globals.hasNext()) {
            VarDescriptor vd=(VarDescriptor) globals.next();
            crhead.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+";");
        }
-       crhead.outputline("void computesizes(int *,int **);");
-       crhead.outputline("void recomputesizes();");
+        crhead.outputline("};");
+       crhead.outputline("void "+name+"_statecomputesizes(struct "+name+"_state * ,int *,int **);");
+       crhead.outputline("void "+name+"_staterecomputesizes(struct "+name+"_state *);");
     }
 
     private void generate_computesizes() {
@@ -302,7 +316,7 @@ public class RepairGenerator {
                public SymbolTable getSymbolTable() { return st; }
            };
 
-       cr.outputline("void "+name+"_state::computesizes(int *sizearray,int **numele) {");
+       cr.outputline("void "+name+"_statecomputesizes(struct "+name+"_state * thisvar,int *sizearray,int **numele) {");
        cr.outputline("int maybe=0;");
        for(int i=0;i<max;i++) {
            TypeDescriptor td=tdarray[i];
@@ -342,7 +356,7 @@ public class RepairGenerator {
        CodeWriter cr = new StandardCodeWriter(outputaux) {
                public SymbolTable getSymbolTable() { return st; }
            };
-       cr.outputline("void "+name+"_state::recomputesizes() {");
+       cr.outputline("void "+name+"_staterecomputesizes(struct "+name+"_state * thisvar) {");
        cr.outputline("int maybe=0;");
        for(int i=0;i<max;i++) {
            TypeDescriptor td=tdarray[i];
@@ -376,15 +390,12 @@ public class RepairGenerator {
        crhead.outputline("#ifndef "+name+"_h");
        crhead.outputline("#define "+name+"_h");
         crhead.outputline("#include \"SimpleHash.h\"");
-       crhead.outputline("extern \"C\" {");
         crhead.outputline("#include \"instrument.h\"");
-       crhead.outputline("}");
         crhead.outputline("#include <stdio.h>");
         crhead.outputline("#include <stdlib.h>");
-       crhead.outputline("class "+name+" {");
-       crhead.outputline("public:");
-       crhead.outputline(name+"();");
-       crhead.outputline("~"+name+"();");
+       crhead.outputline("struct "+name+" * allocate"+name+"();");
+       crhead.outputline("void free"+name+"(struct "+name+" *);");
+       crhead.outputline("struct "+name+" {");
         craux.outputline("#include \""+headername+"\"");
         craux.outputline("#include \"size.h\"");
        if (Compiler.TIME) {
@@ -406,17 +417,18 @@ public class RepairGenerator {
                }
            }
        }
-        craux.outputline(name+"::"+name+"() {");
-        craux.outputline("// creating hashtables ");
+        craux.outputline("struct "+ name+"* "+name+"() {");
+        craux.outputline("/* creating hashtables */");
 
         /* build sets */
         Iterator sets = state.stSets.descriptors();
+        craux.outputline("struct "+name+"* thisvar=(struct "+name+"*) malloc(sizeof(struct "+name+"));");
 
         /* first pass create all the hash tables */
         while (sets.hasNext()) {
             SetDescriptor set = (SetDescriptor) sets.next();
-           crhead.outputline("SimpleHash* " + set.getSafeSymbol() + "_hash;");
-            craux.outputline(set.getSafeSymbol() + "_hash = new SimpleHash();");
+           crhead.outputline("struct SimpleHash* " + set.getJustSafeSymbol() + "_hash;");
+            craux.outputline(set.getSafeSymbol() + "_hash = noargallocateSimpleHash();");
         }
 
         /* second pass build relationships between hashtables */
@@ -428,7 +440,7 @@ public class RepairGenerator {
 
             while (subsets.hasNext()) {
                 SetDescriptor subset = (SetDescriptor) subsets.next();
-                craux.outputline(subset.getSafeSymbol() + "_hash->addParent(" + set.getSafeSymbol() + "_hash);");
+                craux.outputline("SimpleHashaddParent("+subset.getSafeSymbol() +"_hash ,"+ set.getSafeSymbol() + "_hash);");
             }
         }
 
@@ -440,20 +452,20 @@ public class RepairGenerator {
             RelationDescriptor relation = (RelationDescriptor) relations.next();
 
             if (relation.testUsage(RelationDescriptor.IMAGE)) {
-                crhead.outputline("SimpleHash* " + relation.getSafeSymbol() + "_hash;");
-                craux.outputline(relation.getSafeSymbol() + "_hash = new SimpleHash();");
+                crhead.outputline("struct SimpleHash* " + relation.getJustSafeSymbol() + "_hash;");
+                craux.outputline(relation.getSafeSymbol() + "_hash = noargallocateSimpleHash();");
             }
 
             if (relation.testUsage(RelationDescriptor.INVIMAGE)) {
-                crhead.outputline("SimpleHash* " + relation.getSafeSymbol() + "_hashinv;");
-                craux.outputline(relation.getSafeSymbol() + "_hashinv = new SimpleHash();");
+                crhead.outputline("struct SimpleHash* " + relation.getJustSafeSymbol() + "_hashinv;");
+                craux.outputline(relation.getSafeSymbol() + "_hashinv = noargallocateSimpleHash();");
             }
         }
 
         craux.outputline("}");
         crhead.outputline("};");
-        craux.outputline(name+"::~"+name+"() {");
-        craux.outputline("// deleting hashtables");
+        craux.outputline("void free"+name+"(struct "+ name +"* thisvar) {");
+        craux.outputline("/* deleting hashtables */");
 
         /* build destructor */
         sets = state.stSets.descriptors();
@@ -461,7 +473,7 @@ public class RepairGenerator {
         /* first pass create all the hash tables */
         while (sets.hasNext()) {
             SetDescriptor set = (SetDescriptor) sets.next();
-            craux.outputline("delete "+set.getSafeSymbol() + "_hash;");
+            craux.outputline("freeSimpleHash("+set.getSafeSymbol() + "_hash);");
         }
 
         /* destroy relations */
@@ -472,13 +484,14 @@ public class RepairGenerator {
             RelationDescriptor relation = (RelationDescriptor) relations.next();
 
             if (relation.testUsage(RelationDescriptor.IMAGE)) {
-                craux.outputline("delete "+relation.getSafeSymbol() + "_hash;");
+                craux.outputline("freeSimpleHash("+relation.getSafeSymbol() + "_hash);");
             }
 
             if (relation.testUsage(RelationDescriptor.INVIMAGE)) {
-                craux.outputline("delete " + relation.getSafeSymbol() + "_hashinv;");
+                craux.outputline("freeSimpleHash(" + relation.getSafeSymbol() + "_hashinv);");
             }
         }
+        craux.outputline("free(thisvar);");
         craux.outputline("}");
     }
 
@@ -497,31 +510,29 @@ public class RepairGenerator {
            craux.outputline("int abstractcount;");
        }
 
-       crhead.outputline("void doanalysis();");
-       craux.outputline("void "+name +"_state::doanalysis()");
+       crhead.outputline("void doanalysis(struct "+name+"_state *);");
+       craux.outputline("void doanalysis(struct "+name+"_state * thisvar)");
        craux.startblock();
        if (Compiler.TIME) {
            craux.outputline("struct timeval _begin_time,_end_time;");
            craux.outputline("gettimeofday(&_begin_time,NULL);");
        }
-
        if (Compiler.GENERATEINSTRUMENT) {
            craux.outputline("updatecount=0;");
            craux.outputline("rebuildcount=0;");
            craux.outputline("abstractcount=0;");
        }
        craux.outputline("int highmark;");
+       craux.outputline("struct "+name+ " * "+oldmodel.getSafeSymbol()+"=0;");
+        craux.outputline("struct WorkList * "+worklist.getSafeSymbol()+" = allocateWorkList();");
+       craux.outputline("struct RepairHash * "+repairtable.getSafeSymbol()+"=0;");
        craux.outputline("initializestack(&highmark);");
-       craux.outputline("typeobject *typeobject1=gettypeobject();");
-       craux.outputline("typeobject1->computesizes(this);");
-       craux.outputline("recomputesizes();");
-       craux.outputline(name+ " * "+oldmodel.getSafeSymbol()+"=0;");
-        craux.outputline("WorkList * "+worklist.getSafeSymbol()+" = new WorkList();");
-       craux.outputline("RepairHash * "+repairtable.getSafeSymbol()+"=0;");
+       craux.outputline("computesizes(thisvar);");
+       craux.outputline(name+"_staterecomputesizes(thisvar);");
        craux.outputline("while (1)");
        craux.startblock();
-       craux.outputline(name+ " * "+newmodel.getSafeSymbol()+"=new "+name+"();");
-       craux.outputline(worklist.getSafeSymbol()+"->reset();");
+       craux.outputline("struct "+name+ " * "+newmodel.getSafeSymbol()+"=allocate"+name+"();");
+       craux.outputline("WorkListreset("+worklist.getSafeSymbol()+");");
        if (Compiler.GENERATEINSTRUMENT)
            craux.outputline("rebuildcount++;");
     }
@@ -550,7 +561,7 @@ public class RepairGenerator {
                public SymbolTable getSymbolTable() { return st; }
            };
 
-       cr.outputline("// printing sets!");
+       cr.outputline("/* printing sets!*/");
        cr.outputline("printf(\"\\n\\nPRINTING SETS AND RELATIONS\\n\");");
 
         Iterator setiterator = state.stSets.descriptors();
@@ -563,13 +574,13 @@ public class RepairGenerator {
            String setname = sd.getSafeSymbol();
 
            cr.startblock();
-           cr.outputline("// printing set " + setname);
-           cr.outputline("printf(\"\\nPrinting set " + sd.getSymbol() + " - %d elements \\n\", " + setname + "_hash->count());");
-           cr.outputline("SimpleIterator __setiterator;");
-           cr.outputline("" + setname + "_hash->iterator(__setiterator);");
-           cr.outputline("while (__setiterator.hasNext())");
+           cr.outputline("/* printing set " + setname+"*/");
+           cr.outputline("printf(\"\\nPrinting set " + sd.getSymbol() + " - %d elements \\n\", SimpleHashcountset("+setname+"_hash));");
+           cr.outputline("struct SimpleIterator __setiterator;");
+           cr.outputline("SimpleHashiterator(&"+setname+"_hash,__setiterator);");
+           cr.outputline("while (hasNext(&__setiterator))");
            cr.startblock();
-           cr.outputline("int __setval = (int) __setiterator.next();");
+           cr.outputline("int __setval = (int) next(&__setiterator);");
 
            TypeDescriptor td = sd.getType();
            if (td instanceof StructureTypeDescriptor) {
@@ -612,7 +623,7 @@ public class RepairGenerator {
                        InvariantValue ivalue=new InvariantValue();
                        cr.setInvariantValue(ivalue);
 
-                       cr.outputline("// build " +escape(rule.toString()));
+                       cr.outputline("/* build " +escape(rule.toString())+"*/");
                        cr.startblock();
                        cr.outputline("int maybe=0;");
 
@@ -639,6 +650,7 @@ public class RepairGenerator {
                            }
                        }
 
+                        int openparencount=0;
                        for(Iterator invit=invariants.iterator();invit.hasNext();) {
                            Expr invexpr=(Expr)invit.next();
                            VarDescriptor tmpvd=VarDescriptor.makeNew("tmpvar");
@@ -647,8 +659,9 @@ public class RepairGenerator {
                            cr.outputline("int "+maybevd.getSafeSymbol()+"=maybe;");
                            cr.outputline("maybe=0;");
                            ivalue.assignPair(invexpr,tmpvd,maybevd);
+                            openparencount++;
+                            cr.startblock();
                        }
-
                        quantifiers = rule.quantifiers();
                        while (quantifiers.hasNext()) {
                            Quantifier quantifier = (Quantifier) quantifiers.next();
@@ -656,9 +669,9 @@ public class RepairGenerator {
                        }
 
                        /* pretty print! */
-                       cr.output("//");
+                       cr.output("/*");
                        rule.getGuardExpr().prettyPrint(cr);
-                       cr.outputline("");
+                       cr.outputline("*/");
 
                        /* now we have to generate the guard test */
                        VarDescriptor guardval = VarDescriptor.makeNew();
@@ -675,6 +688,8 @@ public class RepairGenerator {
                            cr.endblock();
                        }
                        cr.endblock();
+                        while((openparencount--)>0)
+                            cr.endblock();
                        cr.outputline("");
                        cr.outputline("");
                    }
@@ -685,13 +700,13 @@ public class RepairGenerator {
                for(Iterator initialworklist=ruleset.iterator();initialworklist.hasNext();) {
                    /** Construct initial worklist set */
                    Rule rule=(Rule)initialworklist.next();
-                   cr2.outputline(worklist.getSafeSymbol()+"->add("+rule.getNum()+",-1,0,0);");
+                   cr2.outputline("WorkListadd("+worklist.getSafeSymbol()+","+rule.getNum()+",-1,0,0);");
                }
 
-               cr2.outputline("while ("+worklist.getSafeSymbol()+"->hasMoreElements())");
+               cr2.outputline("while (WorkListhasMoreElements("+worklist.getSafeSymbol()+"))");
                cr2.startblock();
                VarDescriptor idvar=VarDescriptor.makeNew("id");
-               cr2.outputline("int "+idvar.getSafeSymbol()+"="+worklist.getSafeSymbol()+"->getid();");
+               cr2.outputline("int "+idvar.getSafeSymbol()+"=WorkListgetid("+worklist.getSafeSymbol()+");");
 
                String elseladder = "if";
 
@@ -714,10 +729,10 @@ public class RepairGenerator {
                        VarDescriptor typevar=VarDescriptor.makeNew("type");
                        VarDescriptor leftvar=VarDescriptor.makeNew("left");
                        VarDescriptor rightvar=VarDescriptor.makeNew("right");
-                       cr.outputline("int "+typevar.getSafeSymbol()+"="+worklist.getSafeSymbol()+"->gettype();");
-                       cr.outputline("int "+leftvar.getSafeSymbol()+"="+worklist.getSafeSymbol()+"->getlvalue();");
-                       cr.outputline("int "+rightvar.getSafeSymbol()+"="+worklist.getSafeSymbol()+"->getrvalue();");
-                       cr.outputline("// build " +escape(rule.toString()));
+                       cr.outputline("int "+typevar.getSafeSymbol()+"= WorkListgettype("+worklist.getSafeSymbol()+");");
+                       cr.outputline("int "+leftvar.getSafeSymbol()+"= WorkListgetlvalue("+worklist.getSafeSymbol()+");");
+                       cr.outputline("int "+rightvar.getSafeSymbol()+"= WorkListgetrvalue("+worklist.getSafeSymbol()+");");
+                       cr.outputline("/* build " +escape(rule.toString())+"*/");
 
 
                        for (int j=0;j<rule.numQuantifiers();j++) {
@@ -726,10 +741,10 @@ public class RepairGenerator {
                        }
 
                        /* pretty print! */
-                       cr.output("//");
+                       cr.output("/*");
 
                        rule.getGuardExpr().prettyPrint(cr);
-                       cr.outputline("");
+                       cr.outputline("*/");
 
                        /* now we have to generate the guard test */
 
@@ -762,7 +777,7 @@ public class RepairGenerator {
                cr2.outputline("exit(1);");
                cr2.endblock();
                // end block created for worklist
-               cr2.outputline(worklist.getSafeSymbol()+"->pop();");
+               cr2.outputline("WorkListpop("+worklist.getSafeSymbol()+");");
                cr2.endblock();
            }
        }
@@ -799,7 +814,7 @@ public class RepairGenerator {
                CodeWriter cr = new StandardCodeWriter(outputaux);
                cr.pushSymbolTable(constraint.getSymbolTable());
 
-               cr.outputline("// checking " + escape(constraint.toString()));
+               cr.outputline("/* checking " + escape(constraint.toString())+"*/");
                 cr.startblock();
 
                 ListIterator quantifiers = constraint.quantifiers();
@@ -830,9 +845,10 @@ public class RepairGenerator {
                if (Compiler.REPAIR) {
                /* Do repairs */
                /* Build new repair table */
+
                cr.outputline("if ("+repairtable.getSafeSymbol()+")");
-               cr.outputline("delete "+repairtable.getSafeSymbol()+";");
-                cr.outputline(repairtable.getSafeSymbol()+"=new RepairHash();");
+               cr.outputline("freeRepairHash("+repairtable.getSafeSymbol()+");");
+                cr.outputline(repairtable.getSafeSymbol()+"=noargallocateRepairHash();");
 
                if (Compiler.GENERATEDEBUGHOOKS)
                    cr.outputline("debughook();");
@@ -925,7 +941,7 @@ public class RepairGenerator {
                cr.outputline("}");
 
                cr.outputline("if ("+oldmodel.getSafeSymbol()+")");
-               cr.outputline("delete "+oldmodel.getSafeSymbol()+";");
+               cr.outputline("free"+name+"("+oldmodel.getSafeSymbol()+");");
                cr.outputline(oldmodel.getSafeSymbol()+"="+newmodel.getSafeSymbol()+";");
                cr.outputline("goto rebuild;");  /* Rebuild model and all */
                }
@@ -943,11 +959,11 @@ public class RepairGenerator {
        CodeWriter cr = new StandardCodeWriter(outputaux);
        cr.startblock();
        cr.outputline("if ("+repairtable.getSafeSymbol()+")");
-       cr.outputline("delete "+repairtable.getSafeSymbol()+";");
+       cr.outputline("freeRepairHash("+repairtable.getSafeSymbol()+");");
        cr.outputline("if ("+oldmodel.getSafeSymbol()+")");
-       cr.outputline("delete "+oldmodel.getSafeSymbol()+";");
-       cr.outputline("delete "+newmodel.getSafeSymbol()+";");
-       cr.outputline("delete "+worklist.getSafeSymbol()+";");
+       cr.outputline("free"+name+"("+oldmodel.getSafeSymbol()+");");
+       cr.outputline("free"+name+"("+newmodel.getSafeSymbol()+");");
+       cr.outputline("freeWorkList("+worklist.getSafeSymbol()+");");
        cr.outputline("resettypemap();");
        cr.outputline("break;");
        cr.endblock();
@@ -1051,12 +1067,12 @@ public class RepairGenerator {
            ((RelationExpr)expr.getLeftExpr()).getExpr().generate(cr,leftside);
            expr.getRightExpr().generate(cr,newvalue);
            cr.outputline(rd.getRange().getType().getGenerateType().getSafeSymbol()+" "+rightside.getSafeSymbol()+";");
-           cr.outputline(rd.getSafeSymbol()+"_hash->get("+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+");");
+           cr.outputline("SimpleHashget("+rd.getSafeSymbol()+"_hash,"+leftside.getSafeSymbol()+", &"+rightside.getSafeSymbol()+");");
        } else {
            ((RelationExpr)expr.getLeftExpr()).getExpr().generate(cr,rightside);
            expr.getRightExpr().generate(cr,newvalue);
            cr.outputline(rd.getDomain().getType().getGenerateType().getSafeSymbol()+" "+leftside.getSafeSymbol()+";");
-           cr.outputline(rd.getSafeSymbol()+"_hashinv->get("+rightside.getSafeSymbol()+","+leftside.getSafeSymbol()+");");
+           cr.outputline("SimpleHashget("+rd.getSafeSymbol()+"_hashinv,"+rightside.getSafeSymbol()+", &"+leftside.getSafeSymbol()+");");
        }
 
        opcode=Opcode.translateOpcode(negated,opcode);
@@ -1078,17 +1094,17 @@ public class RepairGenerator {
        }
        /* Do abstract repairs */
        if (usageimage) {
-           cr.outputline(rd.getSafeSymbol()+"_hash->remove("+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+");");
+           cr.outputline("SimpleHashremove("+rd.getSafeSymbol()+"_hash, "+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+");");
        }
        if (usageinvimage) {
-           cr.outputline(rd.getSafeSymbol()+"_hashinv->remove("+rightside.getSafeSymbol()+","+leftside.getSafeSymbol()+");");
+           cr.outputline("SimpleHashremove("+rd.getSafeSymbol()+"_hashinv, "+rightside.getSafeSymbol()+","+leftside.getSafeSymbol()+");");
        }
 
        if (needremoveloop) {
            if (!inverted) {
-               cr.outputline("if ("+rd.getSafeSymbol()+"_hash->contains("+leftside.getSafeSymbol()+")) {");
+               cr.outputline("if (SimpleHashcontainskey("+rd.getSafeSymbol()+"_hash, "+leftside.getSafeSymbol()+")) {");
            } else {
-               cr.outputline("if ("+rd.getSafeSymbol()+"_hashinv->contains("+rightside.getSafeSymbol()+")) {");
+               cr.outputline("if (SimpleHashcontainskey("+rd.getSafeSymbol()+"_hashinv, "+rightside.getSafeSymbol()+")) {");
            }
            for(int i=0;i<state.vRules.size();i++) {
                Rule r=(Rule)state.vRules.get(i);
@@ -1098,7 +1114,7 @@ public class RepairGenerator {
                        if (un.getRule()==r) {
                                /* Update for rule r */
                            String name=(String)updatenames.get(un);
-                           cr.outputline(repairtable.getSafeSymbol()+"->addrelation("+rd.getNum()+","+r.getNum()+","+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+",(int) &"+name+");");
+                           cr.outputline("RepairHashaddrelation("+repairtable.getSafeSymbol()+","+rd.getNum()+","+r.getNum()+","+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+",(int) &"+name+");");
                        }
                    }
                }
@@ -1109,16 +1125,16 @@ public class RepairGenerator {
 
        if (usageimage) {
            if (!inverted) {
-               cr.outputline(rd.getSafeSymbol()+"_hash->add("+leftside.getSafeSymbol()+","+newvalue.getSafeSymbol()+");");
+               cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hash,"+leftside.getSafeSymbol()+","+newvalue.getSafeSymbol()+");");
            } else {
-               cr.outputline(rd.getSafeSymbol()+"_hash->add("+newvalue.getSafeSymbol()+","+rightside.getSafeSymbol()+");");
+               cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hash, "+newvalue.getSafeSymbol()+","+rightside.getSafeSymbol()+");");
            }
        }
        if (usageinvimage) {
            if (!inverted) {
-               cr.outputline(rd.getSafeSymbol()+"_hashinv->add("+newvalue.getSafeSymbol()+","+leftside.getSafeSymbol()+");");
+               cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hashinv, "+newvalue.getSafeSymbol()+","+leftside.getSafeSymbol()+");");
            } else {
-               cr.outputline(rd.getSafeSymbol()+"_hashinv->add("+rightside.getSafeSymbol()+","+newvalue.getSafeSymbol()+");");
+               cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hashinv,"+rightside.getSafeSymbol()+","+newvalue.getSafeSymbol()+");");
            }
        }
        /* Do concrete repairs */
@@ -1131,7 +1147,7 @@ public class RepairGenerator {
                        if (un.getRule()==r) {
                            /* Update for rule r */
                            String name=(String)updatenames.get(un);
-                           cr.outputline(repairtable.getSafeSymbol()+"->addrelation("+rd.getNum()+","+r.getNum()+","+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+",(int) &"+name+","+newvalue.getSafeSymbol()+");");
+                           cr.outputline("RepairHashaddrelation2("+repairtable.getSafeSymbol()+","+rd.getNum()+","+r.getNum()+","+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+",(int) &"+name+","+newvalue.getSafeSymbol()+");");
                        }
                    }
                }
@@ -1147,7 +1163,7 @@ public class RepairGenerator {
                            if (un.getRule()==r) {
                                /* Update for rule r */
                                String name=(String)updatenames.get(un);
-                               cr.outputline(repairtable.getSafeSymbol()+"->addrelation("+rd.getNum()+","+r.getNum()+","+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+",(int) &"+name+");");
+                               cr.outputline("RepairHashaddrelation("+repairtable.getSafeSymbol()+","+rd.getNum()+","+r.getNum()+","+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+",(int) &"+name+");");
                            }
                        }
                    }
@@ -1156,9 +1172,9 @@ public class RepairGenerator {
            UpdateNode un=munadd.getUpdate(0);
            String name=(String)updatenames.get(un);
            if (!inverted) {
-               cr.outputline(name+"(this,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+leftside.getSafeSymbol()+","+newvalue.getSafeSymbol()+");");
+               cr.outputline(name+"(thisvar,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+leftside.getSafeSymbol()+","+newvalue.getSafeSymbol()+");");
            } else {
-               cr.outputline(name+"(this,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+newvalue.getSafeSymbol()+","+rightside.getSafeSymbol()+");");
+               cr.outputline(name+"(thisvar,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+newvalue.getSafeSymbol()+","+rightside.getSafeSymbol()+");");
            }
        }
        if (needremoveloop) {
@@ -1237,14 +1253,14 @@ public class RepairGenerator {
                if (ep.inverted()) {
                    ((ImageSetExpr)((SizeofExpr)expr.left).setexpr).generate_leftside(cr,rightvar);
                    cr.outputline("int "+leftvar.getSafeSymbol()+";");
-                   cr.outputline(d.getSafeSymbol()+"_hashinv->get((int)"+rightvar.getSafeSymbol()+","+leftvar.getSafeSymbol()+");");
+                   cr.outputline("SimpleHashget("+d.getSafeSymbol()+"_hashinv,(int)"+rightvar.getSafeSymbol()+", &"+leftvar.getSafeSymbol()+");");
                } else {
                    ((ImageSetExpr)((SizeofExpr)expr.left).setexpr).generate_leftside(cr,leftvar);
                    cr.outputline("int "+rightvar.getSafeSymbol()+"=0;");
-                   cr.outputline(d.getSafeSymbol()+"_hash->get((int)"+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+");");
+                   cr.outputline("SimpleHashget("+d.getSafeSymbol()+"_hash ,(int)"+leftvar.getSafeSymbol()+", &"+rightvar.getSafeSymbol()+");");
                }
            } else {
-               cr.outputline("int "+leftvar.getSafeSymbol()+"="+d.getSafeSymbol()+"_hash->firstkey();");
+               cr.outputline("int "+leftvar.getSafeSymbol()+"= SimpleHashfirstkey("+d.getSafeSymbol()+"_hash);");
            }
            /* Generate abstract remove instruction */
            if (d instanceof RelationDescriptor) {
@@ -1252,11 +1268,11 @@ public class RepairGenerator {
                boolean usageimage=rd.testUsage(RelationDescriptor.IMAGE);
                boolean usageinvimage=rd.testUsage(RelationDescriptor.INVIMAGE);
                if (usageimage)
-                   cr.outputline(rd.getSafeSymbol() + "_hash->remove((int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
+                   cr.outputline("SimpleHashremove("+rd.getSafeSymbol()+"_hash, (int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
                if (usageinvimage)
-                   cr.outputline(rd.getSafeSymbol() + "_hashinv->remove((int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+                   cr.outputline("SimpleHashremove("+rd.getSafeSymbol()+"_hashinv ,(int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
            } else {
-               cr.outputline(d.getSafeSymbol() + "_hash->remove((int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+               cr.outputline("SimpleHashremove("+d.getSafeSymbol()+"_hash, (int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
            }
            /* Generate concrete remove instruction */
            for(int i=0;i<state.vRules.size();i++) {
@@ -1268,9 +1284,9 @@ public class RepairGenerator {
                                /* Update for rule rule r */
                            String name=(String)updatenames.get(un);
                            if (d instanceof RelationDescriptor) {
-                               cr.outputline(repairtable.getSafeSymbol()+"->addrelation("+d.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+",(int) &"+name+");");
+                               cr.outputline("RepairHashaddrelation("+repairtable.getSafeSymbol()+","+d.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+",(int) &"+name+");");
                            } else {
-                               cr.outputline(repairtable.getSafeSymbol()+"->addset("+d.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+",(int) &"+name+");");
+                               cr.outputline("RepairHashaddset("+repairtable.getSafeSymbol()+","+d.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+",(int) &"+name+");");
                            }
                        }
                    }
@@ -1299,16 +1315,16 @@ public class RepairGenerator {
                    SetDescriptor sd=termination.sources.relgetSourceSet(rd,!ep.inverted());
                    VarDescriptor iterator=VarDescriptor.makeNew("iterator");
                    cr.outputline(sd.getType().getGenerateType().getSafeSymbol() +" "+newobject.getSafeSymbol()+";");
-                   cr.outputline("SimpleIterator "+iterator.getSafeSymbol()+";");
-                   cr.outputline("for("+sd.getSafeSymbol()+"_hash->iterator("+ iterator.getSafeSymbol() +");"+iterator.getSafeSymbol()+".hasNext();)");
+                   cr.outputline("struct SimpleIterator "+iterator.getSafeSymbol()+";");
+                   cr.outputline("for(SimpleHashiterator(& "+sd.getSafeSymbol()+"_hash ,"+ iterator.getSafeSymbol() +");"+iterator.getSafeSymbol()+".hasNext();)");
                    cr.startblock();
                    if (ep.inverted()) {
-                       cr.outputline("if (!"+rd.getSafeSymbol()+"_hashinv->contains("+iterator.getSafeSymbol()+".key(),"+otherside.getSafeSymbol()+"))");
+                       cr.outputline("if (!SimpleHashcontainskeydata("+rd.getSafeSymbol()+"_hashinv,"+iterator.getSafeSymbol()+".key(),"+otherside.getSafeSymbol()+"))");
                    } else {
-                       cr.outputline("if (!"+rd.getSafeSymbol()+"_hash->contains("+otherside.getSafeSymbol()+","+iterator.getSafeSymbol()+".key()))");
+                       cr.outputline("if (!SimpleHashcontainskeydata("+rd.getSafeSymbol()+"_hash, "+otherside.getSafeSymbol()+","+iterator.getSafeSymbol()+".key()))");
                    }
-                   cr.outputline(newobject.getSafeSymbol()+"="+iterator.getSafeSymbol()+".key();");
-                   cr.outputline(iterator.getSafeSymbol()+".next();");
+                   cr.outputline(newobject.getSafeSymbol()+"=key("+iterator.getSafeSymbol()+");");
+                   cr.outputline("next("+iterator.getSafeSymbol()+");");
                    cr.endblock();
                } else if (termination.sources.relallocSource(rd,!ep.inverted())) {
                    /* Allocation Source*/
@@ -1318,23 +1334,23 @@ public class RepairGenerator {
                    boolean usageimage=rd.testUsage(RelationDescriptor.IMAGE);
                    boolean usageinvimage=rd.testUsage(RelationDescriptor.INVIMAGE);
                    if (usageimage)
-                       cr.outputline(rd.getSafeSymbol()+"_hash->add("+newobject.getSafeSymbol()+","+otherside.getSafeSymbol()+");");
+                       cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hash, "+newobject.getSafeSymbol()+","+otherside.getSafeSymbol()+");");
                    if (usageinvimage)
-                       cr.outputline(rd.getSafeSymbol()+"_hashinv->add("+otherside.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
+                       cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hashinv, "+otherside.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
 
                    UpdateNode un=munadd.getUpdate(0);
                    String name=(String)updatenames.get(un);
-                   cr.outputline(name+"(this,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+newobject.getSafeSymbol()+","+otherside.getSafeSymbol()+");");
+                   cr.outputline(name+"(thisvar,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+newobject.getSafeSymbol()+","+otherside.getSafeSymbol()+");");
                } else {
                    boolean usageimage=rd.testUsage(RelationDescriptor.IMAGE);
                    boolean usageinvimage=rd.testUsage(RelationDescriptor.INVIMAGE);
                    if (usageimage)
-                       cr.outputline(rd.getSafeSymbol()+"_hash->add("+otherside.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
+                       cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hash, "+otherside.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
                    if (usageinvimage)
-                       cr.outputline(rd.getSafeSymbol()+"_hashinv->add("+newobject.getSafeSymbol()+","+otherside.getSafeSymbol()+");");
+                       cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hashinv, "+newobject.getSafeSymbol()+","+otherside.getSafeSymbol()+");");
                    UpdateNode un=munadd.getUpdate(0);
                    String name=(String)updatenames.get(un);
-                   cr.outputline(name+"(this,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+otherside.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
+                   cr.outputline(name+"(thisvar, "+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+otherside.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
                }
            } else {
                SetDescriptor sd=(SetDescriptor)d;
@@ -1345,20 +1361,20 @@ public class RepairGenerator {
                    VarDescriptor iterator=VarDescriptor.makeNew("iterator");
                    cr.outputline(sourcesd.getType().getGenerateType().getSafeSymbol() +" "+newobject.getSafeSymbol()+";");
                    cr.outputline("SimpleIterator "+iterator.getSafeSymbol()+";");
-                   cr.outputline("for("+sourcesd.getSafeSymbol()+"_hash->iterator("+iterator.getSafeSymbol()+");"+iterator.getSafeSymbol()+".hasNext();)");
+                   cr.outputline("for(SimpleHashiterator("+sourcesd.getSafeSymbol()+"_hash, "+iterator.getSafeSymbol()+");"+iterator.getSafeSymbol()+".hasNext();)");
                    cr.startblock();
-                   cr.outputline("if (!"+sd.getSafeSymbol()+"_hash->contains("+iterator.getSafeSymbol()+".key()))");
-                   cr.outputline(newobject.getSafeSymbol()+"="+iterator.getSafeSymbol()+".key();");
-                   cr.outputline(iterator.getSafeSymbol()+".next();");
+                   cr.outputline("if (!SimpleHashcontainskey("+sd.getSafeSymbol()+"_hash, key("+iterator.getSafeSymbol()+")))");
+                   cr.outputline(newobject.getSafeSymbol()+"=key("+iterator.getSafeSymbol()+");");
+                   cr.outputline("next("+iterator.getSafeSymbol()+");");
                    cr.endblock();
                } else if (termination.sources.allocSource(sd)) {
                    /* Allocation Source*/
                    termination.sources.generateSourceAlloc(cr,newobject,sd);
                } else throw new Error("No source for adding to Set");
-               cr.outputline(sd.getSafeSymbol()+"_hash->add("+newobject.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
+               cr.outputline("SimpleHashadd("+sd.getSafeSymbol()+"_hash, "+newobject.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
                UpdateNode un=munadd.getUpdate(0);
                String name=(String)updatenames.get(un);
-               cr.outputline(name+"(this,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
+               cr.outputline(name+"(thisvar,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+newobject.getSafeSymbol()+");");
            }
            cr.endblock();
        }
@@ -1381,14 +1397,14 @@ public class RepairGenerator {
                boolean usageinvimage=rd.testUsage(RelationDescriptor.INVIMAGE);
                if (inverse) {
                    if (usageimage)
-                       cr.outputline(rd.getSafeSymbol() + "_hash->remove((int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+                       cr.outputline("SimpleHashremove("+rd.getSafeSymbol()+"_hash, (int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
                    if (usageinvimage)
-                       cr.outputline(rd.getSafeSymbol() + "_hashinv->remove((int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
+                       cr.outputline("SimpleHashremove("+rd.getSafeSymbol()+"_hashinv, (int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
                } else {
                    if (usageimage)
-                       cr.outputline(rd.getSafeSymbol() + "_hash->remove((int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
+                       cr.outputline("SimpleHashremove("+rd.getSafeSymbol()+"_hash ,(int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
                    if (usageinvimage)
-                       cr.outputline(rd.getSafeSymbol() + "_hashinv->remove((int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+                       cr.outputline("SimpleHashremove("+rd.getSafeSymbol()+"_hashinv, (int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
                }
                for(int i=0;i<state.vRules.size();i++) {
                    Rule r=(Rule)state.vRules.get(i);
@@ -1399,9 +1415,9 @@ public class RepairGenerator {
                                /* Update for rule rule r */
                                String name=(String)updatenames.get(un);
                                if (inverse) {
-                                   cr.outputline(repairtable.getSafeSymbol()+"->addrelation("+rd.getNum()+","+r.getNum()+","+rightvar.getSafeSymbol()+","+leftvar.getSafeSymbol()+",(int) &"+name+");");
+                                   cr.outputline("RepairHashaddrelation("+repairtable.getSafeSymbol()+","+rd.getNum()+","+r.getNum()+","+rightvar.getSafeSymbol()+","+leftvar.getSafeSymbol()+",(int) &"+name+");");
                                } else {
-                                   cr.outputline(repairtable.getSafeSymbol()+"->addrelation("+rd.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+",(int) &"+name+");");
+                                   cr.outputline("RepairHashaddrelation("+repairtable.getSafeSymbol()+","+rd.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+",(int) &"+name+");");
                                }
                            }
                        }
@@ -1409,7 +1425,7 @@ public class RepairGenerator {
                }
            } else {
                SetDescriptor sd=ip.setexpr.sd;
-               cr.outputline(sd.getSafeSymbol() + "_hash->remove((int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+               cr.outputline("SimpleHashremove("+sd.getSafeSymbol()+"_hash, (int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
 
                for(int i=0;i<state.vRules.size();i++) {
                    Rule r=(Rule)state.vRules.get(i);
@@ -1419,7 +1435,7 @@ public class RepairGenerator {
                            if (un.getRule()==r) {
                                /* Update for rule rule r */
                                String name=(String)updatenames.get(un);
-                               cr.outputline(repairtable.getSafeSymbol()+"->addset("+sd.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+",(int) &"+name+");");
+                               cr.outputline("RepairHashaddset("+repairtable.getSafeSymbol()+","+sd.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+",(int) &"+name+");");
                            }
                        }
                    }
@@ -1436,30 +1452,30 @@ public class RepairGenerator {
                boolean usageinvimage=rd.testUsage(RelationDescriptor.INVIMAGE);
                if (inverse) {
                    if (usageimage)
-                       cr.outputline(rd.getSafeSymbol() + "_hash->add((int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+                       cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hash, (int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
                    if (usageinvimage)
-                       cr.outputline(rd.getSafeSymbol() + "_hashinv->add((int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
+                       cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hashinv, (int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
                } else {
                    if (usageimage)
-                       cr.outputline(rd.getSafeSymbol() + "_hash->add((int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
+                       cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hash, (int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
                    if (usageinvimage)
-                       cr.outputline(rd.getSafeSymbol() + "_hashinv->add((int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+                       cr.outputline("SimpleHashadd("+rd.getSafeSymbol()+"_hashinv, (int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
                }
                UpdateNode un=mun.getUpdate(0);
                String name=(String)updatenames.get(un);
                if (inverse) {
-                   cr.outputline(name+"(this,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+rightvar.getSafeSymbol()+","+leftvar.getSafeSymbol()+");");
+                   cr.outputline(name+"(thisvar,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+rightvar.getSafeSymbol()+","+leftvar.getSafeSymbol()+");");
                } else {
-                   cr.outputline(name+"(this,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+");");
+                   cr.outputline(name+"(thisvar,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+");");
                }
            } else {
                SetDescriptor sd=ip.setexpr.sd;
-               cr.outputline(sd.getSafeSymbol() + "_hash->add((int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+               cr.outputline("SimpleHashadd("+sd.getSafeSymbol()+"_hash, (int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
 
                UpdateNode un=mun.getUpdate(0);
                /* Update for rule rule r */
                String name=(String)updatenames.get(un);
-               cr.outputline(name+"(this,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+leftvar.getSafeSymbol()+");");
+               cr.outputline(name+"(thisvar,"+newmodel.getSafeSymbol()+","+repairtable.getSafeSymbol()+","+leftvar.getSafeSymbol()+");");
            }
        }
     }
@@ -1526,24 +1542,24 @@ public class RepairGenerator {
        if (!(usageinvimage||usageimage)) /* not used at all*/
            return;
 
-        cr.outputline("// RELATION DISPATCH ");
+        cr.outputline("/* RELATION DISPATCH */");
        if (Compiler.REPAIR) {
            cr.outputline("if ("+oldmodel.getSafeSymbol()+"&&");
            if (usageimage)
-               cr.outputline("!"+oldmodel.getSafeSymbol() +"->"+rd.getJustSafeSymbol()+"_hash->contains("+leftvar+","+rightvar+"))");
+               cr.outputline("!SimpleHashcontainskeydata("+oldmodel.getSafeSymbol()+"->"+rd.getJustSafeSymbol() + "_hash, "+leftvar+","+rightvar+"))");
            else
-               cr.outputline("!"+oldmodel.getSafeSymbol() +"->"+rd.getJustSafeSymbol()+"_hashinv->contains("+rightvar+","+leftvar+"))");
+               cr.outputline("!SimpleHashcontainskeydata("+oldmodel.getSafeSymbol() +"->"+rd.getJustSafeSymbol()+"_hashinv, "+rightvar+","+leftvar+"))");
 
            cr.startblock(); {
                /* Adding new item */
                /* Perform safety checks */
                cr.outputline("if ("+repairtable.getSafeSymbol()+"&&");
-               cr.outputline(repairtable.getSafeSymbol()+"->containsrelation("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+"))");
+               cr.outputline("RepairHashcontainsrelation("+repairtable.getSafeSymbol()+","+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+"))");
                cr.startblock(); {
                    /* Have update to call into */
                    VarDescriptor mdfyptr=VarDescriptor.makeNew("modifyptr");
                    VarDescriptor ismdfyptr=VarDescriptor.makeNew("ismodifyptr");
-                   cr.outputline("int "+ismdfyptr.getSafeSymbol()+"="+repairtable.getSafeSymbol()+"->ismodify("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
+                   cr.outputline("int "+ismdfyptr.getSafeSymbol()+"=RepairHashismodify("+repairtable.getSafeSymbol()+","+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
 
 
 
@@ -1558,7 +1574,7 @@ public class RepairGenerator {
                    VarDescriptor funptr=VarDescriptor.makeNew("updateptr");
                    VarDescriptor tmpptr=VarDescriptor.makeNew("tempupdateptr");
 
-                   String methodcall="("+funptr.getSafeSymbol()+") (this,"+oldmodel.getSafeSymbol()+","+repairtable.getSafeSymbol();
+                   String methodcall="("+funptr.getSafeSymbol()+") (thisvar,"+oldmodel.getSafeSymbol()+","+repairtable.getSafeSymbol();
                    for(int i=0;i<currentrule.numQuantifiers();i++) {
                        Quantifier q=currentrule.getQuantifier(i);
                        if (q instanceof SetQuantifier) {
@@ -1577,23 +1593,23 @@ public class RepairGenerator {
 
 
                    cr.outputline("void *"+tmpptr.getSafeSymbol()+"=");
-                   cr.outputline("(void *) "+repairtable.getSafeSymbol()+"->getrelation("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
+                   cr.outputline("(void *) RepairHashgetrelation("+repairtable.getSafeSymbol()+","+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
                    cr.outputline("if ("+ismdfyptr.getSafeSymbol()+")");
                    {
                        cr.startblock();
-                       cr.outputline("int "+mdfyptr.getSafeSymbol()+"="+repairtable.getSafeSymbol()+"->getrelation2("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
-                       cr.outputline("void (*"+funptr.getSafeSymbol()+") ("+name+"_state *,"+name+"*,RepairHash *"+parttype+",int,int,int)="+"(void (*) ("+name+"_state *,"+name+"*,RepairHash *"+parttype+",int,int,int)) "+tmpptr.getSafeSymbol()+";");
+                       cr.outputline("int "+mdfyptr.getSafeSymbol()+"=RepairHashgetrelation2("+repairtable.getSafeSymbol()+","+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
+                       cr.outputline("void (*"+funptr.getSafeSymbol()+") (struct "+name+"_state *, struct "+name+"*, struct RepairHash *"+parttype+",int,int,int)="+"(void (*) (struct "+name+"_state *, struct "+name+"*, struct RepairHash *"+parttype+",int,int,int)) "+tmpptr.getSafeSymbol()+";");
                        cr.outputline(methodcall+","+leftvar+", "+rightvar+", "+mdfyptr.getSafeSymbol() +");");
                        cr.endblock();
                    }
                    cr.outputline("else ");
                    {
                        cr.startblock();
-                       cr.outputline("void (*"+funptr.getSafeSymbol()+") ("+name+"_state *,"+name+"*,RepairHash *"+parttype+")="+"(void (*) ("+name+"_state *,"+name+"*,RepairHash *"+parttype+")) "+tmpptr.getSafeSymbol()+";");
+                       cr.outputline("void (*"+funptr.getSafeSymbol()+") (struct "+name+"_state *, struct "+name+"*,struct RepairHash *"+parttype+")="+"(void (*) (struct "+name+"_state *,struct "+name+"*,struct RepairHash *"+parttype+")) "+tmpptr.getSafeSymbol()+";");
                        cr.outputline(methodcall+");");
                        cr.endblock();
                    }
-                   cr.outputline("delete "+newmodel.getSafeSymbol()+";");
+                   cr.outputline("free"+name+"("+newmodel.getSafeSymbol()+");");
                    cr.outputline("goto rebuild;");
                }
                cr.endblock();
@@ -1603,7 +1619,7 @@ public class RepairGenerator {
                    UpdateNode un=find_compensation(currentrule);
                    String name=(String)updatenames.get(un);
                    usedupdates.add(un); /* Mark as used */
-                   String methodcall=name+"(this,"+oldmodel.getSafeSymbol()+","+repairtable.getSafeSymbol();
+                   String methodcall=name+"(thisvar,"+oldmodel.getSafeSymbol()+","+repairtable.getSafeSymbol();
                    for(int i=0;i<currentrule.numQuantifiers();i++) {
                        Quantifier q=currentrule.getQuantifier(i);
                        if (q instanceof SetQuantifier) {
@@ -1620,7 +1636,7 @@ public class RepairGenerator {
                    }
                    methodcall+=");";
                    cr.outputline(methodcall);
-                   cr.outputline("delete "+newmodel.getSafeSymbol()+";");
+                   cr.outputline("free"+name+"("+newmodel.getSafeSymbol()+");");
                    cr.outputline("goto rebuild;");
                }
            }
@@ -1628,6 +1644,7 @@ public class RepairGenerator {
        }
 
         String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
+        cr.startblock();
        cr.outputline("int " + addeditem + "=0;");
 
        String ifstring="if (!maybe";
@@ -1643,12 +1660,12 @@ public class RepairGenerator {
 
        if (rd.testUsage(RelationDescriptor.IMAGE)) {
            cr.outputline(ifstring);
-           cr.outputline(addeditem + " = " + rd.getSafeSymbol() + "_hash->add((int)" + leftvar + ", (int)" + rightvar+ ");");
+           cr.outputline(addeditem + " = SimpleHashadd("+rd.getSafeSymbol()+"_hash, (int)" + leftvar + ", (int)" + rightvar+ ");");
        }
 
        if (rd.testUsage(RelationDescriptor.INVIMAGE)) {
            cr.outputline(ifstring);
-           cr.outputline(addeditem + " = " + rd.getSafeSymbol() + "_hashinv->add((int)" + rightvar + ", (int)" + leftvar + ");");
+           cr.outputline(addeditem + " = SimpleHashadd("+rd.getSafeSymbol()+"_hashinv, (int)" + rightvar + ", (int)" + leftvar + ");");
        }
 
 
@@ -1662,7 +1679,8 @@ public class RepairGenerator {
        }
        dispatchrules.removeAll(toremove);
         if (dispatchrules.size() == 0) {
-            cr.outputline("// nothing to dispatch");
+            cr.outputline("/* nothing to dispatch */");
+            cr.endblock();
             return;
         }
 
@@ -1673,32 +1691,32 @@ public class RepairGenerator {
             Rule rule = (Rule) dispatchrules.elementAt(i);
            if (rule.getGuardExpr().getRequiredDescriptors().contains(rd)) {
                /* Guard depends on this relation, so we recomput everything */
-               cr.outputline(worklist.getSafeSymbol()+"->add("+rule.getNum()+",-1,0,0);");
+               cr.outputline("WorkListadd("+worklist.getSafeSymbol()+","+rule.getNum()+",-1,0,0);");
            } else {
                for (int j=0;j<rule.numQuantifiers();j++) {
                    Quantifier q=rule.getQuantifier(j);
                    if (q.getRequiredDescriptors().contains(rd)) {
                        /* Generate add */
-                       cr.outputline(worklist.getSafeSymbol()+"->add("+rule.getNum()+","+j+","+leftvar+","+rightvar+");");
+                       cr.outputline("WorkListadd("+worklist.getSafeSymbol()+","+rule.getNum()+","+j+","+leftvar+","+rightvar+");");
                    }
                }
            }
         }
-
+        cr.endblock();
        cr.endblock();
     }
 
 
     public void generate_dispatch(CodeWriter cr, SetDescriptor sd, String setvar) {
-       cr.outputline("// SET DISPATCH ");
+       cr.outputline("/* SET DISPATCH */");
        if (Compiler.REPAIR) {
            cr.outputline("if ("+oldmodel.getSafeSymbol()+"&&");
-           cr.outputline("!"+oldmodel.getSafeSymbol() +"->"+sd.getJustSafeSymbol()+"_hash->contains("+setvar+"))");
+           cr.outputline("!SimpleHashcontainskey("+oldmodel.getSafeSymbol() +"->"+sd.getJustSafeSymbol()+"_hash, "+setvar+"))");
            cr.startblock(); {
                /* Adding new item */
                /* See if there is an outstanding update in the repairtable */
                cr.outputline("if ("+repairtable.getSafeSymbol()+"&&");
-               cr.outputline(repairtable.getSafeSymbol()+"->containsset("+sd.getNum()+","+currentrule.getNum()+","+setvar+"))");
+               cr.outputline("RepairHashcontainsset("+repairtable.getSafeSymbol()+","+sd.getNum()+","+currentrule.getNum()+","+setvar+"))");
                cr.startblock(); {
                    /* Have update to call into */
                    VarDescriptor funptr=VarDescriptor.makeNew("updateptr");
@@ -1709,9 +1727,9 @@ public class RepairGenerator {
                        else
                            parttype=parttype+", int";
                    }
-                   cr.outputline("void (*"+funptr.getSafeSymbol()+") ("+name+"_state *,"+name+"*,RepairHash *"+parttype+")=");
-                   cr.outputline("(void (*) ("+name+"_state *,"+name+"*,RepairHash *"+parttype+")) "+repairtable.getSafeSymbol()+"->getset("+sd.getNum()+","+currentrule.getNum()+","+setvar+");");
-                   String methodcall="("+funptr.getSafeSymbol()+") (this,"+oldmodel.getSafeSymbol()+","+
+                   cr.outputline("void (*"+funptr.getSafeSymbol()+") (struct "+name+"_state *,struct "+name+"*,struct RepairHash *"+parttype+")=");
+                   cr.outputline("(void (*) (struct "+name+"_state *,struct "+name+"*,struct RepairHash *"+parttype+")) RepairHashgetset("+repairtable.getSafeSymbol()+","+sd.getNum()+","+currentrule.getNum()+","+setvar+");");
+                   String methodcall="("+funptr.getSafeSymbol()+") (thisvar,"+oldmodel.getSafeSymbol()+","+
                        repairtable.getSafeSymbol();
                    for(int i=0;i<currentrule.numQuantifiers();i++) {
                        Quantifier q=currentrule.getQuantifier(i);
@@ -1729,7 +1747,7 @@ public class RepairGenerator {
                    }
                    methodcall+=");";
                    cr.outputline(methodcall);
-                   cr.outputline("delete "+newmodel.getSafeSymbol()+";");
+                   cr.outputline("free"+name+"("+newmodel.getSafeSymbol()+");");
                    cr.outputline("goto rebuild;");
                }
                cr.endblock();
@@ -1746,7 +1764,7 @@ public class RepairGenerator {
                        String name=(String)updatenames.get(un);
                        usedupdates.add(un); /* Mark as used */
 
-                       String methodcall=name+"(this,"+oldmodel.getSafeSymbol()+","+
+                       String methodcall=name+"(thisvar,"+oldmodel.getSafeSymbol()+","+
                            repairtable.getSafeSymbol();
                        for(int j=0;j<currentrule.numQuantifiers();j++) {
                            Quantifier q=currentrule.getQuantifier(j);
@@ -1766,11 +1784,11 @@ public class RepairGenerator {
                        if (currentrule!=itrule) {
                            SetDescriptor sdrule=((SetInclusion)itrule.getInclusion()).getSet();
                            cr.outputline("if ("+oldmodel.getSafeSymbol()+"&&");
-                           cr.outputline("!"+oldmodel.getSafeSymbol() +"->"+sdrule.getJustSafeSymbol()+"_hash->contains("+setvar+"))");
+                           cr.outputline("!SimpleHashcontainskey("+ oldmodel.getSafeSymbol() +"->"+sdrule.getJustSafeSymbol() +"_hash,"+setvar+"))");
                            cr.startblock();
                        }
                        cr.outputline(methodcall);
-                       cr.outputline("delete "+newmodel.getSafeSymbol()+";");
+                       cr.outputline("free"+name+"("+newmodel.getSafeSymbol()+");");
                        cr.outputline("goto rebuild;");
                        cr.endblock();
                    }
@@ -1780,13 +1798,14 @@ public class RepairGenerator {
            }
        }
 
+        cr.startblock();
         String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
        cr.outputline("int " + addeditem + " = 0;");
        if (sd.getType() instanceof StructureTypeDescriptor)  {
            cr.outputline("if (!maybe&&"+setvar+")");
        } else
            cr.outputline("if (!maybe)");
-       cr.outputline(addeditem + " = " + sd.getSafeSymbol() + "_hash->add((int)" + setvar +  ", (int)" + setvar + ");");
+       cr.outputline(addeditem + " = SimpleHashadd("+sd.getSafeSymbol()+"_hash, (int)" + setvar +  ", (int)" + setvar + ");");
        cr.startblock();
         Vector dispatchrules = getrulelist(sd);
 
@@ -1799,7 +1818,8 @@ public class RepairGenerator {
        dispatchrules.removeAll(toremove);
 
         if (dispatchrules.size() == 0) {
-            cr.outputline("// nothing to dispatch");
+            cr.outputline("/* nothing to dispatch */");
+           cr.endblock();
            cr.endblock();
             return;
         }
@@ -1810,18 +1830,19 @@ public class RepairGenerator {
             Rule rule = (Rule) dispatchrules.elementAt(i);
            if (SetDescriptor.expand(rule.getGuardExpr().getRequiredDescriptors()).contains(sd)) {
                /* Guard depends on this relation, so we recompute everything */
-               cr.outputline(worklist.getSafeSymbol()+"->add("+rule.getNum()+",-1,0,0);");
+               cr.outputline("WorkListadd("+worklist.getSafeSymbol()+","+rule.getNum()+",-1,0,0);");
            } else {
                for (int j=0;j<rule.numQuantifiers();j++) {
                    Quantifier q=rule.getQuantifier(j);
                    if (SetDescriptor.expand(q.getRequiredDescriptors()).contains(sd)) {
                        /* Generate add */
-                       cr.outputline(worklist.getSafeSymbol()+"->add("+rule.getNum()+","+j+","+setvar+",0);");
+                       cr.outputline("WorkListadd("+worklist.getSafeSymbol()+","+rule.getNum()+","+j+","+setvar+",0);");
                    }
                }
            }
        }
        cr.endblock();
        cr.endblock();
+       cr.endblock();
     }
 }
index 9deb8ac083cd343ce08662a1b599498edaf20a13..d166e6e9cce2554395bbc9c0bfa506210d7c9fdc 100755 (executable)
@@ -57,11 +57,11 @@ public class SetExpr extends Expr {
     }
 
     public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
-        writer.outputline("int " + dest.getSafeSymbol() + " = " + sd.getSafeSymbol() + "_hash->contains(" + element.getSafeSymbol() + ");");
-    }    
+        writer.outputline("int " + dest.getSafeSymbol() + " = SimpleHashcontainskey(" +sd.getSafeSymbol()+ "_hash, "+element.getSafeSymbol() + ");");
+    }
 
     public void generate_size(CodeWriter writer, VarDescriptor dest) {
-        writer.outputline("int " + dest.getSafeSymbol() + " = " + sd.getSafeSymbol() + "_hash->count();");
+        writer.outputline("int " + dest.getSafeSymbol() + " = SimpleHashcountset("+sd.getSafeSymbol()+"_hash);");
     }
 
     public void prettyPrint(PrettyPrinter pp) {
@@ -74,5 +74,3 @@ public class SetExpr extends Expr {
     }
 
 }
-
-
index 7beefc99eb23e036ea207a7481f2e672d2a926e3..4da814c84e2dce2dfebbf6030526d80bb1947951 100755 (executable)
@@ -66,7 +66,7 @@ public class SetInclusion extends Inclusion {
         if (dostore) {
            /*      if (!Compiler.REPAIR) {
                writer.outputline("int " + addeditem + " = 1;");
-               writer.outputline(addeditem + " = " + set.getSafeSymbol() + "_hash->add((int)" + vd.getSafeSymbol()
+               writer.outputline(addeditem + " = SimpleHashadd("+set.getSafeSymbol()+"_hash, (int)" + vd.getSafeSymbol()
                                  +  ", (int)" + vd.getSafeSymbol() + ");");
                                  } else {*/
                Repair.generate_dispatch(writer, set, vd.getSafeSymbol());
index 379a5099a57adaa1daa7c057ea251ba3d1231662..d17505eeb96620d141df54f4278b69bcf16fb47f 100755 (executable)
@@ -38,21 +38,21 @@ public class SetQuantifier extends Quantifier {
     }
 
     public void generate_open(CodeWriter writer) {
-       writer.outputline("SimpleIterator "+var.getSafeSymbol()+"_iterator;");
-        writer.outputline("for (" + set.getSafeSymbol() + "_hash->iterator("+var.getSafeSymbol()+"_iterator); " + var.getSafeSymbol() + "_iterator.hasNext(); )");
+       writer.outputline("struct SimpleIterator "+var.getSafeSymbol()+"_iterator;");
+        writer.outputline("for (SimpleHashiterator("+set.getSafeSymbol()+"_hash, & "+ var.getSafeSymbol()+"_iterator); hasNext(&"+var.getSafeSymbol()+"_iterator); )");
         writer.startblock();
-        writer.outputline(var.getType().getGenerateType() + " " + var.getSafeSymbol() + " = (" + var.getType().getGenerateType() + ") " + var.getSafeSymbol() + "_iterator.next();");
+        writer.outputline(var.getType().getGenerateType() + " " + var.getSafeSymbol() + " = (" + var.getType().getGenerateType() + ") next(&"+var.getSafeSymbol()+"_iterator);");
     }
-  
+
     public void generate_open(CodeWriter writer, String type,int number, String left,String right) {
        VarDescriptor tmp=VarDescriptor.makeNew("flag");
-       writer.outputline("SimpleIterator "+var.getSafeSymbol()+"_iterator;");
-        writer.outputline(set.getSafeSymbol() + "_hash->iterator("+var.getSafeSymbol()+"_iterator);");
+       writer.outputline("struct SimpleIterator "+var.getSafeSymbol()+"_iterator;");
+        writer.outputline("SimpleHashiterator("+set.getSafeSymbol()+"_hash, &"+var.getSafeSymbol()+"_iterator);");
        writer.outputline("int "+tmp.getSafeSymbol()+"=0;");
        writer.outputline("if ("+type+"=="+number+")");
        writer.outputline(tmp.getSafeSymbol()+"=1;");
 
-       writer.outputline("while("+tmp.getSafeSymbol()+"||(("+type+"!="+number+")&&"+var.getSafeSymbol() + "_iterator.hasNext()))");
+       writer.outputline("while("+tmp.getSafeSymbol()+"||(("+type+"!="+number+")&&hasNext(&"+var.getSafeSymbol()+"_iterator)))");
         writer.startblock();
         writer.outputline(var.getType().getGenerateType() + " " + var.getSafeSymbol() + ";");
        writer.outputline("if ("+type+"=="+number+")");
@@ -61,19 +61,19 @@ public class SetQuantifier extends Quantifier {
         writer.outputline(var.getSafeSymbol() + " = (" + var.getType().getGenerateType() + ") " + left + ";");
        writer.endblock();
        writer.outputline("else");
-        writer.outputline(var.getSafeSymbol() + " = (" + var.getType().getGenerateType() + ") " + var.getSafeSymbol() + "_iterator.next();");
+        writer.outputline(var.getSafeSymbol() + " = (" + var.getType().getGenerateType() + ") next(&"+var.getSafeSymbol()+"_iterator);");
     }
-  
-    public int generate_worklistload(CodeWriter writer, int offset) {        
+
+    public int generate_worklistload(CodeWriter writer, int offset) {
         String varname = var.getSafeSymbol();
-        writer.outputline("int " + varname + " = wi->word" + offset + ";"); 
-        return offset + 1;       
+        writer.outputline("int " + varname + " = wi->word" + offset + ";");
+        return offset + 1;
     }
 
-    public int generate_workliststore(CodeWriter writer, int offset) {        
+    public int generate_workliststore(CodeWriter writer, int offset) {
         String varname = var.getSafeSymbol();
         writer.outputline("wi->word" + offset + " = " + varname + ";");
-        return offset + 1;       
+        return offset + 1;
     }
 
 
index 45e63e7337cba76a958a3708de61d239e19b75e6..3e053684025ae70ebac6076472dc19546564ccbe 100755 (executable)
@@ -39,9 +39,9 @@ public class SizeofFunction extends Expr {
         String destname = dest.getSafeSymbol();
         cr.outputline("int " + destname + ";");
 
-        // ok... destination is declared... we gotta expand this rule inplace... and instead of the inclusion we 
+        // ok... destination is declared... we gotta expand this rule inplace... and instead of the inclusion we
         // set the destination in the guard ... otherwise maybe!
-        
+
         VarDescriptor domain = vd;
 
         cr.pushSymbolTable(rule.getSymbolTable());
@@ -51,26 +51,26 @@ public class SizeofFunction extends Expr {
             SetQuantifier sq = ((SetQuantifier) rule.quantifiers().next());
             VarDescriptor rulebinding = sq.getVar();
             String tempvar = (VarDescriptor.makeNew("tempvar")).getSafeSymbol();
-            
+
             // this is to be safe about name overlap because int t = t; sets t to 0!
             cr.outputline("int " + tempvar + " = " + domain.getSafeSymbol() + ";");
             cr.outputline("int " + rulebinding.getSafeSymbol() + " = " + tempvar + ";");
-            
+
             /* pretty print! */
-            cr.outputline("// about to inbed relational function");
-            cr.output("// ");
+            cr.outputline("/* about to inbed relational function*/");
+            cr.output("/* ");
             rule.getGuardExpr().prettyPrint(cr);
-            cr.outputline("");
-            
+            cr.outputline("*/");
+
             /* now we have to generate the guard test */
             VarDescriptor guardval = VarDescriptor.makeNew();
             rule.getGuardExpr().generate(cr, guardval);
-            
+
             cr.outputline("if (" + guardval.getSafeSymbol() + ")");
             cr.startblock(); {
-                
+
                 cr.outputline(destname + " = 1;");
-                
+
             } cr.endblock();
             cr.outputline("else");
             cr.startblock(); {
@@ -94,5 +94,5 @@ public class SizeofFunction extends Expr {
     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
         throw new IRException();
     }
-        
+
 }
index e9a94fb33d405716b0a0a115da6d6b6efb6e4f8f..284302b96fc4d9d6a44898454de673949bd1a406 100755 (executable)
@@ -14,7 +14,7 @@ public class StructureGenerator {
        this.state=state;
        this.rg=rg;
        try {
-           cr=new StandardCodeWriter(new java.io.PrintWriter(new FileOutputStream("size.cc"),true));
+           cr=new StandardCodeWriter(new java.io.PrintWriter(new FileOutputStream("size.c"),true));
            crhead=new StandardCodeWriter(new java.io.PrintWriter(new FileOutputStream("size.h"),true));
        } catch (Exception e) {
            e.printStackTrace();
@@ -67,27 +67,27 @@ public class StructureGenerator {
        }
        str+="};";
        cr.outputline(str);
-       
 
-       cr.outputline("int typeobject::size(int type) {");
+
+       cr.outputline("int size(int type) {");
        cr.outputline("return arsize[type];");
        cr.outputline("}");
 
-       cr.outputline("int typeobject::sizeBytes(int type) {");
+       cr.outputline("int sizeBytes(int type) {");
        cr.outputline("return arsizeBytes[type];");
        cr.outputline("}");
 
-       cr.outputline("int typeobject::numElements(int type, int fieldindex) {");
+       cr.outputline("int numElements(int type, int fieldindex) {");
        cr.outputline("return arnumelements[type][fieldindex];");
        cr.outputline("}");
-       cr.outputline("typeobject::typeobject() {}");
     }
 
     private void generatecomputesize() {
        int max=TypeDescriptor.counter;
-       cr.outputline("void typeobject::computesizes("+rg.name+"_state * obj) {");
-       cr.outputline("obj->computesizes(arsize,arnumelements);");
-       cr.outputline("for(int i=0;i<"+max+";i++) {");
+       cr.outputline("void computesizes(struct "+rg.name+"_state * obj) {");
+        cr.outputline("int i;");
+       cr.outputline(rg.name+"_statecomputesizes(obj,arsize,arnumelements);");
+       cr.outputline("for(i=0;i<"+max+";i++) {");
        cr.outputline("int bits=arsize[i];");
        cr.outputline("int bytes=bits>>3;");
        cr.outputline("if (bits%8) bytes++;");
@@ -98,9 +98,6 @@ public class StructureGenerator {
 
     private void generateheader() {
        crhead.outputline("#include \""+rg.headername + "\"");
-       crhead.outputline("class typeobject {");
-       crhead.outputline("public:");
-       crhead.outputline("typeobject();");
        crhead.outputline("int getfield(int type, int fieldindex);");
        crhead.outputline("int isArray(int type, int fieldindex);");
        crhead.outputline("int isPtr(int type, int fieldindex);");
@@ -109,11 +106,10 @@ public class StructureGenerator {
        crhead.outputline("int sizeBytes(int type);");
        crhead.outputline("int getnumfields(int type);");
        crhead.outputline("bool issubtype(int subtype, int type);");
-       crhead.outputline("void computesizes("+rg.name+"_state *);");
-       crhead.outputline("};");
+       crhead.outputline("void computesizes(struct "+rg.name+"_state *);");
     }
 
-    
+
     private void generategetfield() {
        for(Iterator it=state.stTypes.descriptors();it.hasNext();) {
            TypeDescriptor ttd=(TypeDescriptor)it.next();
@@ -143,8 +139,8 @@ public class StructureGenerator {
        }
        str+="};";
        cr.outputline(str);
-       
-       cr.outputline("int typeobject::getfield(int type, int fieldindex) {");
+
+       cr.outputline("int getfield(int type, int fieldindex) {");
        cr.outputline("return argetfield[type][fieldindex];");
        cr.outputline("}");
     }
@@ -164,8 +160,8 @@ public class StructureGenerator {
        }
        str+="};";
        cr.outputline(str);
-       
-       cr.outputline("int typeobject::getnumfields(int type) {");
+
+       cr.outputline("int getnumfields(int type) {");
        cr.outputline("return argetnumfield[type];");
        cr.outputline("}");
     }
@@ -201,8 +197,8 @@ public class StructureGenerator {
        }
        str+="};";
        cr.outputline(str);
-       
-       cr.outputline("int typeobject::isArray(int type, int fieldindex) {");
+
+       cr.outputline("int isArray(int type, int fieldindex) {");
        cr.outputline("return arisArray[type][fieldindex];");
        cr.outputline("}");
     }
@@ -237,8 +233,8 @@ public class StructureGenerator {
        }
        str+="};";
        cr.outputline(str);
-       
-       cr.outputline("int typeobject::isPtr(int type, int fieldindex) {");
+
+       cr.outputline("int isPtr(int type, int fieldindex) {");
        cr.outputline("return arisPtr[type][fieldindex];");
        cr.outputline("}");
     }
@@ -264,7 +260,7 @@ public class StructureGenerator {
        }
        str+="};";
        cr.outputline(str);
-       cr.outputline("bool typeobject::issubtype(int subtype, int type) {");
+       cr.outputline("bool issubtype(int subtype, int type) {");
        cr.outputline("return arissubtype[subtype][type];");
        cr.outputline("}");
     }
index 9a83f8ef2b8f3b6aebb9c5c7ec8ca70c1ece2b9f..310f2412314ad7e1c4c99c19454b8cbf1656546b 100755 (executable)
@@ -57,14 +57,14 @@ public class SumExpr extends Expr {
         writer.outputline("int "+dest.getSafeSymbol()+"=0;");
 
         VarDescriptor itvd=VarDescriptor.makeNew("iterator");
-        writer.outputline("SimpleIterator "+itvd.getSafeSymbol()+";");
-        writer.outputline(sd.getSafeSymbol()+"_hash->iterator("+itvd.getSafeSymbol()+");");
-        writer.outputline("while ("+itvd.getSafeSymbol()+".hasNext()) {");
+        writer.outputline("struct SimpleIterator "+itvd.getSafeSymbol()+";");
+        writer.outputline("SimpleHashiterator("+sd.getSafeSymbol()+"_hash , &"+itvd.getSafeSymbol()+");");
+        writer.outputline("while (hasNext(&"+itvd.getSafeSymbol()+")) {");
         VarDescriptor keyvd=VarDescriptor.makeNew("key");
-        writer.outputline("int "+keyvd.getSafeSymbol()+"="+itvd.getSafeSymbol()+".next();");
+        writer.outputline("int "+keyvd.getSafeSymbol()+"=next(&"+itvd.getSafeSymbol()+");");
         VarDescriptor tmpvar=VarDescriptor.makeNew("tmp");
         writer.outputline("int "+tmpvar.getSafeSymbol()+";");
-        writer.outputline(rd.getSafeSymbol()+ "_hash->get("+keyvd.getSafeSymbol()+","+tmpvar.getSafeSymbol()+");");
+        writer.outputline("SimpleHashget("+rd.getSafeSymbol()+"_hash, "+keyvd.getSafeSymbol()+", &"+tmpvar.getSafeSymbol()+");");
         writer.outputline(dest.getSafeSymbol()+"+="+tmpvar.getSafeSymbol()+";");
         writer.outputline("}");
     }
index eabd01491b545008c63e7ff90d07598e94bcd9db..962ee775ef0fac5f2bcb6f083005fbc409397a53 100755 (executable)
@@ -22,7 +22,7 @@ public class TupleOfExpr extends Expr {
         if ((left == null) || (right == null) || (relation == null)) {
             throw new NullPointerException();
         }
-        
+
         this.left = left;
         this.right = right;
         this.relation = relation;
@@ -75,8 +75,8 @@ public class TupleOfExpr extends Expr {
         VarDescriptor rd = VarDescriptor.makeNew();
         right.generate(writer, rd);
 
-        writer.outputline("int " + dest.getSafeSymbol() + " = " + 
-                          relation.getSafeSymbol() + "_hash->contains(" + 
+        writer.outputline("int " + dest.getSafeSymbol() + " = SimpleHashcontainskeydata("
+                          +relation.getSafeSymbol() +"_hash, "+
                           ld.getSafeSymbol() + ", " +
                           rd.getSafeSymbol() + ");");
     }
@@ -92,7 +92,7 @@ public class TupleOfExpr extends Expr {
     public TypeDescriptor typecheck(SemanticAnalyzer sa) {
         TypeDescriptor ld = left.typecheck(sa);
         TypeDescriptor rd = right.typecheck(sa);
-        
+
         if (ld == null || rd == null) {
             return null;
         }
index 4a345aa5db64cca8f77469409e336e3f79336662..c22084434a3b59b177229cbb91bea3aa3a5eb9eb 100755 (executable)
@@ -37,7 +37,7 @@ class UpdateNode {
        st+="---------------------\n";
        return st;
     }
-  
+
     public void addBindings(Vector v) {
        for (int i=0;i<v.size();i++) {
            addBinding((Binding)v.get(i));
@@ -73,7 +73,7 @@ class UpdateNode {
                Descriptor d=u1.getDescriptor();
                Expr subexpr=null;
                Expr intindex=null;
-               
+
                if (u2.isField()) {
                    subexpr=((DotExpr)u2.getLeftExpr()).getExpr();
                    intindex=((DotExpr)u2.getLeftExpr()).getIndex();
@@ -131,7 +131,7 @@ class UpdateNode {
                    continue;  /* Abstract updates are already accounted for by graph */
                if (u1.getDescriptor()!=u2.getDescriptor())
                    continue; /* No interference - different descriptors */
-               
+
                if ((u1.getOpcode()==Opcode.GT||u1.getOpcode()==Opcode.GE)&&
                    (u2.getOpcode()==Opcode.GT||u2.getOpcode()==Opcode.GE))
                    continue; /* Can be satisfied simultaneously */
@@ -174,7 +174,7 @@ class UpdateNode {
                        toremove.add(u2);
                    continue;
                }
-               
+
                /* Compatible operations < & <= */
                if (((u1.getOpcode()==Opcode.LT)||(u1.getOpcode()==Opcode.LE))&&
                    ((u2.getOpcode()==Opcode.LT)||(u2.getOpcode()==Opcode.LE)))
@@ -209,7 +209,7 @@ class UpdateNode {
     public Binding getBinding(int i) {
        return (Binding)bindings.get(i);
     }
-    
+
     public Binding getBinding(VarDescriptor vd) {
        if (binding.containsKey(vd))
            return (Binding)binding.get(vd);
@@ -299,10 +299,10 @@ class UpdateNode {
                boolean usageimage=rd.testUsage(RelationDescriptor.IMAGE);
                boolean usageinvimage=rd.testUsage(RelationDescriptor.INVIMAGE);
                if (usageimage)
-                   cr.outputline(rg.stmodel+"->"+rd.getJustSafeSymbol() + "_hash->remove((int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
+                   cr.outputline("SimpleHashremove("+rg.stmodel+"->"+rd.getJustSafeSymbol()+"_hash, (int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
                if (usageinvimage)
-                   cr.outputline(rg.stmodel+"->"+rd.getJustSafeSymbol() + "_hashinv->remove((int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
-               
+                   cr.outputline("SimpleHashremove("+rg.stmodel+"->"+rd.getJustSafeSymbol()+"_hashinv, (int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+
                for(int i=0;i<state.vRules.size();i++) {
                    Rule r=(Rule)state.vRules.get(i);
                    if (r.getInclusion().getTargetDescriptors().contains(rd)) {
@@ -311,14 +311,14 @@ class UpdateNode {
                            if (un.getRule()==r) {
                                /* Update for rule rule r */
                                String name=(String)rg.updatenames.get(un);
-                               cr.outputline(rg.strepairtable+"->addrelation("+rd.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+",(int) &"+name+");");
+                               cr.outputline("RepairHashaddrelation("+rg.strepairtable+","+rd.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+",(int) &"+name+");");
                            }
                        }
                    }
                }
            } else {
                SetDescriptor sd=(SetDescriptor) d;
-               cr.outputline(rg.stmodel+"->"+sd.getJustSafeSymbol() + "_hash->remove((int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+               cr.outputline("SimpleHashremove("+rg.stmodel+"->"+sd.getJustSafeSymbol()+"_hash, (int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
 
                for(int i=0;i<state.vRules.size();i++) {
                    Rule r=(Rule)state.vRules.get(i);
@@ -328,7 +328,7 @@ class UpdateNode {
                            if (un.getRule()==r) {
                                /* Update for rule rule r */
                                String name=(String)rg.updatenames.get(un);
-                               cr.outputline(rg.strepairtable+"->addset("+sd.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+",(int) &"+name+");");
+                               cr.outputline("RepairHashaddset("+rg.strepairtable+","+sd.getNum()+","+r.getNum()+","+leftvar.getSafeSymbol()+",(int) &"+name+");");
                            }
                        }
                    }
@@ -341,16 +341,16 @@ class UpdateNode {
                boolean usageimage=rd.testUsage(RelationDescriptor.IMAGE);
                boolean usageinvimage=rd.testUsage(RelationDescriptor.INVIMAGE);
                if (usageimage)
-                   cr.outputline(rg.stmodel+"->"+rd.getJustSafeSymbol() + "_hash->add((int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
+                   cr.outputline("SimpleHashadd("+rg.stmodel+"->"+rd.getJustSafeSymbol()+"_hash, (int)" + leftvar.getSafeSymbol() + ", (int)" + rightvar.getSafeSymbol() + ");");
                if (usageinvimage)
-                   cr.outputline(rg.stmodel+"->"+rd.getJustSafeSymbol() + "_hashinv->add((int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+                   cr.outputline("SimpleHashadd("+rg.stmodel+"->"+rd.getJustSafeSymbol()+"_hashinv, (int)" + rightvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
 
                UpdateNode un=mun.getUpdate(0);
                String name=(String)rg.updatenames.get(un);
                cr.outputline(name+"(this,"+rg.stmodel+","+rg.strepairtable+","+leftvar.getSafeSymbol()+","+rightvar.getSafeSymbol()+");");
            } else {
                SetDescriptor sd=(SetDescriptor)d;
-               cr.outputline(rg.stmodel+"->"+sd.getJustSafeSymbol() + "_hash->add((int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
+               cr.outputline("SimpleHashadd("+rg.stmodel+"->"+sd.getJustSafeSymbol()+"_hash, (int)" + leftvar.getSafeSymbol() + ", (int)" + leftvar.getSafeSymbol() + ");");
 
                UpdateNode un=mun.getUpdate(0);
                /* Update for rule rule r */
@@ -490,7 +490,7 @@ class UpdateNode {
        ArrayAnalysis.AccessPath ap=u.getAccessPath();
        VarDescriptor init=VarDescriptor.makeNew("init");
        if (ap.isSet()) {
-           cr.outputline("int "+init.getSafeSymbol()+"="+ap.getSet().getSafeSymbol()+"_hash->firstkey();");
+           cr.outputline("int "+init.getSafeSymbol()+"= SimpleHashfirstkey("+ap.getSet().getSafeSymbol()+"_hash);");
            init.td=ap.getSet().getType();
        } else {
            init=ap.getVar();
@@ -540,7 +540,7 @@ class UpdateNode {
 
            if (b.getType()==Binding.SEARCH) {
                VarDescriptor vd=b.getVar();
-               cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"="+b.getSet().getSafeSymbol()+"_hash->firstkey();");
+               cr.outputline(vd.getType().getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"=SimpleHashfirstkey("+b.getSet().getSafeSymbol()+"_hash);");
            } else if (b.getType()==Binding.CREATE) {
                throw new Error("Creation not supported");
                //              source.generateSourceAlloc(cr,vd,b.getSet());
index de490b3a19b3f759f8987ec71bbeae788b75a0d6..8ba05d93db7cef087cf65f794009d3628941b756 100755 (executable)
@@ -115,14 +115,14 @@ public class VarExpr extends Expr {
 
        if (writer.getInvariantValue()!=null&&
            writer.getInvariantValue().isInvariant(this)) {
-           writer.outputline("maybe="+writer.getInvariantValue().getMaybe(this).getSafeSymbol()+";");
            writer.outputline(vd.getType().getGenerateType().getSafeSymbol()+
                              " "+dest.getSafeSymbol()+"="+writer.getInvariantValue().getValue(this).getSafeSymbol()+";");
+           writer.outputline("maybe="+writer.getInvariantValue().getMaybe(this).getSafeSymbol()+";");
            return;
        }
 
         writer.outputline(vd.getType().getGenerateType().getSafeSymbol() + " " + dest.getSafeSymbol() +
-                          " = (" + vd.getType().getGenerateType().getSafeSymbol() + ") " + vd.getSafeSymbol() + "; //varexpr");
+                          " = (" + vd.getType().getGenerateType().getSafeSymbol() + ") " + vd.getSafeSymbol() + "; /*varexpr*/");
        if (vd.isGlobal() && (DOTYPECHECKS||DOMEMCHECKS) && (td instanceof StructureTypeDescriptor)) {
            VarDescriptor typevar=VarDescriptor.makeNew("typechecks");
            writer.outputline("if ("+dest.getSafeSymbol()+")");
index 023b06491b41337947bb682bc6b2414ecb94fe9b..c2675f2d09a5b265b3ca6f216b1f709f973cce81 100755 (executable)
@@ -9,12 +9,12 @@ public class WorkList {
     public static Vector getrulelist(Descriptor d) {
 
         Vector dispatchrules = new Vector();
-        Vector rules = State.currentState.vRules;        
-        
+        Vector rules = State.currentState.vRules;
+
         for (int i = 0; i < rules.size(); i++) {
             Rule rule = (Rule) rules.elementAt(i);
             Set requiredsymbols = rule.getRequiredDescriptors();
-            
+
             // #TBD#: in general this is wrong because these descriptors may contain descriptors
             // bound in "in?" expressions which need to be dealt with in a topologically sorted
             // fashion...
@@ -26,19 +26,19 @@ public class WorkList {
 
         return dispatchrules;
     }
-    
+
 
     public static void generate_dispatch(CodeWriter cr, RelationDescriptor rd, String leftvar, String rightvar) {
 
-        cr.outputline("// RELATION DISPATCH ");        
+        cr.outputline("/* RELATION DISPATCH */");
 
         Vector dispatchrules = getrulelist(rd);
-        
+
         if (dispatchrules.size() == 0) {
-            cr.outputline("// nothing to dispatch");
+            cr.outputline("/* nothing to dispatch*/");
             return;
         }
-       
+
         for(int i = 0; i < dispatchrules.size(); i++) {
             Rule rule = (Rule) dispatchrules.elementAt(i);
             cr.outputline("need to dispatch for " + rule.getLabel());
@@ -50,25 +50,25 @@ public class WorkList {
 
 
     public static void generate_dispatch(CodeWriter cr, SetDescriptor sd, String setvar) {
-               
-        cr.outputline("// SET DISPATCH ");        
+
+        cr.outputline("/* SET DISPATCH */");
+
         Vector dispatchrules = getrulelist(sd);
 
         if (dispatchrules.size() == 0) {
-            cr.outputline("// nothing to dispatch");
+            cr.outputline("/* nothing to dispatch*/");
             return;
         }
 
         for(int i = 0; i < dispatchrules.size(); i++) {
             Rule rule = (Rule) dispatchrules.elementAt(i);
-            
+
             ListIterator quantifiers = rule.quantifiers();
             Vector otherq = new Vector(); // quantifiers that we need to iterate over to add workitems
 
-            cr.outputline("// " + rule.getLabel());
+            cr.outputline("/* " + rule.getLabel()+"*/");
             cr.startblock();
-                          
+
 
             // #ATTN#: this may/does not handle multiple instances of the same quantifier being bound
             // solution is probabyl to iterate over all bindings
@@ -91,16 +91,16 @@ public class WorkList {
                     size += 8;
                 } else { // ForQuantifier
                     size += 4;
-                }                    
+                }
 
-                otherq.addElement(quantifier);        
+                otherq.addElement(quantifier);
             }
 
             assert boundname != null;
 
             // bind bound variable
             cr.outputline("int " + boundname + " = " + setvar + ";");
-            
+
             // add the rest of the quantifiers and continue to calculate size
             while (quantifiers.hasNext()) {
                 Quantifier quantifier = (Quantifier) quantifiers.next();
@@ -110,15 +110,15 @@ public class WorkList {
                     size += 4;
                 }
             }
-            
+
             ListIterator otheriterator = otherq.listIterator();
             while (otheriterator.hasNext()) {
-                Quantifier quantifier = (Quantifier) otheriterator.next();                   
+                Quantifier quantifier = (Quantifier) otheriterator.next();
                 quantifier.generate_open(cr);
                 // implicitly opens bracket
-            }            
-                        
-            cr.outputline("// dispatching to " + rule.getLabel());
+            }
+
+            cr.outputline("/* dispatching to " + rule.getLabel()+"*/");
             // #TODO#:  add code to do worklist addition
 
             cr.outputline("WORKITEM *wi = (WORKITEM *) malloc(" + size + ");");
@@ -132,21 +132,21 @@ public class WorkList {
             while (quantifiers.hasNext()) {
                 Quantifier quantifier = (Quantifier) quantifiers.next();
                 offset = quantifier.generate_workliststore(cr, offset);
-            }            
-             
+            }
+
             // now store in worklist!
-            cr.outputline("WORKLIST->add((int) wi);");            
-           
+            cr.outputline("WORKLIST->add((int) wi);");
+
             // close all those brackets
             while (otheriterator.hasPrevious()) {
                 otheriterator.previous(); // throw away
                 cr.endblock();
-            }           
+            }
 
             // end rule
             cr.endblock();
 
-        }    
+        }
     }
 
 }
index f33363b471e7e3e5a884b58461e0c740e7f98104..bbdf1b7d0f8ae0e0d4b4342b4d39b0053ec69a4d 100755 (executable)
@@ -8,14 +8,14 @@ public class WorklistGenerator {
 
     State state;
     java.io.PrintWriter output = null;
-            
+
     public WorklistGenerator(State state) {
         this.state = state;
     }
 
     public void generate(java.io.OutputStream output) {
-        this.output = new java.io.PrintWriter(output, true); 
-        
+        this.output = new java.io.PrintWriter(output, true);
+
         generate_tokentable();
         generate_hashtables();
         generate_worklist();
@@ -28,16 +28,16 @@ public class WorklistGenerator {
 
     private void generate_tokentable() {
 
-        CodeWriter cr = new StandardCodeWriter(output);        
-        Iterator tokens = TokenLiteralExpr.tokens.keySet().iterator();        
+        CodeWriter cr = new StandardCodeWriter(output);
+        Iterator tokens = TokenLiteralExpr.tokens.keySet().iterator();
 
         cr.outputline("");
-        cr.outputline("// Token values");
+        cr.outputline("/* Token values*/");
         cr.outputline("");
 
         while (tokens.hasNext()) {
             Object token = tokens.next();
-            cr.outputline("// " + token.toString() + " = " + TokenLiteralExpr.tokens.get(token).toString());            
+            cr.outputline("/* " + token.toString() + " = " + TokenLiteralExpr.tokens.get(token).toString()+"*/");
         }
 
         cr.outputline("");
@@ -47,48 +47,48 @@ public class WorklistGenerator {
     private void generate_hashtables() {
 
         CodeWriter cr = new StandardCodeWriter(output);
-        cr.outputline("int __Success = 1;\n");       
-        cr.outputline("// creating hashtables ");
-        
+        cr.outputline("int __Success = 1;\n");
+        cr.outputline("/* creating hashtables */");
+
         /* build all the hashtables */
         Hashtable hashtables = new Hashtable();
 
         /* build sets */
         Iterator sets = state.stSets.descriptors();
-        
+
         /* first pass create all the hash tables */
         while (sets.hasNext()) {
             SetDescriptor set = (SetDescriptor) sets.next();
             cr.outputline("SimpleHash* " + set.getSafeSymbol() + "_hash = new SimpleHash();");
-        } 
-        
+        }
+
         /* second pass build relationships between hashtables */
         sets = state.stSets.descriptors();
-        
+
         while (sets.hasNext()) {
             SetDescriptor set = (SetDescriptor) sets.next();
             Iterator subsets = set.subsets();
-            
+
             while (subsets.hasNext()) {
-                SetDescriptor subset = (SetDescriptor) subsets.next();                
+                SetDescriptor subset = (SetDescriptor) subsets.next();
                 cr.outputline(subset.getSafeSymbol() + "_hash->addParent(" + set.getSafeSymbol() + "_hash);");
             }
-        } 
+        }
 
         /* build relations */
         Iterator relations = state.stRelations.descriptors();
-        
+
         /* first pass create all the hash tables */
         while (relations.hasNext()) {
             RelationDescriptor relation = (RelationDescriptor) relations.next();
-            
+
             if (relation.testUsage(RelationDescriptor.IMAGE)) {
                 cr.outputline("SimpleHash* " + relation.getSafeSymbol() + "_hash = new SimpleHash();");
             }
 
             if (relation.testUsage(RelationDescriptor.INVIMAGE)) {
                 cr.outputline("SimpleHash* " + relation.getSafeSymbol() + "_hashinv = new SimpleHash();");
-            } 
+            }
         }
 
         cr.outputline("");
@@ -101,21 +101,21 @@ public class WorklistGenerator {
         cr.outputline("WORKLIST = new SimpleList();");
 
     }
-    
+
     private void generate_teardown() {
 
-        CodeWriter cr = new StandardCodeWriter(output);        
+        CodeWriter cr = new StandardCodeWriter(output);
         cr.outputline("WORKLIST->reset();");
         cr.outputline("while (WORKLIST->hasMoreElements())");
         cr.startblock();
         cr.outputline("free ((WORKITEM *) WORKLIST->nextElement());");
-        cr.endblock();        
+        cr.endblock();
         cr.outputline("delete WORKLIST;");
 
     }
 
     private void generate_rules() {
-        
+
         /* first we must sort the rules */
         Iterator allrules = state.vRules.iterator();
 
@@ -144,38 +144,38 @@ public class WorklistGenerator {
                 worklistrules.add(rule);
             }
         }
-       
+
         Iterator iterator_er = emptyrules.iterator();
         while (iterator_er.hasNext()) {
 
-            Rule rule = (Rule) iterator_er.next();            
+            Rule rule = (Rule) iterator_er.next();
 
             {
-                final SymbolTable st = rule.getSymbolTable();                
+                final SymbolTable st = rule.getSymbolTable();
                 CodeWriter cr = new StandardCodeWriter(output) {
                         public SymbolTable getSymbolTable() { return st; }
                     };
-                
-                cr.outputline("// build " + rule.getLabel());
+
+                cr.outputline("/* build " + rule.getLabel()+"*/");
                 cr.startblock();
 
                 ListIterator quantifiers = rule.quantifiers();
 
                 while (quantifiers.hasNext()) {
-                    Quantifier quantifier = (Quantifier) quantifiers.next();                   
+                    Quantifier quantifier = (Quantifier) quantifiers.next();
                     quantifier.generate_open(cr);
-                }            
-                        
+                }
+
                 /* pretty print! */
-                cr.output("//");
+                cr.output("/*");
                 rule.getGuardExpr().prettyPrint(cr);
-                cr.outputline("");
+                cr.outputline("*/");
 
                 /* now we have to generate the guard test */
-        
+
                 VarDescriptor guardval = VarDescriptor.makeNew();
                 rule.getGuardExpr().generate(cr, guardval);
-                
+
                 cr.outputline("if (" + guardval.getSafeSymbol() + ")");
                 cr.startblock();
 
@@ -194,23 +194,23 @@ public class WorklistGenerator {
             }
         }
 
-        CodeWriter cr2 = new StandardCodeWriter(output);        
+        CodeWriter cr2 = new StandardCodeWriter(output);
 
         cr2.outputline("WORKLIST->reset();");
         cr2.outputline("while (WORKLIST->hasMoreElements())");
         cr2.startblock();
         cr2.outputline("WORKITEM *wi = (WORKITEM *) WORKLIST->nextElement();");
-        
+
         String elseladder = "if";
 
         Iterator iterator_rules = worklistrules.iterator();
         while (iterator_rules.hasNext()) {
-            
-            Rule rule = (Rule) iterator_rules.next();            
+
+            Rule rule = (Rule) iterator_rules.next();
             int dispatchid = rule.getNum();
 
             {
-                final SymbolTable st = rule.getSymbolTable();                
+                final SymbolTable st = rule.getSymbolTable();
                 CodeWriter cr = new StandardCodeWriter(output) {
                         public SymbolTable getSymbolTable() { return st; }
                     };
@@ -219,26 +219,26 @@ public class WorklistGenerator {
                 cr.outputline(elseladder + " (wi->id == " + dispatchid + ")");
                 cr.startblock();
 
-                cr.outputline("// build " + rule.getLabel());
+                cr.outputline("/* build " + rule.getLabel()+"*/");
 
                 ListIterator quantifiers = rule.quantifiers();
 
                 int count = 0;
                 while (quantifiers.hasNext()) {
                     Quantifier quantifier = (Quantifier) quantifiers.next();
-                    count = quantifier.generate_worklistload(cr, count );                    
+                    count = quantifier.generate_worklistload(cr, count );
                 }
-                        
+
                 /* pretty print! */
-                cr.output("//");
+                cr.output("/*");
                 rule.getGuardExpr().prettyPrint(cr);
-                cr.outputline("");
+                cr.outputline("*/");
 
                 /* now we have to generate the guard test */
-        
+
                 VarDescriptor guardval = VarDescriptor.makeNew();
                 rule.getGuardExpr().generate(cr, guardval);
-                
+
                 cr.outputline("if (" + guardval.getSafeSymbol() + ")");
                 cr.startblock();
 
@@ -247,7 +247,7 @@ public class WorklistGenerator {
                 cr.endblock();
 
                 // close startblocks generated by DotExpr memory checks
-                //DotExpr.generate_memory_endblocks(cr);                
+                //DotExpr.generate_memory_endblocks(cr);
 
                 cr.endblock(); // end else-if WORKLIST ladder
 
@@ -269,9 +269,9 @@ public class WorklistGenerator {
     private void generate_implicit_checks() {
 
         /* do post checks */
-         
+
         CodeWriter cr = new StandardCodeWriter(output);
-           
+
         // #TBD#: these should be implicit checks added to the set of constraints
         //output.println("check multiplicity");
     }
@@ -283,33 +283,33 @@ public class WorklistGenerator {
 
         for (int i = 0; i < constraints.size(); i++) {
 
-            Constraint constraint = (Constraint) constraints.elementAt(i); 
+            Constraint constraint = (Constraint) constraints.elementAt(i);
 
             {
 
                 final SymbolTable st = constraint.getSymbolTable();
-                
+
                 CodeWriter cr = new StandardCodeWriter(output) {
                         public SymbolTable getSymbolTable() { return st; }
                     };
-                
-                cr.outputline("// checking " + constraint.getLabel());
+
+                cr.outputline("/* checking " + constraint.getLabel()+"*/");
                 cr.startblock();
 
                 ListIterator quantifiers = constraint.quantifiers();
 
                 while (quantifiers.hasNext()) {
-                    Quantifier quantifier = (Quantifier) quantifiers.next();                   
+                    Quantifier quantifier = (Quantifier) quantifiers.next();
                     quantifier.generate_open(cr);
-                }            
+                }
 
                 cr.outputline("int maybe = 0;");
-                        
+
                 /* now we have to generate the guard test */
-        
+
                 VarDescriptor constraintboolean = VarDescriptor.makeNew("constraintboolean");
                 constraint.getLogicStatement().generate(cr, constraintboolean);
-                
+
                 cr.outputline("if (maybe)");
                 cr.startblock();
                 cr.outputline("__Success = 0;");
@@ -334,13 +334,10 @@ public class WorklistGenerator {
                 cr.outputline("");
                 cr.outputline("");
             }
-            
+
         }
 
-        output.println("// if (__Success) { printf(\"all tests passed\"); }");
-    }    
+        output.println("/* if (__Success) { printf(\"all tests passed\"); }*/");
+    }
 
 }
-
-
-
index 163f90c7d39e402fbba47a660569bf3cdca22cd3..b8aef1f5781321bc46f6f324621732ae9dd60efc 100755 (executable)
@@ -43,7 +43,7 @@ IR/RelationInclusion.class IR/SetInclusion.class IR/TupleOfExpr.class \
 IR/ElementOfExpr.class IR/Rule.class IR/Inclusion.class                        \
 IR/CodeWriter.class IR/SymbolTableStack.class  \
 IR/StandardCodeWriter.class IR/SumExpr.class           \
-IR/WorkList.class              \
+IR/WorkList.class IR/PrintWrapper.class                \
 IR/RepairGenerator.class IR/AbstractInterferes.class                   \
 IR/PrettyPrinter.class IR/AbstractRepair.class IR/Quantifiers.class    \
 IR/Binding.class IR/ConcreteInterferes.class IR/Conjunction.class      \
index 5b11610a3ff01c0f34e183863989d85c4d208588..986c8d04d828ffa30237ba9c3f5428e7587605f7 100755 (executable)
@@ -1,4 +1,7 @@
-struct foo_state {int l;};
+#include "specs/x86/cache_aux.h"
+class typeobject {
+public:
+typeobject();
 int getfield(int type, int fieldindex);
 int isArray(int type, int fieldindex);
 int isPtr(int type, int fieldindex);
@@ -7,4 +10,5 @@ int size(int type);
 int sizeBytes(int type);
 int getnumfields(int type);
 bool issubtype(int subtype, int type);
-void computesizes(struct foo_state *);
+void computesizes(foo_state *);
+};