-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Underscore: _
variable in REPL
#2755
Conversation
src/libasr/codegen/asr_to_llvm.cpp
Outdated
@@ -2709,11 +2712,20 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor> | |||
} | |||
|
|||
void visit_Variable(const ASR::Variable_t &x) { | |||
if ((compiler_options.interactive) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ((compiler_options.interactive) && | |
if (compiler_options.interactive && |
Similarly others.
src/libasr/codegen/asr_to_llvm.cpp
Outdated
@@ -2709,11 +2712,20 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor> | |||
} | |||
|
|||
void visit_Variable(const ASR::Variable_t &x) { | |||
if ((compiler_options.interactive) && | |||
(std::strcmp(x.m_name, "_") == 0) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it so that at some place we compare with (std::strcmp(x.m_name, "_") == 0)
and at some we use (std::strcmp(x.m_name, compiler_options.po.global_underscore.c_str()) == 0)
? What is the significance of compiler_options.po.global_underscore
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous code block's last expression's value is stored in compiler_options.po.global_underscore
, which is ___main__global_stmts_<int>__
.
While generating IR for compiler_options.po.global_underscore
, we store its hash in global_underscore_hash
, then whenever we need a reference to _
variable, we use global_underscore_hash
. So _
gets replaced with ___main__global_stmts_<int>__
.
Looks good overall. Lets merge #2752 and rebase and resolve conflicts in this PR. After that I will have a look again. |
c015890
to
a4a2bc8
Compare
mostly I messed up the rebasing partially
Demo:
This PR is built on top of #2752. Therefore #2752 should be merged first.