Skip to content

Commit

Permalink
Merge pull request lcompilers#2701 from Vipul-Cariappa/name-mangling
Browse files Browse the repository at this point in the history
avoiding name mangling while interactive is true
  • Loading branch information
Shaikh-Ubaid committed May 14, 2024
2 parents 476d9bb + 4ef7738 commit 8773842
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3791,7 +3791,9 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
}
}
std::string fn_name;
if (ASRUtils::get_FunctionType(x)->m_abi == ASR::abiType::BindC) {
if (compiler_options.interactive && startswith(sym_name, "__main__global_stmts")) {
fn_name = sym_name;
} else if (ASRUtils::get_FunctionType(x)->m_abi == ASR::abiType::BindC) {
if (ASRUtils::get_FunctionType(x)->m_bindc_name) {
fn_name = ASRUtils::get_FunctionType(x)->m_bindc_name;
} else {
Expand Down
6 changes: 2 additions & 4 deletions src/lpython/python_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ Result<PythonCompiler::EvalResult> PythonCompiler::evaluate(
}

// ASR -> LLVM
std::string module_prefix = "__module___main___";
std::string module_name = "__main__";
std::string sym_name = module_name + "global_stmts_" + std::to_string(eval_count) + "__";
run_fn = module_prefix + sym_name;
run_fn = module_name + "global_stmts_" + std::to_string(eval_count) + "__";

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

if (call_run_fn) {
ASR::down_cast<ASR::Module_t>(symbol_table->resolve_symbol(module_name))->m_symtab
->erase_symbol(sym_name);
->erase_symbol(run_fn);
}

eval_count++;
Expand Down

0 comments on commit 8773842

Please sign in to comment.