@@ -30,9 +30,9 @@ class ASRToCVisitor : public BaseCCPPVisitor<ASRToCVisitor>
30
30
31
31
int counter;
32
32
33
- ASRToCVisitor (diag::Diagnostics &diag, Platform &platform ,
33
+ ASRToCVisitor (diag::Diagnostics &diag, CompilerOptions &co ,
34
34
int64_t default_lower_bound)
35
- : BaseCCPPVisitor(diag, platform, false , false , true , default_lower_bound),
35
+ : BaseCCPPVisitor(diag, co. platform, co , false , false , true , default_lower_bound),
36
36
array_types_decls (std::string(" \n struct dimension_descriptor\n "
37
37
" {\n int32_t lower_bound, length;\n };\n " )),
38
38
c_utils_functions{std::make_unique<CUtils::CUtilFunctions>()},
@@ -970,15 +970,27 @@ R"(
970
970
}
971
971
972
972
void visit_EnumStaticMember (const ASR::EnumStaticMember_t& x) {
973
+ if (compiler_options.fast && x.m_value != nullptr ) {
974
+ visit_expr (*x.m_value );
975
+ return ;
976
+ }
973
977
ASR::Variable_t* enum_var = ASR::down_cast<ASR::Variable_t>(x.m_m );
974
978
src = std::string (enum_var->m_name );
975
979
}
976
980
977
981
void visit_EnumValue (const ASR::EnumValue_t& x) {
982
+ if (compiler_options.fast && x.m_value != nullptr ) {
983
+ visit_expr (*x.m_value );
984
+ return ;
985
+ }
978
986
visit_expr (*x.m_v );
979
987
}
980
988
981
989
void visit_EnumName (const ASR::EnumName_t& x) {
990
+ if (compiler_options.fast && x.m_value != nullptr ) {
991
+ visit_expr (*x.m_value );
992
+ return ;
993
+ }
982
994
int64_t min_value = INT64_MAX;
983
995
ASR::Enum_t* enum_t = ASR::down_cast<ASR::Enum_t>(x.m_enum_type );
984
996
ASR::EnumType_t* enum_type = ASR::down_cast<ASR::EnumType_t>(enum_t ->m_enum_type );
@@ -1127,6 +1139,10 @@ R"(
1127
1139
}
1128
1140
1129
1141
void visit_ArraySize (const ASR::ArraySize_t& x) {
1142
+ if (compiler_options.fast && x.m_value != nullptr ) {
1143
+ visit_expr (*x.m_value );
1144
+ return ;
1145
+ }
1130
1146
visit_expr (*x.m_v );
1131
1147
std::string var_name = src;
1132
1148
std::string args = " " ;
@@ -1144,6 +1160,10 @@ R"(
1144
1160
}
1145
1161
1146
1162
void visit_ArrayReshape (const ASR::ArrayReshape_t& x) {
1163
+ if (compiler_options.fast && x.m_value != nullptr ) {
1164
+ visit_expr (*x.m_value );
1165
+ return ;
1166
+ }
1147
1167
visit_expr (*x.m_array );
1148
1168
std::string array = src;
1149
1169
visit_expr (*x.m_shape );
@@ -1166,6 +1186,10 @@ R"(
1166
1186
}
1167
1187
1168
1188
void visit_ArrayBound (const ASR::ArrayBound_t& x) {
1189
+ if (compiler_options.fast && x.m_value != nullptr ) {
1190
+ visit_expr (*x.m_value );
1191
+ return ;
1192
+ }
1169
1193
visit_expr (*x.m_v );
1170
1194
std::string var_name = src;
1171
1195
std::string args = " " ;
@@ -1203,6 +1227,10 @@ R"(
1203
1227
}
1204
1228
1205
1229
void visit_ArrayItem (const ASR::ArrayItem_t &x) {
1230
+ if (compiler_options.fast && x.m_value != nullptr ) {
1231
+ visit_expr (*x.m_value );
1232
+ return ;
1233
+ }
1206
1234
this ->visit_expr (*x.m_v );
1207
1235
std::string array = src;
1208
1236
std::string out = array;
@@ -1253,6 +1281,10 @@ R"(
1253
1281
}
1254
1282
1255
1283
void visit_StringItem (const ASR::StringItem_t& x) {
1284
+ if (compiler_options.fast && x.m_value != nullptr ) {
1285
+ visit_expr (*x.m_value );
1286
+ return ;
1287
+ }
1256
1288
this ->visit_expr (*x.m_idx );
1257
1289
std::string idx = std::move (src);
1258
1290
this ->visit_expr (*x.m_arg );
@@ -1261,6 +1293,10 @@ R"(
1261
1293
}
1262
1294
1263
1295
void visit_StringLen (const ASR::StringLen_t &x) {
1296
+ if (compiler_options.fast && x.m_value != nullptr ) {
1297
+ visit_expr (*x.m_value );
1298
+ return ;
1299
+ }
1264
1300
this ->visit_expr (*x.m_arg );
1265
1301
src = " strlen(" + src + " )" ;
1266
1302
}
@@ -1276,7 +1312,7 @@ R"(
1276
1312
};
1277
1313
1278
1314
Result<std::string> asr_to_c (Allocator &al, ASR::TranslationUnit_t &asr,
1279
- diag::Diagnostics &diagnostics, Platform &platform ,
1315
+ diag::Diagnostics &diagnostics, CompilerOptions &co ,
1280
1316
int64_t default_lower_bound)
1281
1317
{
1282
1318
@@ -1286,7 +1322,7 @@ Result<std::string> asr_to_c(Allocator &al, ASR::TranslationUnit_t &asr,
1286
1322
pass_replace_array_op (al, asr, pass_options);
1287
1323
pass_unused_functions (al, asr, pass_options);
1288
1324
pass_replace_class_constructor (al, asr, pass_options);
1289
- ASRToCVisitor v (diagnostics, platform , default_lower_bound);
1325
+ ASRToCVisitor v (diagnostics, co , default_lower_bound);
1290
1326
try {
1291
1327
v.visit_asr ((ASR::asr_t &)asr);
1292
1328
} catch (const CodeGenError &e) {
0 commit comments