+ if (Compiler.TIME) {
+ cr.outputline("gettimeofday(&_end_time,NULL);");
+ cr.outputline("printf(\"time=%ld uS\\n\",(_end_time.tv_sec-_begin_time.tv_sec)*1000000+_end_time.tv_usec-_begin_time.tv_usec);");
+ }
+
+ if (Compiler.GENERATEINSTRUMENT) {
+ cr.outputline("printf(\"updatecount=%d\\n\",updatecount);");
+ cr.outputline("printf(\"rebuildcount=%d\\n\",rebuildcount);");
+ cr.outputline("printf(\"abstractcount=%d\\n\",abstractcount);");
+ }
+
+ }
+
+ private void generate_print() {
+
+ final SymbolTable st = new SymbolTable();
+
+ CodeWriter cr = new StandardCodeWriter(outputaux) {
+ public SymbolTable getSymbolTable() { return st; }
+ };
+
+ cr.outputline("/* printing sets!*/");
+ cr.outputline("printf(\"\\n\\nPRINTING SETS AND RELATIONS\\n\");");
+
+ Iterator setiterator = state.stSets.descriptors();
+ while (setiterator.hasNext()) {
+ SetDescriptor sd = (SetDescriptor) setiterator.next();
+ if (sd.getSymbol().equals("int") || sd.getSymbol().equals("token")) {
+ continue;
+ }
+
+ String setname = sd.getSafeSymbol();
+
+ cr.startblock();
+ cr.outputline("/* printing set " + setname+"*/");
+ cr.outputline("printf(\"\\nPrinting set " + sd.getSymbol() + " - %d elements \\n\", SimpleHashcountset("+setname+"_hash));");
+ cr.addDeclaration("struct SimpleIterator","__setiterator");
+ cr.outputline("SimpleHashiterator("+setname+"_hash,&__setiterator);");
+ cr.outputline("while (hasNext(&__setiterator))");
+ cr.startblock();
+ cr.addDeclaration("int","__setval");
+ cr.outputline("__setval = (int) next(&__setiterator);");
+
+ TypeDescriptor td = sd.getType();
+ if (td instanceof StructureTypeDescriptor) {
+ StructureTypeDescriptor std = (StructureTypeDescriptor) td;
+ VarDescriptor vd = new VarDescriptor ("__setval", "__setval", td, false);
+ std.generate_printout(cr, vd);
+ } else { // Missing type descriptor or reserved type, just print int
+ cr.outputline("printf(\"<%d> \", __setval);");
+ }
+
+
+ cr.endblock();
+ cr.endblock();
+ }
+
+ Iterator reliterator = state.stRelations.descriptors();
+ while (reliterator.hasNext()) {
+ RelationDescriptor rd = (RelationDescriptor) reliterator.next();
+
+
+ String relname = rd.getSafeSymbol();
+ if (rd.testUsage(RelationDescriptor.IMAGE)) {
+ cr.startblock();
+ cr.outputline("/* printing relation " + relname+"*/");
+ cr.outputline("printf(\"\\nPrinting relation " + rd.getSymbol() + " - %d elements \\n\", SimpleHashcountset("+relname+"_hash));");
+ cr.addDeclaration("struct SimpleIterator","__reliterator");
+ cr.outputline("SimpleHashiterator("+relname+"_hash,&__reliterator);");
+ cr.outputline("while (hasNext(&__reliterator))");
+ cr.startblock();
+ cr.addDeclaration("int","__relval");
+ cr.addDeclaration("int","__relval2");
+ cr.outputline("__relval2 = (int) key(&__reliterator);");
+ cr.outputline("__relval = (int) next(&__reliterator);");
+
+ cr.outputline("printf(\"<%ld,%ld> \", __relval2,__relval);");
+
+ cr.endblock();
+ cr.endblock();
+ } else if (rd.testUsage(RelationDescriptor.INVIMAGE)) {
+ cr.startblock();
+ cr.outputline("/* printing inv relation " + relname+"*/");
+ cr.outputline("printf(\"\\nPrinting relation using inv" + rd.getSymbol() + " - %d elements \\n\", SimpleHashcountset("+relname+"_hash));");
+ cr.addDeclaration("struct SimpleIterator","__reliterator");
+ cr.outputline("SimpleHashiterator("+relname+"_hashinv,&__reliterator);");
+ cr.outputline("while (hasNext(&__reliterator))");
+ cr.startblock();
+ cr.addDeclaration("int","__relval");
+ cr.addDeclaration("int","__relval2");
+ cr.outputline("__relval2 = (int) key(&__reliterator);");
+ cr.outputline("__relval = (int) next(&__reliterator);");
+
+
+ cr.outputline("printf(\"<%ld,%ld> \", __relval,__relval2);");
+
+ cr.endblock();
+ cr.endblock();
+ }
+
+ }
+
+ cr.outputline("printf(\"\\n\\n------------------- END PRINTING\\n\");");