@@ -39,20 +39,20 @@ const std::size_t interpretert::npos=std::numeric_limits<size_t>::max();
39
39
40
40
void interpretert::operator ()()
41
41
{
42
- status () << " 0- Initialize:" << eom;
42
+ output. status () << " 0- Initialize:" << messaget:: eom;
43
43
initialize (true );
44
44
try
45
45
{
46
- status () << " Type h for help\n " << eom;
46
+ output. status () << " Type h for help\n " << messaget:: eom;
47
47
48
48
while (!done)
49
49
command ();
50
50
51
- status () << total_steps << " - Program End.\n " << eom;
51
+ output. status () << total_steps << " - Program End.\n " << messaget:: eom;
52
52
}
53
53
catch (const char *e)
54
54
{
55
- error () << e << " \n " << eom;
55
+ output. error () << e << " \n " << messaget:: eom;
56
56
}
57
57
58
58
while (!done)
@@ -113,22 +113,19 @@ void interpretert::show_state()
113
113
{
114
114
if (!show)
115
115
return ;
116
- status () << " \n "
117
- << total_steps+ 1
118
- << " ----------------------------------------------------\n " ;
116
+ output. status () << " \n "
117
+ << total_steps + 1
118
+ << " ----------------------------------------------------\n " ;
119
119
120
120
if (pc==function->second .body .instructions .end ())
121
121
{
122
- status () << " End of function '" << function->first << " '\n " ;
122
+ output. status () << " End of function '" << function->first << " '\n " ;
123
123
}
124
124
else
125
125
function->second .body .output_instruction (
126
- ns,
127
- function->first ,
128
- status (),
129
- *pc);
126
+ ns, function->first , output.status (), *pc);
130
127
131
- status () << eom;
128
+ output. status () << messaget:: eom;
132
129
}
133
130
134
131
// / reads a user command and executes it.
@@ -147,18 +144,18 @@ void interpretert::command()
147
144
done=true ;
148
145
else if (ch==' h' )
149
146
{
150
- status () << " Interpreter help\n "
151
- << " h: display this menu\n "
152
- << " j: output json trace\n "
153
- << " m: output memory dump\n "
154
- << " o: output goto trace\n "
155
- << " q: quit\n "
156
- << " r: run up to entry point\n "
157
- << " s#: step a number of instructions\n "
158
- << " sa: step across a function\n "
159
- << " so: step out of a function\n "
160
- << " se: step until end of program\n "
161
- << eom;
147
+ output. status () << " Interpreter help\n "
148
+ << " h: display this menu\n "
149
+ << " j: output json trace\n "
150
+ << " m: output memory dump\n "
151
+ << " o: output goto trace\n "
152
+ << " q: quit\n "
153
+ << " r: run up to entry point\n "
154
+ << " s#: step a number of instructions\n "
155
+ << " sa: step across a function\n "
156
+ << " so: step out of a function\n "
157
+ << " se: step until end of program\n "
158
+ << messaget:: eom;
162
159
}
163
160
else if (ch==' j' )
164
161
{
@@ -176,7 +173,7 @@ void interpretert::command()
176
173
return ;
177
174
}
178
175
}
179
- json_steps.output (result ());
176
+ json_steps.output (output. result ());
180
177
}
181
178
else if (ch==' m' )
182
179
{
@@ -197,7 +194,7 @@ void interpretert::command()
197
194
return ;
198
195
}
199
196
}
200
- steps.output (ns, result ());
197
+ steps.output (ns, output. result ());
201
198
}
202
199
else if (ch==' r' )
203
200
{
@@ -408,8 +405,9 @@ void interpretert::execute_other()
408
405
mp_integer size=get_size (pc->code .op0 ().type ());
409
406
while (rhs.size ()<size) rhs.insert (rhs.end (), tmp.begin (), tmp.end ());
410
407
if (size!=rhs.size ())
411
- error () << " !! failed to obtain rhs (" << rhs.size () << " vs. "
412
- << size << " )\n " << eom;
408
+ output.error () << " !! failed to obtain rhs (" << rhs.size () << " vs. "
409
+ << size << " )\n "
410
+ << messaget::eom;
413
411
else
414
412
{
415
413
assign (address, rhs);
@@ -637,9 +635,9 @@ exprt interpretert::get_value(
637
635
symbol_expr, from_integer (offset_from_address, integer_typet ()));
638
636
}
639
637
640
- error () << " interpreter: invalid pointer "
641
- << rhs[numeric_cast_v<std::size_t >(offset)] << " > object count "
642
- << memory.size () << eom;
638
+ output. error () << " interpreter: invalid pointer "
639
+ << rhs[numeric_cast_v<std::size_t >(offset)]
640
+ << " > object count " << memory.size () << messaget:: eom;
643
641
644
642
throw " interpreter: reading from invalid pointer" ;
645
643
}
@@ -671,10 +669,9 @@ void interpretert::execute_assign()
671
669
mp_integer size=get_size (code_assign.lhs ().type ());
672
670
673
671
if (size!=rhs.size ())
674
- error () << " !! failed to obtain rhs ("
675
- << rhs.size () << " vs. "
676
- << size << " )\n "
677
- << eom;
672
+ output.error () << " !! failed to obtain rhs (" << rhs.size () << " vs. "
673
+ << size << " )\n "
674
+ << messaget::eom;
678
675
else
679
676
{
680
677
goto_trace_stept &trace_step=steps.get_last_step ();
@@ -716,11 +713,11 @@ void interpretert::assign(
716
713
memory_cellt &cell = memory[numeric_cast_v<std::size_t >(address_val)];
717
714
if (show)
718
715
{
719
- status () << total_steps << " ** assigning "
720
- << address_to_symbol (address_val).get_identifier () << " [ "
721
- << address_to_offset (address_val)
722
- << " ]:=" << rhs[numeric_cast_v<std::size_t >(i)] << " \n "
723
- << eom;
716
+ output. status () << total_steps << " ** assigning "
717
+ << address_to_symbol (address_val).get_identifier ()
718
+ << " [ " << address_to_offset (address_val)
719
+ << " ]:=" << rhs[numeric_cast_v<std::size_t >(i)] << " \n "
720
+ << messaget:: eom;
724
721
}
725
722
cell.value = rhs[numeric_cast_v<std::size_t >(i)];
726
723
if (cell.initialized ==memory_cellt::initializedt::UNKNOWN)
@@ -740,8 +737,8 @@ void interpretert::execute_assert()
740
737
if (!evaluate_boolean (pc->get_condition ()))
741
738
{
742
739
if (show)
743
- error () << " assertion failed at " << pc->location_number
744
- << " \n " << eom;
740
+ output. error () << " assertion failed at " << pc->location_number << " \n "
741
+ << messaget:: eom;
745
742
}
746
743
}
747
744
@@ -847,7 +844,7 @@ void interpretert::execute_function_call()
847
844
}
848
845
849
846
if (show)
850
- error () << " no body for " + id2string ( identifier) << eom;
847
+ output. error () << " no body for " << identifier << messaget:: eom;
851
848
}
852
849
}
853
850
@@ -903,16 +900,17 @@ typet interpretert::concretize_type(const typet &type)
903
900
if (computed_size.size ()==1 &&
904
901
computed_size[0 ]>=0 )
905
902
{
906
- result () << " Concretized array with size " << computed_size[0 ]
907
- << eom;
903
+ output. result () << " Concretized array with size " << computed_size[0 ]
904
+ << messaget:: eom;
908
905
return
909
906
array_typet (
910
907
type.subtype (),
911
908
from_integer (computed_size[0 ], integer_typet ()));
912
909
}
913
910
else
914
911
{
915
- warning () << " Failed to concretize variable array" << eom;
912
+ output.warning () << " Failed to concretize variable array"
913
+ << messaget::eom;
916
914
}
917
915
}
918
916
return type;
@@ -1067,11 +1065,12 @@ void interpretert::print_memory(bool input_flags)
1067
1065
const memory_cellt &cell=cell_address.second ;
1068
1066
const auto identifier = address_to_symbol (i).get_identifier ();
1069
1067
const auto offset=address_to_offset (i);
1070
- status () << identifier << " [" << offset << " ]"
1071
- << " =" << cell.value << eom;
1068
+ output. status () << identifier << " [" << offset << " ]"
1069
+ << " =" << cell.value << messaget:: eom;
1072
1070
if (input_flags)
1073
- status () << " (" << static_cast <int >(cell.initialized ) << " )" << eom;
1074
- status () << eom;
1071
+ output.status () << " (" << static_cast <int >(cell.initialized ) << " )"
1072
+ << messaget::eom;
1073
+ output.status () << messaget::eom;
1075
1074
}
1076
1075
}
1077
1076
0 commit comments