+
+ /**
+ * <p>
+ * This function will automatically generate the printing statements for
+ * supported types when given a type and a name of the declaration.
+ * </p>
+ *
+ * @return The auto-generated state printing statements
+ */
+ public static Code generatePrintStatement(String type, String name) {
+ Code code = new Code();
+ // Primitive types
+ if (type.equals("int") || type.equals("unsigned")
+ || type.equals("unsigned int") || type.equals("int unsigned")
+ || type.equals("double") || type.equals("double")
+ || type.equals("bool")) {
+ // PRINT("\tx=%d\n", x);
+ code.addLine(SpecNaming.PRINT + "(\"\\t" + name + "=%d\\n\", "
+ + name + ");");
+ } else if (type.equals("int *") || type.equals("unsigned *")
+ || type.equals("unsigned int *")
+ || type.equals("int unsigned *") || type.equals("double *")
+ || type.equals("double *") || type.equals("bool *")) {
+ // Supported pointer types for primitive types
+ // PRINT("\t*x=%d\n", *x);
+ code.addLine(SpecNaming.PRINT + "(\"\\t*" + name + "=%d\\n\", *"
+ + name + ");");
+ } else if (type.equals("IntList") || type.equals("IntSet")
+ || type.equals("IntMap")) {
+ // Supported types
+ // PRINT("\tq: ");
+ // printContainer(&q);
+ // model_print("\n");
+ code.addLine(SpecNaming.PRINT + "(\"\\t" + name + ": \");");
+ code.addLine(SpecNaming.PrintContainer + "(&" + name + ");");
+ code.addLine(SpecNaming.PRINT + "(\"\\n\");");
+ } else if (type.equals("IntList *") || type.equals("IntSet *")
+ || type.equals("IntMap *")) {
+ // Supported pointer types
+ // PRINT("\tq: ");
+ // printContainer(q);
+ // model_print("\n");
+ code.addLine(SpecNaming.PRINT + "(\"\\t" + name + ": \");");
+ code.addLine(SpecNaming.PrintContainer + "(" + name + ");");
+ code.addLine(SpecNaming.PRINT + "(\"\\n\");");
+ } else if (type.equals("void")) {
+ // Just do nothing!
+ } else {
+ if (type.endsWith("*")) { // If it's an obvious pointer (with a STAR)
+ // Weak support pointer types (just print out the address)
+ // PRINT("\tmutex=%p\n", mutex);
+ code.addLine(SpecNaming.PRINT + "(\"\\t" + name + "=%p\\n\", "
+ + name + ");");
+ } else {
+ code.addLine("// We do not support auto-gen print-out for type: "
+ + type + ".");
+ }
+
+ }
+
+ return code;
+ }
+