-
Notifications
You must be signed in to change notification settings - Fork 273
Factor out language_infot from languaget #2157
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,15 +21,8 @@ Author: Daniel Kroening, [email protected] | |
#include "ansi_c_entry_point.h" | ||
#include "ansi_c_typecheck.h" | ||
#include "ansi_c_parser.h" | ||
#include "expr2c.h" | ||
#include "c_preprocess.h" | ||
#include "ansi_c_internal_additions.h" | ||
#include "type2name.h" | ||
|
||
std::set<std::string> ansi_c_languaget::extensions() const | ||
{ | ||
return { "c", "i" }; | ||
} | ||
|
||
void ansi_c_languaget::modules_provided(std::set<std::string> &modules) | ||
{ | ||
|
@@ -144,36 +137,9 @@ void ansi_c_languaget::show_parse(std::ostream &out) | |
parse_tree.output(out); | ||
} | ||
|
||
std::unique_ptr<languaget> new_ansi_c_language() | ||
{ | ||
return util_make_unique<ansi_c_languaget>(); | ||
} | ||
|
||
bool ansi_c_languaget::from_expr( | ||
const exprt &expr, | ||
std::string &code, | ||
const namespacet &ns) | ||
{ | ||
code=expr2c(expr, ns); | ||
return false; | ||
} | ||
|
||
bool ansi_c_languaget::from_type( | ||
const typet &type, | ||
std::string &code, | ||
const namespacet &ns) | ||
std::unique_ptr<languaget> new_ansi_c_language(const language_infot &info) | ||
{ | ||
code=type2c(type, ns); | ||
return false; | ||
} | ||
|
||
bool ansi_c_languaget::type_to_name( | ||
const typet &type, | ||
std::string &name, | ||
const namespacet &ns) | ||
{ | ||
name=type2name(type, ns); | ||
return false; | ||
return std::unique_ptr<ansi_c_languaget>(new ansi_c_languaget(info)); | ||
} | ||
|
||
bool ansi_c_languaget::to_expr( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*******************************************************************\ | ||
|
||
Module: C Language | ||
|
||
Author: Daniel Kroening, [email protected] | ||
|
||
\*******************************************************************/ | ||
|
||
#include "ansi_c_language_info.h" | ||
|
||
#include "expr2c.h" | ||
#include "type2name.h" | ||
|
||
#include "ansi_c_language.h" | ||
|
||
std::set<std::string> ansi_c_language_infot::extensions() const | ||
{ | ||
return {"c", "i"}; | ||
} | ||
|
||
bool ansi_c_language_infot::from_expr( | ||
const exprt &expr, | ||
std::string &code, | ||
const namespacet &ns) const | ||
{ | ||
code = expr2c(expr, ns); | ||
return false; | ||
} | ||
|
||
bool ansi_c_language_infot::from_type( | ||
const typet &type, | ||
std::string &code, | ||
const namespacet &ns) const | ||
{ | ||
code = type2c(type, ns); | ||
return false; | ||
} | ||
|
||
bool ansi_c_language_infot::type_to_name( | ||
const typet &type, | ||
std::string &name, | ||
const namespacet &ns) const | ||
{ | ||
name = type2name(type, ns); | ||
return false; | ||
} | ||
|
||
std::unique_ptr<language_infot> new_ansi_c_language_info() | ||
{ | ||
return std::unique_ptr<language_infot>( | ||
new ansi_c_language_infot(new_ansi_c_language)); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*******************************************************************\ | ||
|
||
Module: C Language | ||
|
||
Author: Daniel Kroening, [email protected] | ||
|
||
\*******************************************************************/ | ||
|
||
#ifndef CPROVER_ANSI_C_ANSI_C_LANGUAGE_INFO_H | ||
#define CPROVER_ANSI_C_ANSI_C_LANGUAGE_INFO_H | ||
|
||
#include <memory> | ||
|
||
#include <langapi/language_info.h> | ||
|
||
class ansi_c_language_infot : public language_infot | ||
{ | ||
public: | ||
explicit ansi_c_language_infot(language_factoryt _factory) | ||
: language_infot(_factory) | ||
{ | ||
} | ||
|
||
irep_idt id() const override | ||
{ | ||
return ID_C; | ||
} | ||
|
||
std::string description() const override | ||
{ | ||
return "C"; | ||
} | ||
|
||
std::set<std::string> extensions() const override; | ||
|
||
bool from_expr(const exprt &expr, std::string &code, const namespacet &ns) | ||
const override; | ||
|
||
bool from_type(const typet &type, std::string &code, const namespacet &ns) | ||
const override; | ||
|
||
bool type_to_name(const typet &type, std::string &name, const namespacet &ns) | ||
const override; | ||
}; | ||
|
||
std::unique_ptr<language_infot> new_ansi_c_language_info(); | ||
|
||
#endif // CPROVER_ANSI_C_ANSI_C_LANGUAGE_INFO_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <sstream> | ||
|
||
#include <langapi/mode.h> | ||
|
||
#include <util/config.h> | ||
|
||
#include "ansi_c_language.h" | ||
|
@@ -88,9 +90,9 @@ void add_library( | |
|
||
std::istringstream in(src); | ||
|
||
ansi_c_languaget ansi_c_language; | ||
ansi_c_language.set_message_handler(message_handler); | ||
ansi_c_language.parse(in, ""); | ||
auto ansi_c_language = get_language_from_mode(ID_C); | ||
ansi_c_language->set_message_handler(message_handler); | ||
ansi_c_language->parse(in, ""); | ||
|
||
ansi_c_language.typecheck(symbol_table, "<built-in-library>"); | ||
ansi_c_language->typecheck(symbol_table, "<built-in-library>"); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,19 +13,13 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <langapi/mode.h> | ||
|
||
#include <ansi-c/ansi_c_language.h> | ||
#include <cpp/cpp_language.h> | ||
|
||
#ifdef HAVE_JSIL | ||
#include <jsil/jsil_language.h> | ||
#endif | ||
#include <ansi-c/ansi_c_language_info.h> | ||
#include <cpp/cpp_language_info.h> | ||
#include <jsil/jsil_language_info.h> | ||
|
||
void cbmc_parse_optionst::register_languages() | ||
{ | ||
register_language(new_ansi_c_language); | ||
register_language(new_cpp_language); | ||
|
||
#ifdef HAVE_JSIL | ||
register_language(new_jsil_language); | ||
#endif | ||
register_language(new_ansi_c_language_info); | ||
register_language(new_cpp_language_info); | ||
register_language(new_jsil_language_info); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ Author: Daniel Kroening, [email protected] | |
#include <util/options.h> | ||
#include <util/memory_info.h> | ||
|
||
#include <ansi-c/ansi_c_language.h> | ||
#include <cpp/cpp_language.h> | ||
#include <ansi-c/ansi_c_language_info.h> | ||
#include <cpp/cpp_language_info.h> | ||
|
||
#include <goto-programs/initialize_goto_model.h> | ||
#include <goto-programs/show_properties.h> | ||
|
@@ -105,8 +105,8 @@ int clobber_parse_optionst::doit() | |
return 0; | ||
} | ||
|
||
register_language(new_ansi_c_language); | ||
register_language(new_cpp_language); | ||
register_language(new_ansi_c_language_info); | ||
register_language(new_cpp_language_info); | ||
|
||
// | ||
// command line options | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The "remove conditional inclusion of JSIL" patch seems to be unrelated to the PR. It may well be a good idea (Do we need conditional compilation of features? If so, what is the policy?) but at the moment it is not explained or justified.
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.
See thread above - requested by @tautschnig due to inconsistent use.
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.
I agree that it would better fit a separate PR, but that PR would necessarily depend on this one because of overlapping changes, hence adding it in here seemed ok to me.