|
30 | 30 | #include "c_qualifiers.h"
|
31 | 31 | #include "expr2c_class.h"
|
32 | 32 |
|
| 33 | +expr2c_configurationt expr2c_configurationt::default_configuration{true, |
| 34 | + true, |
| 35 | + true, |
| 36 | + "TRUE", |
| 37 | + "FALSE"}; |
| 38 | + |
33 | 39 | /*
|
34 | 40 |
|
35 | 41 | Precedences are as follows. Higher values mean higher precedence.
|
@@ -661,7 +667,12 @@ std::string expr2ct::convert_struct_type(
|
661 | 667 | const std::string &qualifiers_str,
|
662 | 668 | const std::string &declarator_str)
|
663 | 669 | {
|
664 |
| - return convert_struct_type(src, qualifiers_str, declarator_str, true, true); |
| 670 | + return convert_struct_type( |
| 671 | + src, |
| 672 | + qualifiers_str, |
| 673 | + declarator_str, |
| 674 | + configuration.print_struct_body_in_type, |
| 675 | + configuration.include_struct_padding_components); |
665 | 676 | }
|
666 | 677 |
|
667 | 678 | /// To generate C-like string for declaring (or defining) the given struct
|
@@ -734,7 +745,8 @@ std::string expr2ct::convert_array_type(
|
734 | 745 | const qualifierst &qualifiers,
|
735 | 746 | const std::string &declarator_str)
|
736 | 747 | {
|
737 |
| - return convert_array_type(src, qualifiers, declarator_str, true); |
| 748 | + return convert_array_type( |
| 749 | + src, qualifiers, declarator_str, configuration.include_array_size); |
738 | 750 | }
|
739 | 751 |
|
740 | 752 | /// To generate a C-like type declaration of an array. Optionally can include or
|
@@ -1996,18 +2008,18 @@ std::string expr2ct::convert_constant(
|
1996 | 2008 | /// FALSE.
|
1997 | 2009 | std::string expr2ct::convert_constant_bool(bool boolean_value)
|
1998 | 2010 | {
|
1999 |
| - // C doesn't really have these |
2000 | 2011 | if(boolean_value)
|
2001 |
| - return "TRUE"; |
| 2012 | + return configuration.true_string; |
2002 | 2013 | else
|
2003 |
| - return "FALSE"; |
| 2014 | + return configuration.false_string; |
2004 | 2015 | }
|
2005 | 2016 |
|
2006 | 2017 | std::string expr2ct::convert_struct(
|
2007 | 2018 | const exprt &src,
|
2008 | 2019 | unsigned &precedence)
|
2009 | 2020 | {
|
2010 |
| - return convert_struct(src, precedence, true); |
| 2021 | + return convert_struct( |
| 2022 | + src, precedence, configuration.include_struct_padding_components); |
2011 | 2023 | }
|
2012 | 2024 |
|
2013 | 2025 | /// To generate a C-like string representing a struct. Can optionally include
|
@@ -3947,17 +3959,33 @@ std::string expr2ct::convert(const exprt &src)
|
3947 | 3959 | return convert_with_precedence(src, precedence);
|
3948 | 3960 | }
|
3949 | 3961 |
|
3950 |
| -std::string expr2c(const exprt &expr, const namespacet &ns) |
| 3962 | +std::string expr2c( |
| 3963 | + const exprt &expr, |
| 3964 | + const namespacet &ns, |
| 3965 | + const expr2c_configurationt &configuration) |
3951 | 3966 | {
|
3952 | 3967 | std::string code;
|
3953 |
| - expr2ct expr2c(ns); |
| 3968 | + expr2ct expr2c(ns, configuration); |
3954 | 3969 | expr2c.get_shorthands(expr);
|
3955 | 3970 | return expr2c.convert(expr);
|
3956 | 3971 | }
|
3957 | 3972 |
|
3958 |
| -std::string type2c(const typet &type, const namespacet &ns) |
| 3973 | +std::string expr2c(const exprt &expr, const namespacet &ns) |
3959 | 3974 | {
|
3960 |
| - expr2ct expr2c(ns); |
| 3975 | + return expr2c(expr, ns, expr2c_configurationt::default_configuration); |
| 3976 | +} |
| 3977 | + |
| 3978 | +std::string type2c( |
| 3979 | + const typet &type, |
| 3980 | + const namespacet &ns, |
| 3981 | + const expr2c_configurationt &configuration) |
| 3982 | +{ |
| 3983 | + expr2ct expr2c(ns, configuration); |
3961 | 3984 | // expr2c.get_shorthands(expr);
|
3962 | 3985 | return expr2c.convert(type);
|
3963 | 3986 | }
|
| 3987 | + |
| 3988 | +std::string type2c(const typet &type, const namespacet &ns) |
| 3989 | +{ |
| 3990 | + return type2c(type, ns, expr2c_configurationt::default_configuration); |
| 3991 | +} |
0 commit comments