Skip to content

Commit aea2a6f

Browse files
committed
Remove unused passes global_stmts_program, global_symbols
Remove unused function move_symbols_from_global_scope() The global_symbols pass that uses it was removed. This function is unused now.
1 parent 6b270c0 commit aea2a6f

File tree

9 files changed

+0
-251
lines changed

9 files changed

+0
-251
lines changed

src/libasr/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ set(SRC
3333
pass/do_loops.cpp
3434
pass/for_all.cpp
3535
pass/global_stmts.cpp
36-
pass/global_stmts_program.cpp
37-
pass/global_symbols.cpp
3836
pass/select_case.cpp
3937
pass/init_expr.cpp
4038
pass/implied_do_loops.cpp

src/libasr/asr_scopes.cpp

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -96,102 +96,4 @@ std::string SymbolTable::get_unique_name(const std::string &name, bool use_uniqu
9696
return unique_name;
9797
}
9898

99-
void SymbolTable::move_symbols_from_global_scope(Allocator &al,
100-
SymbolTable *module_scope, Vec<char *> &syms,
101-
SetChar &mod_dependencies) {
102-
// TODO: This isn't scalable. We have write a visitor in asdl_cpp.py
103-
syms.reserve(al, 4);
104-
mod_dependencies.reserve(al, 4);
105-
for (auto &a : scope) {
106-
switch (a.second->type) {
107-
case (ASR::symbolType::Module): {
108-
// Pass
109-
break;
110-
} case (ASR::symbolType::Function) : {
111-
ASR::Function_t *fn = ASR::down_cast<ASR::Function_t>(a.second);
112-
for (size_t i = 0; i < fn->n_dependencies; i++ ) {
113-
ASR::symbol_t *s = fn->m_symtab->get_symbol(
114-
fn->m_dependencies[i]);
115-
if (s == nullptr) {
116-
std::string block_name = "block";
117-
ASR::symbol_t *block_s = fn->m_symtab->get_symbol(block_name);
118-
int32_t j = 1;
119-
while(block_s != nullptr) {
120-
while(block_s != nullptr) {
121-
ASR::Block_t *b = ASR::down_cast<ASR::Block_t>(block_s);
122-
s = b->m_symtab->get_symbol(fn->m_dependencies[i]);
123-
if (s == nullptr) {
124-
block_s = b->m_symtab->get_symbol("block");
125-
} else {
126-
break;
127-
}
128-
}
129-
if (s == nullptr) {
130-
block_s = fn->m_symtab->get_symbol(block_name +
131-
std::to_string(j));
132-
j++;
133-
} else {
134-
break;
135-
}
136-
}
137-
}
138-
if (s == nullptr) {
139-
s = fn->m_symtab->parent->get_symbol(fn->m_dependencies[i]);
140-
}
141-
if (s != nullptr && ASR::is_a<ASR::ExternalSymbol_t>(*s)) {
142-
char *es_name = ASR::down_cast<
143-
ASR::ExternalSymbol_t>(s)->m_module_name;
144-
mod_dependencies.push_back(al, es_name);
145-
}
146-
}
147-
fn->m_symtab->parent = module_scope;
148-
module_scope->add_symbol(a.first, (ASR::symbol_t *) fn);
149-
syms.push_back(al, s2c(al, a.first));
150-
break;
151-
} case (ASR::symbolType::GenericProcedure) : {
152-
ASR::GenericProcedure_t *es = ASR::down_cast<ASR::GenericProcedure_t>(a.second);
153-
es->m_parent_symtab = module_scope;
154-
module_scope->add_symbol(a.first, (ASR::symbol_t *) es);
155-
syms.push_back(al, s2c(al, a.first));
156-
break;
157-
} case (ASR::symbolType::ExternalSymbol) : {
158-
ASR::ExternalSymbol_t *es = ASR::down_cast<ASR::ExternalSymbol_t>(a.second);
159-
mod_dependencies.push_back(al, es->m_module_name);
160-
es->m_parent_symtab = module_scope;
161-
LCOMPILERS_ASSERT(ASRUtils::symbol_get_past_external(a.second));
162-
module_scope->add_symbol(a.first, (ASR::symbol_t *) es);
163-
syms.push_back(al, s2c(al, a.first));
164-
break;
165-
} case (ASR::symbolType::StructType) : {
166-
ASR::StructType_t *st = ASR::down_cast<ASR::StructType_t>(a.second);
167-
st->m_symtab->parent = module_scope;
168-
module_scope->add_symbol(a.first, (ASR::symbol_t *) st);
169-
syms.push_back(al, s2c(al, a.first));
170-
break;
171-
} case (ASR::symbolType::EnumType) : {
172-
ASR::EnumType_t *et = ASR::down_cast<ASR::EnumType_t>(a.second);
173-
et->m_symtab->parent = module_scope;
174-
module_scope->add_symbol(a.first, (ASR::symbol_t *) et);
175-
syms.push_back(al, s2c(al, a.first));
176-
break;
177-
} case (ASR::symbolType::UnionType) : {
178-
ASR::UnionType_t *ut = ASR::down_cast<ASR::UnionType_t>(a.second);
179-
ut->m_symtab->parent = module_scope;
180-
module_scope->add_symbol(a.first, (ASR::symbol_t *) ut);
181-
syms.push_back(al, s2c(al, a.first));
182-
break;
183-
} case (ASR::symbolType::Variable) : {
184-
ASR::Variable_t *v = ASR::down_cast<ASR::Variable_t>(a.second);
185-
v->m_parent_symtab = module_scope;
186-
module_scope->add_symbol(a.first, (ASR::symbol_t *) v);
187-
syms.push_back(al, s2c(al, a.first));
188-
break;
189-
} default : {
190-
throw LCompilersException("Moving the symbol:`" + a.first +
191-
"` from global scope is not implemented yet");
192-
}
193-
}
194-
}
195-
}
196-
19799
} // namespace LCompilers

src/libasr/asr_scopes.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ struct SymbolTable {
9696
size_t n_scope_names, char **m_scope_names);
9797

9898
std::string get_unique_name(const std::string &name, bool use_unique_id=true);
99-
100-
void move_symbols_from_global_scope(Allocator &al,
101-
SymbolTable *module_scope, Vec<char *> &syms,
102-
SetChar &mod_dependencies);
10399
};
104100

105101
} // namespace LCompilers

src/libasr/gen_pass.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"replace_fma",
1010
"replace_for_all",
1111
"wrap_global_stmts",
12-
"wrap_global_stmts_program",
13-
"wrap_global_symbols",
1412
"replace_implied_do_loops",
1513
"replace_init_expr",
1614
"inline_function_calls",

src/libasr/pass/global_stmts_program.cpp

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/libasr/pass/global_symbols.cpp

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/libasr/pass/wrap_global_stmts_program.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/libasr/pass/wrap_global_symbols.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <libasr/config.h>
1818
#include <libasr/string_utils.h>
1919
#include <libasr/utils.h>
20-
#include <libasr/pass/wrap_global_stmts_program.h>
2120
#include <libasr/pass/instantiate_template.h>
2221
#include <libasr/pass/wrap_global_stmts.h>
2322
#include <libasr/pass/intrinsic_function_registry.h>

0 commit comments

Comments
 (0)