17
17
#include < map>
18
18
#include < utility>
19
19
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
+ } \
20
25
21
26
namespace LCompilers {
22
27
@@ -30,9 +35,9 @@ class ASRToCVisitor : public BaseCCPPVisitor<ASRToCVisitor>
30
35
31
36
int counter;
32
37
33
- ASRToCVisitor (diag::Diagnostics &diag, Platform &platform ,
38
+ ASRToCVisitor (diag::Diagnostics &diag, CompilerOptions &co ,
34
39
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),
36
41
array_types_decls (std::string(" \n struct dimension_descriptor\n "
37
42
" {\n int32_t lower_bound, length;\n };\n " )),
38
43
c_utils_functions{std::make_unique<CUtils::CUtilFunctions>()},
@@ -970,15 +975,18 @@ R"(
970
975
}
971
976
972
977
void visit_EnumStaticMember (const ASR::EnumStaticMember_t& x) {
978
+ CHECK_FAST_C (compiler_options, x)
973
979
ASR::Variable_t* enum_var = ASR::down_cast<ASR::Variable_t>(x.m_m );
974
980
src = std::string (enum_var->m_name );
975
981
}
976
982
977
983
void visit_EnumValue (const ASR::EnumValue_t& x) {
984
+ CHECK_FAST_C (compiler_options, x)
978
985
visit_expr (*x.m_v );
979
986
}
980
987
981
988
void visit_EnumName (const ASR::EnumName_t& x) {
989
+ CHECK_FAST_C (compiler_options, x)
982
990
int64_t min_value = INT64_MAX;
983
991
ASR::Enum_t* enum_t = ASR::down_cast<ASR::Enum_t>(x.m_enum_type );
984
992
ASR::EnumType_t* enum_type = ASR::down_cast<ASR::EnumType_t>(enum_t ->m_enum_type );
@@ -1127,6 +1135,7 @@ R"(
1127
1135
}
1128
1136
1129
1137
void visit_ArraySize (const ASR::ArraySize_t& x) {
1138
+ CHECK_FAST_C (compiler_options, x)
1130
1139
visit_expr (*x.m_v );
1131
1140
std::string var_name = src;
1132
1141
std::string args = " " ;
@@ -1144,6 +1153,7 @@ R"(
1144
1153
}
1145
1154
1146
1155
void visit_ArrayReshape (const ASR::ArrayReshape_t& x) {
1156
+ CHECK_FAST_C (compiler_options, x)
1147
1157
visit_expr (*x.m_array );
1148
1158
std::string array = src;
1149
1159
visit_expr (*x.m_shape );
@@ -1166,6 +1176,7 @@ R"(
1166
1176
}
1167
1177
1168
1178
void visit_ArrayBound (const ASR::ArrayBound_t& x) {
1179
+ CHECK_FAST_C (compiler_options, x)
1169
1180
visit_expr (*x.m_v );
1170
1181
std::string var_name = src;
1171
1182
std::string args = " " ;
@@ -1203,6 +1214,7 @@ R"(
1203
1214
}
1204
1215
1205
1216
void visit_ArrayItem (const ASR::ArrayItem_t &x) {
1217
+ CHECK_FAST_C (compiler_options, x)
1206
1218
this ->visit_expr (*x.m_v );
1207
1219
std::string array = src;
1208
1220
std::string out = array;
@@ -1253,6 +1265,7 @@ R"(
1253
1265
}
1254
1266
1255
1267
void visit_StringItem (const ASR::StringItem_t& x) {
1268
+ CHECK_FAST_C (compiler_options, x)
1256
1269
this ->visit_expr (*x.m_idx );
1257
1270
std::string idx = std::move (src);
1258
1271
this ->visit_expr (*x.m_arg );
@@ -1261,6 +1274,7 @@ R"(
1261
1274
}
1262
1275
1263
1276
void visit_StringLen (const ASR::StringLen_t &x) {
1277
+ CHECK_FAST_C (compiler_options, x)
1264
1278
this ->visit_expr (*x.m_arg );
1265
1279
src = " strlen(" + src + " )" ;
1266
1280
}
@@ -1276,7 +1290,7 @@ R"(
1276
1290
};
1277
1291
1278
1292
Result<std::string> asr_to_c (Allocator &al, ASR::TranslationUnit_t &asr,
1279
- diag::Diagnostics &diagnostics, Platform &platform ,
1293
+ diag::Diagnostics &diagnostics, CompilerOptions &co ,
1280
1294
int64_t default_lower_bound)
1281
1295
{
1282
1296
@@ -1286,7 +1300,7 @@ Result<std::string> asr_to_c(Allocator &al, ASR::TranslationUnit_t &asr,
1286
1300
pass_replace_array_op (al, asr, pass_options);
1287
1301
pass_unused_functions (al, asr, pass_options);
1288
1302
pass_replace_class_constructor (al, asr, pass_options);
1289
- ASRToCVisitor v (diagnostics, platform , default_lower_bound);
1303
+ ASRToCVisitor v (diagnostics, co , default_lower_bound);
1290
1304
try {
1291
1305
v.visit_asr ((ASR::asr_t &)asr);
1292
1306
} catch (const CodeGenError &e) {
0 commit comments