| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent aa4204b commit 8a2cf67
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,6 +137,7 @@ static inline ASR::ttype_t* expr_type(const ASR::expr_t *f) | |||
| 137 | 137 | case ASR::exprType::ListSection: { return ((ASR::ListSection_t*)f)->m_type; } | |
| 138 | 138 | case ASR::exprType::ListPop: { return ((ASR::ListPop_t*)f)->m_type; } | |
| 139 | 139 | case ASR::exprType::DictPop: { return ((ASR::DictPop_t*)f)->m_type; } | |
| 140 | + case ASR::exprType::SetPop: { return ((ASR::SetPop_t*)f)->m_type; } | ||
| 140 | 141 | default : throw LFortranException("Not implemented"); | |
| 141 | 142 | } | |
| 142 | 143 | } | |
@@ -311,6 +312,7 @@ static inline ASR::expr_t* expr_value(ASR::expr_t *f) | |||
| 311 | 312 | case ASR::exprType::ListSection: { return ASR::down_cast<ASR::ListSection_t>(f)->m_value; } | |
| 312 | 313 | case ASR::exprType::ListPop: { return ASR::down_cast<ASR::ListPop_t>(f)->m_value; } | |
| 313 | 314 | case ASR::exprType::DictPop: { return ASR::down_cast<ASR::DictPop_t>(f)->m_value; } | |
| 315 | + case ASR::exprType::SetPop: { return ASR::down_cast<ASR::SetPop_t>(f)->m_value; } | ||
| 314 | 316 | case ASR::exprType::DictItem: // Drop through | |
| 315 | 317 | case ASR::exprType::ArrayConstant: // Drop through | |
| 316 | 318 | case ASR::exprType::IntegerConstant: // Drop through | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ struct AttributeHandler { | |||
| 22 | 22 | {"list@remove", &eval_list_remove}, | |
| 23 | 23 | {"list@insert", &eval_list_insert}, | |
| 24 | 24 | {"list@pop", &eval_list_pop}, | |
| 25 | + {"set@pop", &eval_set_pop}, | ||
| 25 | 26 | {"set@add", &eval_set_add}, | |
| 26 | 27 | {"set@remove", &eval_set_remove}, | |
| 27 | 28 | {"dict@get", &eval_dict_get}, | |
@@ -177,6 +178,17 @@ struct AttributeHandler { | |||
| 177 | 178 | return make_ListPop_t(al, loc, s, idx, list_type, nullptr); | |
| 178 | 179 | } | |
| 179 | 180 | ||
| 181 | + static ASR::asr_t* eval_set_pop(ASR::symbol_t *s, Allocator &al, const Location &loc, | ||
| 182 | + Vec<ASR::expr_t*> &args, diag::Diagnostics &/*diag*/) { | ||
| 183 | + if (args.size() != 0) { | ||
| 184 | + throw SemanticError("pop() takes no arguments (" + std::to_string(args.size()) + " given)", loc); | ||
| 185 | + } | ||
| 186 | + ASR::Variable_t *v = ASR::down_cast<ASR::Variable_t>(s); | ||
| 187 | + ASR::ttype_t *type = v->m_type; | ||
| 188 | + ASR::ttype_t *set_type = ASR::down_cast<ASR::Set_t>(type)->m_type; | ||
| 189 | + return make_SetPop_t(al, loc, s, set_type, nullptr); | ||
| 190 | + } | ||
| 191 | + | ||
| 180 | 192 | static ASR::asr_t* eval_set_add(ASR::symbol_t *s, Allocator &al, const Location &loc, | |
| 181 | 193 | Vec<ASR::expr_t*> &args, diag::Diagnostics &diag) { | |
| 182 | 194 | if (args.size() != 1) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments