Skip to content

Commit 8773842

Browse files
authored
Merge pull request #2701 from Vipul-Cariappa/name-mangling
avoiding name mangling while interactive is true
2 parents 476d9bb + 4ef7738 commit 8773842

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3791,7 +3791,9 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
37913791
}
37923792
}
37933793
std::string fn_name;
3794-
if (ASRUtils::get_FunctionType(x)->m_abi == ASR::abiType::BindC) {
3794+
if (compiler_options.interactive && startswith(sym_name, "__main__global_stmts")) {
3795+
fn_name = sym_name;
3796+
} else if (ASRUtils::get_FunctionType(x)->m_abi == ASR::abiType::BindC) {
37953797
if (ASRUtils::get_FunctionType(x)->m_bindc_name) {
37963798
fn_name = ASRUtils::get_FunctionType(x)->m_bindc_name;
37973799
} else {

src/lpython/python_evaluator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ Result<PythonCompiler::EvalResult> PythonCompiler::evaluate(
8585
}
8686

8787
// ASR -> LLVM
88-
std::string module_prefix = "__module___main___";
8988
std::string module_name = "__main__";
90-
std::string sym_name = module_name + "global_stmts_" + std::to_string(eval_count) + "__";
91-
run_fn = module_prefix + sym_name;
89+
run_fn = module_name + "global_stmts_" + std::to_string(eval_count) + "__";
9290

9391
Result<std::unique_ptr<LLVMModule>> res3 = get_llvm3(*asr,
9492
pass_manager, diagnostics, lm.files.back().in_filename);
@@ -116,7 +114,7 @@ Result<PythonCompiler::EvalResult> PythonCompiler::evaluate(
116114

117115
if (call_run_fn) {
118116
ASR::down_cast<ASR::Module_t>(symbol_table->resolve_symbol(module_name))->m_symtab
119-
->erase_symbol(sym_name);
117+
->erase_symbol(run_fn);
120118
}
121119

122120
eval_count++;

0 commit comments

Comments
 (0)