@@ -2196,6 +2196,8 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
2196
2196
llvm_symtab[h] = ptr;
2197
2197
} else if (x.m_type ->type == ASR::ttypeType::TypeParameter) {
2198
2198
// Ignore type variables
2199
+ } else if (x.m_type ->type == ASR::ttypeType::List) {
2200
+ // Handled in ``_lpython_main_program``function_scope
2199
2201
} else {
2200
2202
throw CodeGenError (" Variable type not supported" , x.base .base .loc );
2201
2203
}
@@ -5309,7 +5311,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
5309
5311
}
5310
5312
}
5311
5313
5312
- inline void fetch_var (ASR::Variable_t* x) {
5314
+ inline void fetch_var (ASR::Variable_t* x, bool is_external= false ) {
5313
5315
if (x->m_value ) {
5314
5316
this ->visit_expr_wrapper (x->m_value , true );
5315
5317
return ;
@@ -5369,6 +5371,28 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
5369
5371
}
5370
5372
break ;
5371
5373
}
5374
+ case ASR::ttypeType::List: {
5375
+ if (is_external) {
5376
+ uint32_t h = get_hash ((ASR::asr_t *)x);
5377
+ llvm::Type *type;
5378
+ int n_dims = 0 , a_kind = 4 ;
5379
+ ASR::dimension_t * m_dims = nullptr ;
5380
+ bool is_array_type = false , is_malloc_array_type = false ;
5381
+ bool is_list = false ;
5382
+ type = get_type_from_ttype_t (x->m_type , x->m_storage , is_array_type,
5383
+ is_malloc_array_type, is_list, m_dims, n_dims,
5384
+ a_kind);
5385
+ llvm::AllocaInst *ptr = builder->CreateAlloca (type, nullptr , x->m_name );
5386
+ llvm_symtab[h] = ptr;
5387
+ if ( llvm_symtab.find (h) != llvm_symtab.end () ) {
5388
+ tmp = llvm_symtab[h];
5389
+ }
5390
+ ASR::List_t* asr_list = ASR::down_cast<ASR::List_t>(x->m_type );
5391
+ std::string type_code = ASRUtils::get_type_code (asr_list->m_type );
5392
+ list_api->list_init (type_code, tmp, *module);
5393
+ break ;
5394
+ }
5395
+ }
5372
5396
default : {
5373
5397
fetch_val (x);
5374
5398
break ;
@@ -5377,9 +5401,13 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
5377
5401
}
5378
5402
5379
5403
void visit_Var (const ASR::Var_t &x) {
5404
+ bool is_external = false ;
5405
+ if (ASR::is_a<ASR::ExternalSymbol_t>(*x.m_v )) {
5406
+ is_external = true ;
5407
+ }
5380
5408
ASR::Variable_t *v = ASR::down_cast<ASR::Variable_t>(
5381
5409
symbol_get_past_external (x.m_v ));
5382
- fetch_var (v);
5410
+ fetch_var (v, is_external );
5383
5411
}
5384
5412
5385
5413
inline ASR::ttype_t * extract_ttype_t_from_expr (ASR::expr_t * expr) {
0 commit comments