Skip to content

Commit 521596a

Browse files
If the module_name already present in dependency, do no append
1 parent 9d4301f commit 521596a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+52
-47
lines changed

src/libasr/asr_scopes.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,11 @@ void SymbolTable::move_symbols_from_global_scope(Allocator &al,
177177
s = fn->m_symtab->parent->get_symbol(fn->m_dependencies[i]);
178178
}
179179
if (s != nullptr && ASR::is_a<ASR::ExternalSymbol_t>(*s)) {
180-
mod_dependencies.push_back(al, ASR::down_cast<
181-
ASR::ExternalSymbol_t>(s)->m_module_name);
180+
char *es_name = ASR::down_cast<
181+
ASR::ExternalSymbol_t>(s)->m_module_name;
182+
if (!present(mod_dependencies, es_name)) {
183+
mod_dependencies.push_back(al, es_name);
184+
}
182185
}
183186
}
184187
fn->m_symtab->parent = module_scope;
@@ -193,7 +196,9 @@ void SymbolTable::move_symbols_from_global_scope(Allocator &al,
193196
break;
194197
} case (ASR::symbolType::ExternalSymbol) : {
195198
ASR::ExternalSymbol_t *es = ASR::down_cast<ASR::ExternalSymbol_t>(a.second);
196-
mod_dependencies.push_back(al, es->m_module_name);
199+
if (!present(mod_dependencies, es->m_module_name)) {
200+
mod_dependencies.push_back(al, es->m_module_name);
201+
}
197202
es->m_parent_symtab = module_scope;
198203
module_scope->add_symbol(a.first, (ASR::symbol_t *) es);
199204
syms.push_back(al, s2c(al, a.first));

tests/reference/asr-cast-435c233.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-cast-435c233.stdout",
9-
"stdout_hash": "ddd5eed149c1a32b085bb95d90ccb90f9f384b6662062f6c2f45b6cf",
9+
"stdout_hash": "f3ad3f888ac012870fdd04efceff3c153d85a624087832aed3116c23",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(TranslationUnit (SymbolTable 1 {_global_symbols: (Module (SymbolTable 98 {_lpython_main_program: (Function (SymbolTable 97 {}) _lpython_main_program (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [f] [] [(SubroutineCall 98 f () [] ())] () Public .false. .false.), f: (Function (SymbolTable 2 {list: (ExternalSymbol 2 list 4 list lpython_builtin [] list Private), s: (Variable 2 s [] Local () () Default (Character 1 -2 () []) Source Public Required .false.), x: (Variable 2 x [] Local () () Default (List (Character 1 -2 () [])) Source Public Required .false.), y: (Variable 2 y [] Local () () Default (List (Character 1 -2 () [])) Source Public Required .false.)}) f (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [list list list] [] [(= (Var 2 s) (StringConstant "lpython" (Character 1 7 () [])) ()) (= (Var 2 x) (FunctionCall 2 list () [((Var 2 s))] (List (Character 1 -2 () [])) () ()) ()) (= (Var 2 y) (ListConstant [(StringConstant "a" (Character 1 1 () [])) (StringConstant "b" (Character 1 1 () [])) (StringConstant "c" (Character 1 1 () []))] (List (Character 1 1 () []))) ()) (= (Var 2 x) (FunctionCall 2 list () [((Var 2 y))] (List (Character 1 -2 () [])) () ()) ()) (= (Var 2 x) (FunctionCall 2 list () [((StringConstant "lpython" (Character 1 7 () [])))] (List (Character 1 -2 () [])) (ListConstant [(StringConstant "l" (Character 1 1 () [])) (StringConstant "p" (Character 1 1 () [])) (StringConstant "y" (Character 1 1 () [])) (StringConstant "t" (Character 1 1 () [])) (StringConstant "h" (Character 1 1 () [])) (StringConstant "o" (Character 1 1 () [])) (StringConstant "n" (Character 1 1 () []))] (List (Character 1 1 () []))) ()) ())] () Public .false. .false.)}) _global_symbols [lpython_builtin lpython_builtin lpython_builtin] .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 96 {_lpython_main_program: (ExternalSymbol 96 _lpython_main_program 98 _lpython_main_program _global_symbols [] _lpython_main_program Public)}) main_program [] [(SubroutineCall 96 _lpython_main_program () [] ())])}) [])
1+
(TranslationUnit (SymbolTable 1 {_global_symbols: (Module (SymbolTable 98 {_lpython_main_program: (Function (SymbolTable 97 {}) _lpython_main_program (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [f] [] [(SubroutineCall 98 f () [] ())] () Public .false. .false.), f: (Function (SymbolTable 2 {list: (ExternalSymbol 2 list 4 list lpython_builtin [] list Private), s: (Variable 2 s [] Local () () Default (Character 1 -2 () []) Source Public Required .false.), x: (Variable 2 x [] Local () () Default (List (Character 1 -2 () [])) Source Public Required .false.), y: (Variable 2 y [] Local () () Default (List (Character 1 -2 () [])) Source Public Required .false.)}) f (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [list list list] [] [(= (Var 2 s) (StringConstant "lpython" (Character 1 7 () [])) ()) (= (Var 2 x) (FunctionCall 2 list () [((Var 2 s))] (List (Character 1 -2 () [])) () ()) ()) (= (Var 2 y) (ListConstant [(StringConstant "a" (Character 1 1 () [])) (StringConstant "b" (Character 1 1 () [])) (StringConstant "c" (Character 1 1 () []))] (List (Character 1 1 () []))) ()) (= (Var 2 x) (FunctionCall 2 list () [((Var 2 y))] (List (Character 1 -2 () [])) () ()) ()) (= (Var 2 x) (FunctionCall 2 list () [((StringConstant "lpython" (Character 1 7 () [])))] (List (Character 1 -2 () [])) (ListConstant [(StringConstant "l" (Character 1 1 () [])) (StringConstant "p" (Character 1 1 () [])) (StringConstant "y" (Character 1 1 () [])) (StringConstant "t" (Character 1 1 () [])) (StringConstant "h" (Character 1 1 () [])) (StringConstant "o" (Character 1 1 () [])) (StringConstant "n" (Character 1 1 () []))] (List (Character 1 1 () []))) ()) ())] () Public .false. .false.)}) _global_symbols [lpython_builtin] .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 96 {_lpython_main_program: (ExternalSymbol 96 _lpython_main_program 98 _lpython_main_program _global_symbols [] _lpython_main_program Public)}) main_program [] [(SubroutineCall 96 _lpython_main_program () [] ())])}) [])

tests/reference/asr-elemental_01-b58df26.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-elemental_01-b58df26.stdout",
9-
"stdout_hash": "05a07863b57c88effff7af4f26ea6bf4ed09b6b81a639ae7411de3c3",
9+
"stdout_hash": "b8e64bdbae08977452da70d1d63d5b37eb7129db8aba4bc33059b01a",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-elemental_01-b58df26.stdout

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/reference/asr-expr7-480ba2f.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-expr7-480ba2f.stdout",
9-
"stdout_hash": "2c6848c98d21b5aa6dced1b6ffb207e08ce9a6565e270bced7393a13",
9+
"stdout_hash": "8afee5ae82bb1aaeae71ee4b91dedb1f4f4c92bdf06566debb965b06",
1010
"stderr": "asr-expr7-480ba2f.stderr",
1111
"stderr_hash": "6e9790ac88db1a9ead8f64a91ba8a6605de67167037908a74b77be0c",
1212
"returncode": 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(TranslationUnit (SymbolTable 1 {_global_symbols: (Module (SymbolTable 100 {_lpython_main_program: (Function (SymbolTable 99 {}) _lpython_main_program (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [main0] [] [(SubroutineCall 100 main0 () [] ())] () Public .false. .false.), main0: (Function (SymbolTable 4 {c: (Variable 4 c [] Local () () Default (Integer 4 []) Source Public Required .false.)}) main0 (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [test_pow test_pow_1] [] [(SubroutineCall 100 test_pow () [] ()) (= (Var 4 c) (FunctionCall 100 test_pow_1 () [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 [])))] (Integer 4 []) () ()) ())] () Public .false. .false.), test_pow: (Function (SymbolTable 2 {a: (Variable 2 a [] Local () () Default (Integer 4 []) Source Public Required .false.), pow: (ExternalSymbol 2 pow 6 pow lpython_builtin [] pow Private), pow@__lpython_overloaded_0__pow: (ExternalSymbol 2 pow@__lpython_overloaded_0__pow 6 __lpython_overloaded_0__pow lpython_builtin [] __lpython_overloaded_0__pow Public)}) test_pow (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [pow@__lpython_overloaded_0__pow] [] [(= (Var 2 a) (Cast (FunctionCall 2 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 2 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 [])))] (Real 8 []) (RealConstant 4.000000 (Real 8 [])) ()) RealToInteger (Integer 4 []) (IntegerConstant 4 (Integer 4 []))) ())] () Public .false. .false.), test_pow_1: (Function (SymbolTable 3 {_lpython_return_variable: (Variable 3 _lpython_return_variable [] ReturnVar () () Default (Integer 4 []) Source Public Required .false.), a: (Variable 3 a [] In () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 3 b [] In () () Default (Integer 4 []) Source Public Required .false.), pow: (ExternalSymbol 3 pow 6 pow lpython_builtin [] pow Private), pow@__lpython_overloaded_0__pow: (ExternalSymbol 3 pow@__lpython_overloaded_0__pow 6 __lpython_overloaded_0__pow lpython_builtin [] __lpython_overloaded_0__pow Public), res: (Variable 3 res [] Local () () Default (Integer 4 []) Source Public Required .false.)}) test_pow_1 (FunctionType [(Integer 4 []) (Integer 4 [])] (Integer 4 []) Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [pow@__lpython_overloaded_0__pow] [(Var 3 a) (Var 3 b)] [(= (Var 3 res) (Cast (FunctionCall 3 pow@__lpython_overloaded_0__pow 3 pow [((Var 3 a)) ((Var 3 b))] (Real 8 []) () ()) RealToInteger (Integer 4 []) ()) ()) (= (Var 3 _lpython_return_variable) (Var 3 res) ()) (Return)] (Var 3 _lpython_return_variable) Public .false. .false.)}) _global_symbols [lpython_builtin lpython_builtin] .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 98 {_lpython_main_program: (ExternalSymbol 98 _lpython_main_program 100 _lpython_main_program _global_symbols [] _lpython_main_program Public)}) main_program [] [(SubroutineCall 98 _lpython_main_program () [] ())])}) [])
1+
(TranslationUnit (SymbolTable 1 {_global_symbols: (Module (SymbolTable 100 {_lpython_main_program: (Function (SymbolTable 99 {}) _lpython_main_program (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [main0] [] [(SubroutineCall 100 main0 () [] ())] () Public .false. .false.), main0: (Function (SymbolTable 4 {c: (Variable 4 c [] Local () () Default (Integer 4 []) Source Public Required .false.)}) main0 (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [test_pow test_pow_1] [] [(SubroutineCall 100 test_pow () [] ()) (= (Var 4 c) (FunctionCall 100 test_pow_1 () [((IntegerConstant 1 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 [])))] (Integer 4 []) () ()) ())] () Public .false. .false.), test_pow: (Function (SymbolTable 2 {a: (Variable 2 a [] Local () () Default (Integer 4 []) Source Public Required .false.), pow: (ExternalSymbol 2 pow 6 pow lpython_builtin [] pow Private), pow@__lpython_overloaded_0__pow: (ExternalSymbol 2 pow@__lpython_overloaded_0__pow 6 __lpython_overloaded_0__pow lpython_builtin [] __lpython_overloaded_0__pow Public)}) test_pow (FunctionType [] () Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [pow@__lpython_overloaded_0__pow] [] [(= (Var 2 a) (Cast (FunctionCall 2 pow@__lpython_overloaded_0__pow 2 pow [((IntegerConstant 2 (Integer 4 []))) ((IntegerConstant 2 (Integer 4 [])))] (Real 8 []) (RealConstant 4.000000 (Real 8 [])) ()) RealToInteger (Integer 4 []) (IntegerConstant 4 (Integer 4 []))) ())] () Public .false. .false.), test_pow_1: (Function (SymbolTable 3 {_lpython_return_variable: (Variable 3 _lpython_return_variable [] ReturnVar () () Default (Integer 4 []) Source Public Required .false.), a: (Variable 3 a [] In () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 3 b [] In () () Default (Integer 4 []) Source Public Required .false.), pow: (ExternalSymbol 3 pow 6 pow lpython_builtin [] pow Private), pow@__lpython_overloaded_0__pow: (ExternalSymbol 3 pow@__lpython_overloaded_0__pow 6 __lpython_overloaded_0__pow lpython_builtin [] __lpython_overloaded_0__pow Public), res: (Variable 3 res [] Local () () Default (Integer 4 []) Source Public Required .false.)}) test_pow_1 (FunctionType [(Integer 4 []) (Integer 4 [])] (Integer 4 []) Source Implementation () .false. .false. .false. .false. .false. [] [] .false.) [pow@__lpython_overloaded_0__pow] [(Var 3 a) (Var 3 b)] [(= (Var 3 res) (Cast (FunctionCall 3 pow@__lpython_overloaded_0__pow 3 pow [((Var 3 a)) ((Var 3 b))] (Real 8 []) () ()) RealToInteger (Integer 4 []) ()) ()) (= (Var 3 _lpython_return_variable) (Var 3 res) ()) (Return)] (Var 3 _lpython_return_variable) Public .false. .false.)}) _global_symbols [lpython_builtin] .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 98 {_lpython_main_program: (ExternalSymbol 98 _lpython_main_program 100 _lpython_main_program _global_symbols [] _lpython_main_program Public)}) main_program [] [(SubroutineCall 98 _lpython_main_program () [] ())])}) [])

tests/reference/asr-expr_05-3a37324.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-expr_05-3a37324.stdout",
9-
"stdout_hash": "e5d6fd42eebd3daf2b69e6c432ff3e806f6a13b2a413b6902787ec25",
9+
"stdout_hash": "a7b9a4ebaa098f3973cc2b425a1c596d03ab3e627463aa218fe87f3d",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

0 commit comments

Comments
 (0)