MCPcopy Create free account
hub / github.com/csmith-project/csmith / output_runtime_value

Method output_runtime_value

src/Variable.cpp:1036–1081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034}
1035
1036int
1037Variable::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
1083int
1084Variable::output_volatile_fprintf(ostream &out, int indent, const string &name,

Callers 5

output_reduced_stmMethod · 0.80
rewrite_func_callMethod · 0.80
output_global_valuesMethod · 0.80

Calls 4

output_tabFunction · 0.85
printf_directiveMethod · 0.80
sizeMethod · 0.80
get_sizesMethod · 0.80

Tested by

no test coverage detected