Skip to content

Commit b61eccf

Browse files
update according to code review suggestion
1 parent 6c40139 commit b61eccf

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/bin/lpython.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -810,19 +810,20 @@ int interactive_python_repl(
810810
LCompilers::LocationManager lm;
811811
std::vector<std::pair<std::string, double>> times;
812812
LCompilers::PythonCompiler::EvalResult r;
813-
813+
814814
std::string code_string;
815815
std::cout << ">>> ";
816816
size_t cell_count = 0;
817817
for (std::string input; std::getline(std::cin, input);) {
818-
if (input == "exit" || input == "quit") // exit condition
818+
if (input == "exit" || input == "quit") {
819819
return 0;
820+
}
820821

821-
if ((input.rfind("def", 0) == 0) ||
822-
(input.rfind("for", 0) == 0) ||
823-
(input.rfind("if", 0) == 0) ||
824-
(input.rfind("else", 0) == 0) ||
825-
(input.rfind("elif", 0) == 0) ||
822+
if ((input.rfind("def", 0) == 0) ||
823+
(input.rfind("for", 0) == 0) ||
824+
(input.rfind("if", 0) == 0) ||
825+
(input.rfind("else", 0) == 0) ||
826+
(input.rfind("elif", 0) == 0) ||
826827
(input.rfind("class", 0) == 0) ||
827828
(input.rfind('@', 0) == 0) ||
828829
(input.rfind(' ', 0) == 0) ||
@@ -859,11 +860,11 @@ int interactive_python_repl(
859860
std::cout << ">>> ";
860861
continue;
861862
}
862-
863+
863864
auto evaluation_end_time = std::chrono::high_resolution_clock::now();
864865
times.push_back(std::make_pair("evalution " + std::to_string(cell_count), std::chrono::duration
865866
<double, std::milli>(evaluation_start_time - evaluation_end_time).count()));
866-
867+
867868
} catch (const LCompilers::LCompilersException &e) {
868869
std::cerr << "Internal Compiler Error: Unhandled exception" << std::endl;
869870
std::vector<LCompilers::StacktraceItem> d = e.stacktrace_addresses();
@@ -1934,8 +1935,6 @@ int main(int argc, char *argv[])
19341935
compiler_options.use_colors = !arg_no_color;
19351936
compiler_options.indent = !arg_no_indent;
19361937

1937-
lpython_pass_manager.parse_pass_arg(arg_pass, skip_pass);
1938-
lpython_pass_manager.use_default_passes();
19391938

19401939
// if (fmt) {
19411940
// return format(arg_fmt_file, arg_fmt_inplace, !arg_fmt_no_color,
@@ -1983,6 +1982,8 @@ int main(int argc, char *argv[])
19831982
}
19841983

19851984
if (arg_files.size() == 0) {
1985+
lpython_pass_manager.parse_pass_arg(arg_pass, skip_pass);
1986+
lpython_pass_manager.use_default_passes();
19861987
compiler_options.po.disable_main = true;
19871988
compiler_options.emit_debug_line_column = false;
19881989
compiler_options.generate_object_code = false;
@@ -2029,6 +2030,7 @@ int main(int argc, char *argv[])
20292030
// return emit_c_preprocessor(arg_file, compiler_options);
20302031
// }
20312032

2033+
lpython_pass_manager.parse_pass_arg(arg_pass, skip_pass);
20322034
if (show_tokens) {
20332035
return emit_tokens(arg_file, true, compiler_options);
20342036
}
@@ -2070,6 +2072,7 @@ int main(int argc, char *argv[])
20702072
return 1;
20712073
#endif
20722074
}
2075+
lpython_pass_manager.use_default_passes();
20732076
if (show_llvm) {
20742077
#ifdef HAVE_LFORTRAN_LLVM
20752078
return emit_llvm(arg_file, runtime_library_dir, lpython_pass_manager, compiler_options);

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8545,9 +8545,6 @@ Result<ASR::TranslationUnit_t*> python_ast_to_asr(Allocator &al, LocationManager
85458545
}
85468546
} else {
85478547
ast_i = AST::down_cast2<AST::Interactive_t>(&ast);
8548-
if (!symtab) {
8549-
// Create new empty symbol table, as a module
8550-
}
85518548
Result<ASR::asr_t*> res = symbol_table_visitor(al, lm, symtab, *ast_i, diagnostics, main_module, module_name,
85528549
ast_overload, parent_dir, compiler_options.import_paths, allow_implicit_casting);
85538550
if (res.ok) {

0 commit comments

Comments
 (0)