-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Support --no-loc to skip location info in Json #2709
Support --no-loc to skip location info in Json #2709
Conversation
We have the flag --dump-all-passes, but it only prints the asr in text format. I often use fortran, the json and the visualisation format to debug codes. This PR supports applying all passes to fortran, json, viz and tree formats. |
src/bin/lfortran.cpp
Outdated
@@ -2058,6 +2063,7 @@ int main(int argc, char *argv[]) | |||
app.add_flag("--legacy-array-sections", compiler_options.legacy_array_sections, "Enables passing array items as sections if required"); | |||
app.add_flag("--ignore-pragma", compiler_options.ignore_pragma, "Ignores all the pragmas"); | |||
app.add_flag("--stack-arrays", compiler_options.stack_arrays, "Allocate memory for arrays on stack"); | |||
app.add_flag("--all-passes", compiler_options.all_passes, "Apply all ASR passes to --show-asr and --show-fortran"); |
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 not adding an option like --dump-fortran
(or something like that) to dump Fortran together with Clojure in --dump-all-passes
.
The same with JSON and --visualize
.
How about this:
These (and more!) are various options that control how ASR is printed. Then we have options that control which exact ASR gets printed: By default the above prints ASR before any passes are applied. Then Let's start with the above. If we need to, we can later add We also have options to control which passes to run, which would affect |
@Shaikh-Ubaid I thought of working on |
I will take care of these Thirumalai. There are tons of other tasks waiting to be fixed. Please focus on them. |
a11c1a8
to
ba03b81
Compare
I updated the PR description. This is ready. Please let me know if a reference test is to be added. I feel it is not needed. (Or can be added later if needed). |
src/libasr/pickle.h
Outdated
std::string pickle_json(ASR::asr_t &asr, LocationManager &lm, bool show_intrinsic_modules=false); | ||
std::string pickle_json(ASR::TranslationUnit_t &asr, LocationManager &lm, bool show_intrinsic_modules=false); | ||
std::string pickle_json(ASR::asr_t &asr, LocationManager &lm, bool no_loc=false, bool show_intrinsic_modules=false); | ||
std::string pickle_json(ASR::TranslationUnit_t &asr, LocationManager &lm, bool no_loc=false, bool show_intrinsic_modules=false); |
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.
Let's not use default arguments, it leads to issues with overloads and clarity of what the values actually are. For example, if there is any code in LFortran that just called pickle_json(asr, lm, true)
, then after this PR this very same code now will evaluate to no_loc=true
and show_intrinsic_modules=false
, which is not what was intended.
To fix this, do it like this:
std::string pickle_json(ASR::TranslationUnit_t &asr, LocationManager &lm, bool no_loc=false, bool show_intrinsic_modules=false); | |
std::string pickle_json(ASR::TranslationUnit_t &asr, LocationManager &lm, bool no_loc, bool show_intrinsic_modules); |
And then modify all call sites to supply all arguments explicitly.
src/lfortran/pickle.h
Outdated
std::string pickle_json(AST::ast_t &ast, LocationManager &lm); | ||
std::string pickle_json(AST::TranslationUnit_t &ast, LocationManager &lm); | ||
std::string pickle_json(AST::ast_t &ast, LocationManager &lm, bool no_loc=false); | ||
std::string pickle_json(AST::TranslationUnit_t &ast, LocationManager &lm, bool no_loc=false); |
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.
same here, no default arguments.
Otherwise it looks good. |
ba03b81
to
a9d8cbc
Compare
a9d8cbc
to
698cdfa
Compare
This PR supports a
--no-loc
flag which enables the user to skip the location information in the generated AST/R Json format.