@@ -46,7 +46,7 @@ enum class IntrinsicFunctions : int64_t {
46
46
Partition,
47
47
ListReverse,
48
48
ListPop,
49
- ListReserve ,
49
+ Reserve ,
50
50
DictKeys,
51
51
DictValues,
52
52
SetAdd,
@@ -103,7 +103,7 @@ inline std::string get_intrinsic_name(int x) {
103
103
INTRINSIC_NAME_CASE (Partition)
104
104
INTRINSIC_NAME_CASE (ListReverse)
105
105
INTRINSIC_NAME_CASE (ListPop)
106
- INTRINSIC_NAME_CASE (ListReserve )
106
+ INTRINSIC_NAME_CASE (Reserve )
107
107
INTRINSIC_NAME_CASE (DictKeys)
108
108
INTRINSIC_NAME_CASE (DictValues)
109
109
INTRINSIC_NAME_CASE (SetAdd)
@@ -1264,51 +1264,54 @@ static inline ASR::asr_t* create_ListPop(Allocator& al, const Location& loc,
1264
1264
1265
1265
} // namespace ListPop
1266
1266
1267
- namespace ListReserve {
1267
+ namespace Reserve {
1268
1268
1269
1269
static inline void verify_args (const ASR::IntrinsicFunction_t& x, diag::Diagnostics& diagnostics) {
1270
- ASRUtils::require_impl (x.n_args == 2 , " Call to list. reserve must have exactly one argument" ,
1270
+ ASRUtils::require_impl (x.n_args == 2 , " Call to reserve must have exactly one argument" ,
1271
1271
x.base .base .loc , diagnostics);
1272
1272
ASRUtils::require_impl (ASR::is_a<ASR::List_t>(*ASRUtils::expr_type (x.m_args [0 ])),
1273
- " Argument to list. reserve must be of list type" ,
1273
+ " First argument to reserve must be of list type" ,
1274
1274
x.base .base .loc , diagnostics);
1275
1275
ASRUtils::require_impl (ASR::is_a<ASR::Integer_t>(*ASRUtils::expr_type (x.m_args [1 ])),
1276
- " Argument to list. reserve must be an integer" ,
1276
+ " Second argument to reserve must be an integer" ,
1277
1277
x.base .base .loc , diagnostics);
1278
1278
ASRUtils::require_impl (x.m_type == nullptr ,
1279
- " Return type of list. reserve must be empty" ,
1279
+ " Return type of reserve must be empty" ,
1280
1280
x.base .base .loc , diagnostics);
1281
1281
}
1282
1282
1283
- static inline ASR::expr_t *eval_list_reserve (Allocator &/* al*/ ,
1283
+ static inline ASR::expr_t *eval_reserve (Allocator &/* al*/ ,
1284
1284
const Location &/* loc*/ , Vec<ASR::expr_t *>& /* args*/ ) {
1285
1285
// TODO: To be implemented for ListConstant expression
1286
1286
return nullptr ;
1287
1287
}
1288
1288
1289
- static inline ASR::asr_t * create_ListReserve (Allocator& al, const Location& loc,
1289
+ static inline ASR::asr_t * create_Reserve (Allocator& al, const Location& loc,
1290
1290
Vec<ASR::expr_t *>& args,
1291
1291
const std::function<void (const std::string &, const Location &)> err) {
1292
1292
if (args.size () != 2 ) {
1293
- err (" Call to list.reserve must have exactly one argument" , loc);
1293
+ err (" Call to reserve must have exactly two argument" , loc);
1294
+ }
1295
+ if (!ASR::is_a<ASR::List_t>(*ASRUtils::expr_type (args[0 ]))) {
1296
+ err (" First argument to reserve must be of list type" , loc);
1294
1297
}
1295
1298
if (!ASR::is_a<ASR::Integer_t>(*ASRUtils::expr_type (args[1 ]))) {
1296
- err (" Argument to list. reserve must be an integer" , loc);
1299
+ err (" Second argument to reserve must be an integer" , loc);
1297
1300
}
1298
1301
1299
1302
Vec<ASR::expr_t *> arg_values;
1300
1303
arg_values.reserve (al, args.size ());
1301
1304
for ( size_t i = 0 ; i < args.size (); i++ ) {
1302
1305
arg_values.push_back (al, ASRUtils::expr_value (args[i]));
1303
1306
}
1304
- ASR::expr_t * compile_time_value = eval_list_reserve (al, loc, arg_values);
1307
+ ASR::expr_t * compile_time_value = eval_reserve (al, loc, arg_values);
1305
1308
return ASR::make_Expr_t (al, loc,
1306
1309
ASRUtils::EXPR (ASRUtils::make_IntrinsicFunction_t_util (al, loc,
1307
- static_cast <int64_t >(ASRUtils::IntrinsicFunctions::ListReserve ),
1310
+ static_cast <int64_t >(ASRUtils::IntrinsicFunctions::Reserve ),
1308
1311
args.p , args.size (), 0 , nullptr , compile_time_value)));
1309
1312
}
1310
1313
1311
- } // namespace ListReserve
1314
+ } // namespace Reserve
1312
1315
1313
1316
namespace DictKeys {
1314
1317
@@ -3172,8 +3175,8 @@ namespace IntrinsicFunctionRegistry {
3172
3175
{nullptr , &DictValues::verify_args}},
3173
3176
{static_cast <int64_t >(ASRUtils::IntrinsicFunctions::ListPop),
3174
3177
{nullptr , &ListPop::verify_args}},
3175
- {static_cast <int64_t >(ASRUtils::IntrinsicFunctions::ListReserve ),
3176
- {nullptr , &ListReserve ::verify_args}},
3178
+ {static_cast <int64_t >(ASRUtils::IntrinsicFunctions::Reserve ),
3179
+ {nullptr , &Reserve ::verify_args}},
3177
3180
{static_cast <int64_t >(ASRUtils::IntrinsicFunctions::SetAdd),
3178
3181
{nullptr , &SetAdd::verify_args}},
3179
3182
{static_cast <int64_t >(ASRUtils::IntrinsicFunctions::SetRemove),
@@ -3256,8 +3259,8 @@ namespace IntrinsicFunctionRegistry {
3256
3259
" list.reverse" },
3257
3260
{static_cast <int64_t >(ASRUtils::IntrinsicFunctions::ListPop),
3258
3261
" list.pop" },
3259
- {static_cast <int64_t >(ASRUtils::IntrinsicFunctions::ListReserve ),
3260
- " list. reserve" },
3262
+ {static_cast <int64_t >(ASRUtils::IntrinsicFunctions::Reserve ),
3263
+ " reserve" },
3261
3264
{static_cast <int64_t >(ASRUtils::IntrinsicFunctions::DictKeys),
3262
3265
" dict.keys" },
3263
3266
{static_cast <int64_t >(ASRUtils::IntrinsicFunctions::DictValues),
@@ -3342,7 +3345,7 @@ namespace IntrinsicFunctionRegistry {
3342
3345
{" list.index" , {&ListIndex::create_ListIndex, &ListIndex::eval_list_index}},
3343
3346
{" list.reverse" , {&ListReverse::create_ListReverse, &ListReverse::eval_list_reverse}},
3344
3347
{" list.pop" , {&ListPop::create_ListPop, &ListPop::eval_list_pop}},
3345
- {" list. reserve" , {&ListReserve::create_ListReserve , &ListReserve::eval_list_reserve }},
3348
+ {" reserve" , {&Reserve::create_Reserve , &Reserve::eval_reserve }},
3346
3349
{" dict.keys" , {&DictKeys::create_DictKeys, &DictKeys::eval_dict_keys}},
3347
3350
{" dict.values" , {&DictValues::create_DictValues, &DictValues::eval_dict_values}},
3348
3351
{" set.add" , {&SetAdd::create_SetAdd, &SetAdd::eval_set_add}},
0 commit comments