@@ -10,6 +10,7 @@ namespace LFortran {
10
10
class FunctionInstantiator : public ASR ::BaseExprStmtDuplicator<FunctionInstantiator>
11
11
{
12
12
public:
13
+ SymbolTable *func_scope;
13
14
SymbolTable *current_scope;
14
15
std::map<std::string, ASR::ttype_t *> subs;
15
16
std::map<std::string, ASR::symbol_t *> rt_subs;
@@ -18,18 +19,17 @@ class FunctionInstantiator : public ASR::BaseExprStmtDuplicator<FunctionInstanti
18
19
std::set<std::string> dependencies;
19
20
20
21
FunctionInstantiator (Allocator &al, std::map<std::string, ASR::ttype_t *> subs,
21
- std::map<std::string, ASR::symbol_t *> rt_subs, SymbolTable *current_scope ,
22
+ std::map<std::string, ASR::symbol_t *> rt_subs, SymbolTable *func_scope ,
22
23
std::string new_func_name):
23
24
BaseExprStmtDuplicator (al),
24
- current_scope{current_scope },
25
+ func_scope{func_scope },
25
26
subs{subs},
26
27
rt_subs{rt_subs},
27
28
new_func_name{new_func_name}
28
29
{}
29
30
30
31
ASR::asr_t * instantiate_Function (ASR::Function_t *x) {
31
32
dependencies.clear ();
32
- SymbolTable *parent_scope = current_scope;
33
33
current_scope = al.make_new <SymbolTable>(x->m_symtab ->parent );
34
34
35
35
Vec<ASR::expr_t *> args;
@@ -135,7 +135,6 @@ class FunctionInstantiator : public ASR::BaseExprStmtDuplicator<FunctionInstanti
135
135
136
136
ASR::symbol_t *t = ASR::down_cast<ASR::symbol_t >(result);
137
137
x->m_symtab ->parent ->add_symbol (new_func_name, t);
138
- current_scope = parent_scope;
139
138
140
139
return result;
141
140
}
@@ -223,7 +222,7 @@ class FunctionInstantiator : public ASR::BaseExprStmtDuplicator<FunctionInstanti
223
222
224
223
ASR::asr_t * duplicate_FunctionCall (ASR::FunctionCall_t *x) {
225
224
std::string sym_name = ASRUtils::symbol_name (x->m_name );
226
- ASR::symbol_t *name = current_scope ->get_symbol (sym_name);
225
+ ASR::symbol_t *name = func_scope ->get_symbol (sym_name);
227
226
Vec<ASR::call_arg_t > args;
228
227
args.reserve (al, x->n_args );
229
228
for (size_t i=0 ; i<x->n_args ; i++) {
0 commit comments