Skip to content

Commit 4f54e00

Browse files
author
thk123
committed
Only print the operands if there are some
Some instructions have no operands, to keep the JSON legible we omit the empty array.
1 parent efca262 commit 4f54e00

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/goto-programs/show_goto_functions_json.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,19 @@ json_objectt show_goto_functions_jsont::get_goto_functions(
9595
instruction_entry["instruction"]=
9696
json_stringt(instruction_builder.str());
9797

98-
json_arrayt operand_array;
99-
for(const exprt &operand : instruction.code.operands())
98+
if(instruction.code.operands().size()>0)
10099
{
101-
json_objectt operand_object;
102-
no_comments_irep_converter.convert_from_irep(operand, operand_object);
103-
operand_array.push_back(operand_object);
100+
json_arrayt operand_array;
101+
for(const exprt &operand : instruction.code.operands())
102+
{
103+
json_objectt operand_object;
104+
no_comments_irep_converter.convert_from_irep(
105+
operand, operand_object);
106+
operand_array.push_back(operand_object);
107+
}
108+
instruction_entry["operands"]=operand_array;
104109
}
105110

106-
instruction_entry["operands"]=operand_array;
107-
108111
if(!instruction.guard.is_true())
109112
{
110113
json_objectt guard_object;

0 commit comments

Comments
 (0)