@@ -68,6 +68,7 @@ struct PythonIntrinsicProcedures {
6868 {" _lpython_str_rstrip" , {m_builtin, &eval__lpython_str_rstrip}},
6969 {" _lpython_str_lstrip" , {m_builtin, &eval__lpython_str_lstrip}},
7070 {" _lpython_str_strip" , {m_builtin, &eval__lpython_str_strip}},
71+ {" _lpython_str_swapcase" , {m_builtin, &eval__lpython_str_swapcase}},
7172 {" _lpython_str_startswith" , {m_builtin, &eval__lpython_str_startswith}}
7273 };
7374 }
@@ -742,7 +743,16 @@ struct PythonIntrinsicProcedures {
742743 ASR ::ttype_t *res_type = ASRUtils::TYPE (ASR::make_StringConstant_t (al, loc, s2c (al, " " ), type));
743744 return ASR ::down_cast<ASR ::expr_t >(ASR::make_StringConstant_t (al, loc, s2c (al, res), res_type));
744745 }
745-
746+
747+ static ASR ::expr_t *eval__lpython_str_swapcase (Allocator &al, const Location &loc, Vec<ASR ::expr_t *> &args) {
748+ LFORTRAN_ASSERT (ASRUtils::all_args_evaluated (args));
749+ std::string res = " " ;
750+ ASR ::ttype_t *type = ASRUtils::TYPE (ASR::make_Character_t (al, loc,
751+ 1 , 1 , nullptr , nullptr , 0 ));
752+ ASR ::ttype_t *res_type = ASRUtils::TYPE (ASR::make_StringConstant_t (al, loc, s2c (al, " " ), type));
753+ return ASR ::down_cast<ASR ::expr_t >(ASR::make_StringConstant_t (al, loc, s2c (al, res), res_type));
754+ }
755+
746756 static ASR ::expr_t *eval_lpython_str_find (Allocator &al, const Location &loc, Vec<ASR ::expr_t *> &/* args*/ ) {
747757 // compile time action implemented on ast->asr
748758 ASR ::ttype_t *int_type = ASRUtils::TYPE (ASR::make_Integer_t (al, loc, 4 , nullptr , 0 ));
0 commit comments