| 1034 | } |
| 1035 | |
| 1036 | int |
| 1037 | Variable::output_runtime_value(ostream &out, string prefix, string suffix, int indent, bool multi_lines) const |
| 1038 | { |
| 1039 | string directive = type->printf_directive(); |
| 1040 | ostringstream oss; |
| 1041 | // for field of struct arrays, create an itemized variable for each member and output the printf individually |
| 1042 | // JYTODO: if all members are the same value, consolidate into one printf? |
| 1043 | if (is_virtual()) { |
| 1044 | assert (!is_field_var()); |
| 1045 | // var must be a virtual array, duplicate the directive for all members |
| 1046 | int j, k; |
| 1047 | const ArrayVariable* av = (const ArrayVariable*)this; |
| 1048 | for (k=av->get_sizes().size()-1; k>=0; k--) { |
| 1049 | int len = av->get_sizes()[k]; |
| 1050 | oss.str(""); |
| 1051 | oss << "{"; |
| 1052 | for (j=0; j<len; j++) { |
| 1053 | oss << directive; |
| 1054 | if (j<len-1) { |
| 1055 | oss << ", "; |
| 1056 | } |
| 1057 | } |
| 1058 | oss << "}"; |
| 1059 | directive = oss.str(); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | output_tab(out, indent); |
| 1064 | if (multi_lines) { |
| 1065 | out << "printf(\"" << prefix << "\");" << endl; |
| 1066 | output_tab(out, indent); |
| 1067 | out << "printf(\"" << directive << suffix << "\", " << to_string() <<");"; |
| 1068 | } |
| 1069 | else { |
| 1070 | out <<"printf(\""; |
| 1071 | out << prefix; |
| 1072 | // distinguish signed and unsigned integers (unnecessary?) |
| 1073 | out << directive; |
| 1074 | //out << oss.str(); |
| 1075 | out << suffix; |
| 1076 | out << "\", "; |
| 1077 | out << to_string(); |
| 1078 | out <<");"; |
| 1079 | } |
| 1080 | return 0; |
| 1081 | } |
| 1082 | |
| 1083 | int |
| 1084 | Variable::output_volatile_fprintf(ostream &out, int indent, const string &name, |
no test coverage detected