Skip to content

Commit 79bf06c

Browse files
committed
Remove duplicate flags from CompilerOptions
1 parent c297cdc commit 79bf06c

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

src/bin/lpython.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,12 @@ int emit_asr(const std::string &infile,
220220

221221
pass_manager.apply_passes(al, asr, compiler_options.po, diagnostics);
222222

223-
if (compiler_options.tree) {
223+
if (compiler_options.po.tree) {
224224
std::cout << LCompilers::LPython::pickle_tree(*asr,
225225
compiler_options.use_colors, with_intrinsic_modules) << std::endl;
226-
} else if (compiler_options.json) {
226+
} else if (compiler_options.po.json) {
227227
std::cout << LCompilers::LPython::pickle_json(*asr, lm, with_intrinsic_modules) << std::endl;
228-
} else if (compiler_options.visualize) {
228+
} else if (compiler_options.po.visualize) {
229229
std::string astr_data_json = LCompilers::LPython::pickle_json(*asr, lm, with_intrinsic_modules);
230230
return visualize_json(astr_data_json, compiler_options.platform);
231231
} else {
@@ -790,7 +790,7 @@ int compile_python_to_object_file(
790790
auto ast_to_asr_start = std::chrono::high_resolution_clock::now();
791791
LCompilers::Result<LCompilers::ASR::TranslationUnit_t*>
792792
r1 = LCompilers::LPython::python_ast_to_asr(al, lm, nullptr, *ast, diagnostics, compiler_options,
793-
!(arg_c && compiler_options.disable_main), "__main__", infile);
793+
!(arg_c && compiler_options.po.disable_main), "__main__", infile);
794794

795795
auto ast_to_asr_end = std::chrono::high_resolution_clock::now();
796796
times.push_back(std::make_pair("AST to ASR", std::chrono::duration<double, std::milli>(ast_to_asr_end - ast_to_asr_start).count()));
@@ -801,7 +801,7 @@ int compile_python_to_object_file(
801801
return 2;
802802
}
803803
LCompilers::ASR::TranslationUnit_t* asr = r1.result;
804-
if( compiler_options.disable_main ) {
804+
if( compiler_options.po.disable_main ) {
805805
int err = LCompilers::LPython::save_pyc_files(*asr, infile);
806806
if( err ) {
807807
return err;
@@ -909,7 +909,7 @@ int compile_to_binary_wasm(
909909
return 2;
910910
}
911911
LCompilers::ASR::TranslationUnit_t* asr = r1.result;
912-
if( compiler_options.disable_main ) {
912+
if( compiler_options.po.disable_main ) {
913913
int err = LCompilers::LPython::save_pyc_files(*asr, infile);
914914
if( err ) {
915915
return err;
@@ -982,7 +982,7 @@ int compile_to_binary_x86(
982982
return 2;
983983
}
984984
LCompilers::ASR::TranslationUnit_t* asr = r1.result;
985-
if( compiler_options.disable_main ) {
985+
if( compiler_options.po.disable_main ) {
986986
int err = LCompilers::LPython::save_pyc_files(*asr, infile);
987987
if( err ) {
988988
return err;
@@ -1056,7 +1056,7 @@ int compile_to_binary_wasm_to_x86(
10561056
return 2;
10571057
}
10581058
LCompilers::ASR::TranslationUnit_t* asr = r1.result;
1059-
if( compiler_options.disable_main ) {
1059+
if( compiler_options.po.disable_main ) {
10601060
int err = LCompilers::LPython::save_pyc_files(*asr, infile);
10611061
if( err ) {
10621062
return err;
@@ -1568,12 +1568,12 @@ int main(int argc, char *argv[])
15681568
app.add_flag("--with-intrinsic-mods", with_intrinsic_modules, "Show intrinsic modules in ASR");
15691569
app.add_flag("--no-color", arg_no_color, "Turn off colored AST/ASR");
15701570
app.add_flag("--no-indent", arg_no_indent, "Turn off Indented print ASR/AST");
1571-
app.add_flag("--tree", compiler_options.tree, "Tree structure print ASR/AST");
1572-
app.add_flag("--json", compiler_options.json, "Print ASR/AST Json format");
1573-
app.add_flag("--visualize", compiler_options.visualize, "Print ASR/AST Visualization");
1571+
app.add_flag("--tree", compiler_options.po.tree, "Tree structure print ASR/AST");
1572+
app.add_flag("--json", compiler_options.po.json, "Print ASR/AST Json format");
1573+
app.add_flag("--visualize", compiler_options.po.visualize, "Print ASR/AST Visualization");
15741574
app.add_option("--pass", arg_pass, "Apply the ASR pass and show ASR (implies --show-asr)");
15751575
app.add_option("--skip-pass", skip_pass, "Skip an ASR pass in default pipeline");
1576-
app.add_flag("--disable-main", compiler_options.disable_main, "Do not generate any code for the `main` function");
1576+
app.add_flag("--disable-main", compiler_options.po.disable_main, "Do not generate any code for the `main` function");
15771577
app.add_flag("--symtab-only", compiler_options.symtab_only, "Only create symbol tables in ASR (skip executable stmt)");
15781578
app.add_flag("--time-report", time_report, "Show compilation time report");
15791579
app.add_flag("--static", static_link, "Create a static executable");
@@ -1582,7 +1582,7 @@ int main(int argc, char *argv[])
15821582
app.add_option("--backend", arg_backend, "Select a backend (llvm, cpp, x86, wasm, wasm_x86, wasm_x64)")->capture_default_str();
15831583
app.add_flag("--enable-bounds-checking", compiler_options.enable_bounds_checking, "Turn on index bounds checking");
15841584
app.add_flag("--openmp", compiler_options.openmp, "Enable openmp");
1585-
app.add_flag("--fast", compiler_options.fast, "Best performance (disable strict standard compliance)");
1585+
app.add_flag("--fast", compiler_options.po.fast, "Best performance (disable strict standard compliance)");
15861586
app.add_option("--target", compiler_options.target, "Generate code for the given target")->capture_default_str();
15871587
app.add_flag("--print-targets", print_targets, "Print the registered targets");
15881588
app.add_flag("--get-rtl-header-dir", print_rtl_header_dir, "Print the path to the runtime library header file");
@@ -1639,9 +1639,9 @@ int main(int argc, char *argv[])
16391639
lcompilers_unique_ID = separate_compilation ? LCompilers::get_unique_ID(): "";
16401640

16411641

1642-
if( compiler_options.fast && compiler_options.enable_bounds_checking ) {
1642+
if( compiler_options.po.fast && compiler_options.enable_bounds_checking ) {
16431643
// ReleaseSafe Mode
1644-
} else if ( compiler_options.fast ) {
1644+
} else if ( compiler_options.po.fast ) {
16451645
// Release Mode
16461646
lpython_pass_manager.use_optimization_passes();
16471647
} else {
@@ -1768,7 +1768,7 @@ int main(int argc, char *argv[])
17681768
}
17691769

17701770
if (compiler_options.po.dump_fortran || compiler_options.po.dump_all_passes) {
1771-
dump_all_passes(arg_file, compiler_options);
1771+
dump_all_passes(arg_file, runtime_library_dir, compiler_options);
17721772
}
17731773

17741774
// if (arg_E) {

src/libasr/utils.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,10 @@ struct CompilerOptions {
6868
bool c_preprocessor = false;
6969
std::vector<std::string> c_preprocessor_defines;
7070
bool prescan = true;
71-
bool disable_main = false;
7271
bool symtab_only = false;
7372
bool show_stacktrace = false;
7473
bool use_colors = true;
7574
bool indent = true;
76-
bool json = false;
77-
bool tree = false;
78-
bool visualize = false;
79-
bool fast = false;
8075
bool openmp = false;
8176
bool generate_object_code = false;
8277
bool no_warnings = false;

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ ASR::TranslationUnit_t* compile_module_till_asr(
139139

140140
// Convert the module from AST to ASR
141141
CompilerOptions compiler_options;
142-
compiler_options.disable_main = true;
142+
compiler_options.po.disable_main = true;
143143
compiler_options.symtab_only = false;
144144
Result<ASR::TranslationUnit_t*> r2 = python_ast_to_asr(al, lm, symtab, *ast,
145145
diagnostics, compiler_options, false, module_name, infile, allow_implicit_casting);
@@ -7996,7 +7996,7 @@ Result<ASR::TranslationUnit_t*> python_ast_to_asr(Allocator &al, LocationManager
79967996
#endif
79977997
}
79987998

7999-
if (main_module && !compiler_options.disable_main) {
7999+
if (main_module && !compiler_options.po.disable_main) {
80008000
// If it is a main module, turn it into a program
80018001
// Note: we can modify this behavior for interactive mode later
80028002

0 commit comments

Comments
 (0)