@@ -318,7 +318,6 @@ struct IntrinsicNodeHandler {
318318 loc);
319319 }
320320 ASR::expr_t *arg = nullptr ;
321- ASR::expr_t *res_value = nullptr ;
322321 ASR::ttype_t *arg_type = nullptr ;
323322 if (args.size () > 0 ) {
324323 arg = args[0 ].m_value ;
@@ -345,43 +344,43 @@ struct IntrinsicNodeHandler {
345344 sm << ival;
346345 std::string value_str = sm.str ();
347346 sm.clear ();
348- ASR::ttype_t * res_type = ASRUtils::TYPE (ASR::make_Allocatable_t (al, loc,
349- ASRUtils::TYPE (ASR::make_String_t (al, loc, 1 , nullptr ,
350- ASR::string_length_kindType::DeferredLength,
351- ASR::string_physical_typeType::DescriptorString))));
352- res_value = ASR::down_cast<ASR:: expr_t >( ASR::make_StringConstant_t (al,
353- loc, s2c (al, value_str), res_type) );
347+ ASR::ttype_t * res_type = ASRUtils::TYPE (ASR::make_String_t (al, loc, 1 ,
348+ ASRUtils::EXPR (ASR::make_IntegerConstant_t (al, loc,
349+ value_str. size (), ASRUtils::TYPE ( ASR::make_Integer_t (al, loc, 4 )))),
350+ ASR::string_length_kindType::ExpressionLength,
351+ ASR::string_physical_typeType::DescriptorString));
352+ return ASR::make_StringConstant_t (al, loc, s2c (al, value_str), res_type);
354353 }
355354 return ASR::make_Cast_t (al, loc, arg, ASR::cast_kindType::RealToString,
356- str_type, res_value );
355+ str_type, nullptr );
357356 } else if (ASRUtils::is_integer (*arg_type)) {
358357 if (ASRUtils::expr_value (arg) != nullptr ) {
359358 int64_t number = ASR::down_cast<ASR::IntegerConstant_t>(
360359 ASRUtils::expr_value (arg))->m_n ;
361360 std::string value_str = std::to_string (number);
362- ASR::ttype_t * res_type = ASRUtils::TYPE (ASR::make_Allocatable_t (al, loc,
363- ASRUtils::TYPE (ASR::make_String_t (al, loc, 1 , nullptr ,
364- ASR::string_length_kindType::DeferredLength,
365- ASR::string_physical_typeType::DescriptorString))));
366- res_value = ASR::down_cast<ASR:: expr_t >( ASR::make_StringConstant_t (al,
367- loc, s2c (al, value_str), res_type) );
361+ ASR::ttype_t * res_type = ASRUtils::TYPE (ASR::make_String_t (al, loc, 1 ,
362+ ASRUtils::EXPR (ASR::make_IntegerConstant_t (al, loc,
363+ value_str. size (), ASRUtils::TYPE ( ASR::make_Integer_t (al, loc, 4 )))),
364+ ASR::string_length_kindType::ExpressionLength,
365+ ASR::string_physical_typeType::DescriptorString));
366+ return ASR::make_StringConstant_t (al, loc, s2c (al, value_str), res_type);
368367 }
369368 return ASR::make_Cast_t (al, loc, arg, ASR::cast_kindType::IntegerToString,
370- str_type, res_value );
369+ str_type, nullptr );
371370 } else if (ASRUtils::is_logical (*arg_type)) {
372371 if (ASRUtils::expr_value (arg) != nullptr ) {
373372 bool bool_number = ASR::down_cast<ASR::LogicalConstant_t>(
374373 ASRUtils::expr_value (arg))->m_value ;
375374 std::string value_str = (bool_number)? " True" : " False" ;
376- ASR::ttype_t * res_type = ASRUtils::TYPE (ASR::make_Allocatable_t (al, loc,
377- ASRUtils::TYPE (ASR::make_String_t (al, loc, 1 , nullptr ,
378- ASR::string_length_kindType::DeferredLength,
379- ASR::string_physical_typeType::DescriptorString))));
380- res_value = ASR::down_cast<ASR:: expr_t >( ASR::make_StringConstant_t (al,
381- loc, s2c (al, value_str), res_type) );
375+ ASR::ttype_t * res_type = ASRUtils::TYPE (ASR::make_String_t (al, loc, 1 ,
376+ ASRUtils::EXPR (ASR::make_IntegerConstant_t (al, loc,
377+ value_str. size (), ASRUtils::TYPE ( ASR::make_Integer_t (al, loc, 4 )))),
378+ ASR::string_length_kindType::ExpressionLength,
379+ ASR::string_physical_typeType::DescriptorString));
380+ return ASR::make_StringConstant_t (al, loc, s2c (al, value_str), res_type);
382381 }
383382 return ASR::make_Cast_t (al, loc, arg, ASR::cast_kindType::LogicalToString,
384- str_type, res_value );
383+ str_type, nullptr );
385384
386385 } else if (ASRUtils::is_character (*arg_type)) {
387386 return (ASR::asr_t *)arg;
0 commit comments