1717#include < map>
1818#include < utility>
1919
20+ #define CHECK_FAST_C (compiler_options, x ) \
21+ if (compiler_options.fast && x.m_value != nullptr ) { \
22+ visit_expr (*x.m_value ); \
23+ return ; \
24+ } \
2025
2126namespace LCompilers {
2227
@@ -30,9 +35,9 @@ class ASRToCVisitor : public BaseCCPPVisitor<ASRToCVisitor>
3035
3136 int counter;
3237
33- ASRToCVisitor (diag::Diagnostics &diag, Platform &platform ,
38+ ASRToCVisitor (diag::Diagnostics &diag, CompilerOptions &co ,
3439 int64_t default_lower_bound)
35- : BaseCCPPVisitor(diag, platform, false , false , true , default_lower_bound),
40+ : BaseCCPPVisitor(diag, co. platform, co , false , false , true , default_lower_bound),
3641 array_types_decls (std::string(" \n struct dimension_descriptor\n "
3742 " {\n int32_t lower_bound, length;\n };\n " )),
3843 c_utils_functions{std::make_unique<CUtils::CUtilFunctions>()},
@@ -970,15 +975,18 @@ R"(
970975 }
971976
972977 void visit_EnumStaticMember (const ASR::EnumStaticMember_t& x) {
978+ CHECK_FAST_C (compiler_options, x)
973979 ASR::Variable_t* enum_var = ASR::down_cast<ASR::Variable_t>(x.m_m );
974980 src = std::string (enum_var->m_name );
975981 }
976982
977983 void visit_EnumValue (const ASR::EnumValue_t& x) {
984+ CHECK_FAST_C (compiler_options, x)
978985 visit_expr (*x.m_v );
979986 }
980987
981988 void visit_EnumName (const ASR::EnumName_t& x) {
989+ CHECK_FAST_C (compiler_options, x)
982990 int64_t min_value = INT64_MAX;
983991 ASR::Enum_t* enum_t = ASR::down_cast<ASR::Enum_t>(x.m_enum_type );
984992 ASR::EnumType_t* enum_type = ASR::down_cast<ASR::EnumType_t>(enum_t ->m_enum_type );
@@ -1127,6 +1135,7 @@ R"(
11271135 }
11281136
11291137 void visit_ArraySize (const ASR::ArraySize_t& x) {
1138+ CHECK_FAST_C (compiler_options, x)
11301139 visit_expr (*x.m_v );
11311140 std::string var_name = src;
11321141 std::string args = " " ;
@@ -1144,6 +1153,7 @@ R"(
11441153 }
11451154
11461155 void visit_ArrayReshape (const ASR::ArrayReshape_t& x) {
1156+ CHECK_FAST_C (compiler_options, x)
11471157 visit_expr (*x.m_array );
11481158 std::string array = src;
11491159 visit_expr (*x.m_shape );
@@ -1166,6 +1176,7 @@ R"(
11661176 }
11671177
11681178 void visit_ArrayBound (const ASR::ArrayBound_t& x) {
1179+ CHECK_FAST_C (compiler_options, x)
11691180 visit_expr (*x.m_v );
11701181 std::string var_name = src;
11711182 std::string args = " " ;
@@ -1203,6 +1214,7 @@ R"(
12031214 }
12041215
12051216 void visit_ArrayItem (const ASR::ArrayItem_t &x) {
1217+ CHECK_FAST_C (compiler_options, x)
12061218 this ->visit_expr (*x.m_v );
12071219 std::string array = src;
12081220 std::string out = array;
@@ -1253,6 +1265,7 @@ R"(
12531265 }
12541266
12551267 void visit_StringItem (const ASR::StringItem_t& x) {
1268+ CHECK_FAST_C (compiler_options, x)
12561269 this ->visit_expr (*x.m_idx );
12571270 std::string idx = std::move (src);
12581271 this ->visit_expr (*x.m_arg );
@@ -1261,6 +1274,7 @@ R"(
12611274 }
12621275
12631276 void visit_StringLen (const ASR::StringLen_t &x) {
1277+ CHECK_FAST_C (compiler_options, x)
12641278 this ->visit_expr (*x.m_arg );
12651279 src = " strlen(" + src + " )" ;
12661280 }
@@ -1276,7 +1290,7 @@ R"(
12761290};
12771291
12781292Result<std::string> asr_to_c (Allocator &al, ASR::TranslationUnit_t &asr,
1279- diag::Diagnostics &diagnostics, Platform &platform ,
1293+ diag::Diagnostics &diagnostics, CompilerOptions &co ,
12801294 int64_t default_lower_bound)
12811295{
12821296
@@ -1286,7 +1300,7 @@ Result<std::string> asr_to_c(Allocator &al, ASR::TranslationUnit_t &asr,
12861300 pass_replace_array_op (al, asr, pass_options);
12871301 pass_unused_functions (al, asr, pass_options);
12881302 pass_replace_class_constructor (al, asr, pass_options);
1289- ASRToCVisitor v (diagnostics, platform , default_lower_bound);
1303+ ASRToCVisitor v (diagnostics, co , default_lower_bound);
12901304 try {
12911305 v.visit_asr ((ASR::asr_t &)asr);
12921306 } catch (const CodeGenError &e) {
0 commit comments