-
Notifications
You must be signed in to change notification settings - Fork 283
Add code_inputt
and code_outputt
for ID_input
and ID_output
#4855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,10 @@ Author: Daniel Kroening, kroening@kroening.com | |
|
||
#include "std_code.h" | ||
|
||
#include "arith_tools.h" | ||
#include "c_types.h" | ||
#include "std_expr.h" | ||
#include "string_constant.h" | ||
|
||
/// If this `codet` is a \ref code_blockt (i.e.\ it represents a block of | ||
/// statements), return the unmodified input. Otherwise (i.e.\ the `codet` | ||
|
@@ -167,3 +170,59 @@ void code_function_bodyt::set_parameter_identifiers( | |
sub.back().set(ID_identifier, id); | ||
} | ||
} | ||
|
||
code_inputt::code_inputt( | ||
std::vector<exprt> arguments, | ||
optionalt<source_locationt> location) | ||
: codet{ID_input, std::move(arguments)} | ||
{ | ||
if(location) | ||
add_source_location() = std::move(*location); | ||
check(*this, validation_modet::INVARIANT); | ||
} | ||
|
||
code_inputt::code_inputt( | ||
const irep_idt &description, | ||
exprt expression, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me, I will update this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
optionalt<source_locationt> location) | ||
: code_inputt{{address_of_exprt(index_exprt( | ||
string_constantt(description), | ||
from_integer(0, index_type()))), | ||
std::move(expression)}, | ||
std::move(location)} | ||
{ | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit odd that you have to choose between multiple inputs in a vector with no description and one input with a description. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The constructor which takes one input with a description is a convenient interface for use in the construction of The constructor which takes multiple inputs in a vector is required in order to support arbitrary calls to Is my explanation of this aspect sufficient, or do you want me to make further changes to the code in the PR - such documenting the purposes of the two constructors? |
||
void code_inputt::check(const codet &code, const validation_modet vm) | ||
{ | ||
DATA_CHECK( | ||
vm, code.operands().size() >= 2, "input must have at least two operands"); | ||
} | ||
|
||
code_outputt::code_outputt( | ||
std::vector<exprt> arguments, | ||
optionalt<source_locationt> location) | ||
: codet{ID_output, std::move(arguments)} | ||
{ | ||
if(location) | ||
add_source_location() = std::move(*location); | ||
check(*this, validation_modet::INVARIANT); | ||
} | ||
|
||
code_outputt::code_outputt( | ||
const irep_idt &description, | ||
exprt expression, | ||
optionalt<source_locationt> location) | ||
: code_outputt{{address_of_exprt(index_exprt( | ||
string_constantt(description), | ||
from_integer(0, index_type()))), | ||
std::move(expression)}, | ||
std::move(location)} | ||
{ | ||
} | ||
|
||
void code_outputt::check(const codet &code, const validation_modet vm) | ||
{ | ||
DATA_CHECK( | ||
vm, code.operands().size() >= 2, "output must have at least two operands"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of a nuisance, but you'll need to add
// NOLINTNEXTLINE(build/deprecated)
before each of the above lines.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.