@@ -90,7 +90,7 @@ int emit_tokens(const std::string &infile, bool line_numbers, const CompilerOpti
90
90
LFortran::diag::Diagnostics diagnostics;
91
91
auto res = LFortran::tokens (al, input, diagnostics, &stypes, &locations);
92
92
LFortran::LocationManager lm;
93
- lm.in_filename = infile;
93
+ lm.in_filename . push_back ( infile) ;
94
94
lm.init_simple (input);
95
95
std::cerr << diagnostics.render (input, lm, compiler_options);
96
96
if (res.ok ) {
@@ -121,7 +121,7 @@ int emit_ast(const std::string &infile,
121
121
al, runtime_library_dir, infile, diagnostics, compiler_options.new_parser );
122
122
if (diagnostics.diagnostics .size () > 0 ) {
123
123
LFortran::LocationManager lm;
124
- lm.in_filename = infile;
124
+ lm.in_filename . push_back ( infile) ;
125
125
// TODO: only read this once, and pass it as an argument to parse_python_file()
126
126
std::string input = LFortran::read_file (infile);
127
127
lm.init_simple (input);
@@ -151,7 +151,7 @@ int emit_asr(const std::string &infile,
151
151
Allocator al (4 *1024 );
152
152
LFortran::diag::Diagnostics diagnostics;
153
153
LFortran::LocationManager lm;
154
- lm.in_filename = infile;
154
+ lm.in_filename . push_back ( infile) ;
155
155
std::string input = LFortran::read_file (infile);
156
156
lm.init_simple (input);
157
157
LFortran::Result<LFortran::LPython::AST::ast_t *> r1 = parse_python_file (
@@ -164,7 +164,8 @@ int emit_asr(const std::string &infile,
164
164
165
165
diagnostics.diagnostics .clear ();
166
166
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
167
- r = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
167
+ r = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
168
+ for (auto &x: lm.in_filename ) std::cout << x << " \n " ;
168
169
std::cerr << diagnostics.render (input, lm, compiler_options);
169
170
if (!r.ok ) {
170
171
LFORTRAN_ASSERT (diagnostics.has_error ())
@@ -193,7 +194,7 @@ int emit_cpp(const std::string &infile,
193
194
Allocator al (4 *1024 );
194
195
LFortran::diag::Diagnostics diagnostics;
195
196
LFortran::LocationManager lm;
196
- lm.in_filename = infile;
197
+ lm.in_filename . push_back ( infile) ;
197
198
std::string input = LFortran::read_file (infile);
198
199
lm.init_simple (input);
199
200
LFortran::Result<LFortran::LPython::AST::ast_t *> r = parse_python_file (
@@ -206,7 +207,7 @@ int emit_cpp(const std::string &infile,
206
207
207
208
diagnostics.diagnostics .clear ();
208
209
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
209
- r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
210
+ r1 = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
210
211
std::cerr << diagnostics.render (input, lm, compiler_options);
211
212
if (!r1.ok ) {
212
213
LFORTRAN_ASSERT (diagnostics.has_error ())
@@ -233,7 +234,7 @@ int emit_c(const std::string &infile,
233
234
Allocator al (4 *1024 );
234
235
LFortran::diag::Diagnostics diagnostics;
235
236
LFortran::LocationManager lm;
236
- lm.in_filename = infile;
237
+ lm.in_filename . push_back ( infile) ;
237
238
std::string input = LFortran::read_file (infile);
238
239
lm.init_simple (input);
239
240
LFortran::Result<LFortran::LPython::AST::ast_t *> r = parse_python_file (
@@ -246,7 +247,7 @@ int emit_c(const std::string &infile,
246
247
247
248
diagnostics.diagnostics .clear ();
248
249
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
249
- r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
250
+ r1 = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
250
251
std::cerr << diagnostics.render (input, lm, compiler_options);
251
252
if (!r1.ok ) {
252
253
LFORTRAN_ASSERT (diagnostics.has_error ())
@@ -273,7 +274,7 @@ int emit_wat(const std::string &infile,
273
274
Allocator al (4 *1024 );
274
275
LFortran::diag::Diagnostics diagnostics;
275
276
LFortran::LocationManager lm;
276
- lm.in_filename = infile;
277
+ lm.in_filename . push_back ( infile) ;
277
278
std::string input = LFortran::read_file (infile);
278
279
lm.init_simple (input);
279
280
LFortran::Result<LFortran::LPython::AST::ast_t *> r = parse_python_file (
@@ -286,7 +287,7 @@ int emit_wat(const std::string &infile,
286
287
287
288
diagnostics.diagnostics .clear ();
288
289
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
289
- r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
290
+ r1 = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
290
291
std::cerr << diagnostics.render (input, lm, compiler_options);
291
292
if (!r1.ok ) {
292
293
LFORTRAN_ASSERT (diagnostics.has_error ())
@@ -321,15 +322,15 @@ int get_symbols (const std::string &infile,
321
322
Allocator al (4 *1024 );
322
323
LFortran::diag::Diagnostics diagnostics;
323
324
LFortran::LocationManager lm;
324
- lm.in_filename = infile;
325
+ lm.in_filename . push_back ( infile) ;
325
326
std::string input = LFortran::read_file (infile);
326
327
lm.init_simple (input);
327
328
LFortran::Result<LFortran::LPython::AST::ast_t *> r1 = LFortran::parse_python_file (
328
329
al, runtime_library_dir, infile, diagnostics, compiler_options.new_parser );
329
330
if (r1.ok ) {
330
331
LFortran::LPython::AST::ast_t * ast = r1.result ;
331
332
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
332
- x = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
333
+ x = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
333
334
if (!x.ok ) {
334
335
std::cout << " {}\n " ;
335
336
return 0 ;
@@ -412,7 +413,7 @@ int get_errors (const std::string &infile,
412
413
Allocator al (4 *1024 );
413
414
LFortran::diag::Diagnostics diagnostics;
414
415
LFortran::LocationManager lm;
415
- lm.in_filename = infile;
416
+ lm.in_filename . push_back ( infile) ;
416
417
std::string input = LFortran::read_file (infile);
417
418
lm.init_simple (input);
418
419
LFortran::Result<LFortran::LPython::AST::ast_t *>
@@ -421,7 +422,7 @@ int get_errors (const std::string &infile,
421
422
if (r1.ok ) {
422
423
LFortran::LPython::AST::ast_t * ast = r1.result ;
423
424
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
424
- r = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
425
+ r = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
425
426
}
426
427
std::vector<LFortran::LPython::error_highlight> diag_lists;
427
428
LFortran::LPython::error_highlight h;
@@ -518,7 +519,7 @@ int emit_llvm(const std::string &infile,
518
519
Allocator al (4 *1024 );
519
520
LFortran::diag::Diagnostics diagnostics;
520
521
LFortran::LocationManager lm;
521
- lm.in_filename = infile;
522
+ lm.in_filename . push_back ( infile) ;
522
523
std::string input = LFortran::read_file (infile);
523
524
lm.init_simple (input);
524
525
LFortran::Result<LFortran::LPython::AST::ast_t *> r = parse_python_file (
@@ -532,7 +533,7 @@ int emit_llvm(const std::string &infile,
532
533
LFortran::LPython::AST::ast_t * ast = r.result ;
533
534
diagnostics.diagnostics .clear ();
534
535
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
535
- r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
536
+ r1 = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
536
537
std::cerr << diagnostics.render (input, lm, compiler_options);
537
538
if (!r1.ok ) {
538
539
LFORTRAN_ASSERT (diagnostics.has_error ())
@@ -565,7 +566,7 @@ int compile_python_to_object_file(
565
566
Allocator al (4 *1024 );
566
567
LFortran::diag::Diagnostics diagnostics;
567
568
LFortran::LocationManager lm;
568
- lm.in_filename = infile;
569
+ lm.in_filename . push_back ( infile) ;
569
570
std::vector<std::pair<std::string, double >>times;
570
571
auto file_reading_start = std::chrono::high_resolution_clock::now ();
571
572
std::string input = LFortran::read_file (infile);
@@ -588,7 +589,7 @@ int compile_python_to_object_file(
588
589
diagnostics.diagnostics .clear ();
589
590
auto ast_to_asr_start = std::chrono::high_resolution_clock::now ();
590
591
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
591
- r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options,
592
+ r1 = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options,
592
593
!(arg_c && compiler_options.disable_main ), infile);
593
594
594
595
auto ast_to_asr_end = std::chrono::high_resolution_clock::now ();
@@ -649,7 +650,7 @@ int compile_to_binary_wasm(
649
650
Allocator al (4 *1024 );
650
651
LFortran::diag::Diagnostics diagnostics;
651
652
LFortran::LocationManager lm;
652
- lm.in_filename = infile;
653
+ lm.in_filename . push_back ( infile) ;
653
654
std::vector<std::pair<std::string, double >>times;
654
655
auto file_reading_start = std::chrono::high_resolution_clock::now ();
655
656
std::string input = LFortran::read_file (infile);
@@ -672,7 +673,7 @@ int compile_to_binary_wasm(
672
673
diagnostics.diagnostics .clear ();
673
674
auto ast_to_asr_start = std::chrono::high_resolution_clock::now ();
674
675
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
675
- r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
676
+ r1 = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
676
677
auto ast_to_asr_end = std::chrono::high_resolution_clock::now ();
677
678
times.push_back (std::make_pair (" AST to ASR" , std::chrono::duration<double , std::milli>(ast_to_asr_end - ast_to_asr_start).count ()));
678
679
std::cerr << diagnostics.render (input, lm, compiler_options);
@@ -714,7 +715,7 @@ int compile_to_binary_x86(
714
715
Allocator al (4 *1024 );
715
716
LFortran::diag::Diagnostics diagnostics;
716
717
LFortran::LocationManager lm;
717
- lm.in_filename = infile;
718
+ lm.in_filename . push_back ( infile) ;
718
719
std::vector<std::pair<std::string, double >>times;
719
720
auto file_reading_start = std::chrono::high_resolution_clock::now ();
720
721
std::string input = LFortran::read_file (infile);
@@ -737,7 +738,7 @@ int compile_to_binary_x86(
737
738
diagnostics.diagnostics .clear ();
738
739
auto ast_to_asr_start = std::chrono::high_resolution_clock::now ();
739
740
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
740
- r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
741
+ r1 = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
741
742
auto ast_to_asr_end = std::chrono::high_resolution_clock::now ();
742
743
times.push_back (std::make_pair (" AST to ASR" , std::chrono::duration<double , std::milli>(ast_to_asr_end - ast_to_asr_start).count ()));
743
744
std::cerr << diagnostics.render (input, lm, compiler_options);
@@ -779,7 +780,7 @@ int compile_to_binary_wasm_to_x86(
779
780
Allocator al (4 *1024 );
780
781
LFortran::diag::Diagnostics diagnostics;
781
782
LFortran::LocationManager lm;
782
- lm.in_filename = infile;
783
+ lm.in_filename . push_back ( infile) ;
783
784
std::vector<std::pair<std::string, double >>times;
784
785
auto file_reading_start = std::chrono::high_resolution_clock::now ();
785
786
std::string input = LFortran::read_file (infile);
@@ -802,7 +803,7 @@ int compile_to_binary_wasm_to_x86(
802
803
diagnostics.diagnostics .clear ();
803
804
auto ast_to_asr_start = std::chrono::high_resolution_clock::now ();
804
805
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
805
- r1 = LFortran::LPython::python_ast_to_asr (al, *ast, diagnostics, compiler_options, true , infile);
806
+ r1 = LFortran::LPython::python_ast_to_asr (al, lm, *ast, diagnostics, compiler_options, true , infile);
806
807
auto ast_to_asr_end = std::chrono::high_resolution_clock::now ();
807
808
times.push_back (std::make_pair (" AST to ASR" , std::chrono::duration<double , std::milli>(ast_to_asr_end - ast_to_asr_start).count ()));
808
809
std::cerr << diagnostics.render (input, lm, compiler_options);
@@ -1020,7 +1021,7 @@ int link_executable(const std::vector<std::string> &infiles,
1020
1021
//
1021
1022
// LFortran::CPreprocessor cpp(compiler_options);
1022
1023
// LFortran::LocationManager lm;
1023
- // lm.in_filename = infile;
1024
+ // lm.in_filename.push_back( infile) ;
1024
1025
// std::string s = cpp.run(input, lm, cpp.macro_definitions);
1025
1026
// std::cout << s;
1026
1027
// return 0;
@@ -1038,7 +1039,7 @@ namespace wasm {
1038
1039
Allocator al (4 *1024 ); \
1039
1040
LFortran::LocationManager lm; \
1040
1041
LFortran::diag::Diagnostics diagnostics; \
1041
- lm.in_filename = " input" ;
1042
+ lm.in_filename.push_back( " input" ) ;
1042
1043
1043
1044
1044
1045
@@ -1067,7 +1068,7 @@ EMSCRIPTEN_KEEPALIVE char* emit_asr_from_source(char *input) {
1067
1068
if (ast.ok ) {
1068
1069
auto casted_ast = (LFortran::LPython::AST::ast_t *)ast.result ;
1069
1070
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
1070
- asr = LFortran::LPython::python_ast_to_asr (al, *casted_ast, diagnostics, compiler_options, true , " input" );
1071
+ asr = LFortran::LPython::python_ast_to_asr (al, lm, *casted_ast, diagnostics, compiler_options, true , " input" );
1071
1072
out = diagnostics.render (input, lm, compiler_options);
1072
1073
if (asr.ok ) {
1073
1074
out += LFortran::pickle (*asr.result , compiler_options.use_colors , compiler_options.indent ,
@@ -1085,7 +1086,7 @@ EMSCRIPTEN_KEEPALIVE char* emit_wat_from_source(char *input) {
1085
1086
if (ast.ok ) {
1086
1087
auto casted_ast = (LFortran::LPython::AST::ast_t *)ast.result ;
1087
1088
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
1088
- asr = LFortran::LPython::python_ast_to_asr (al, *casted_ast, diagnostics, compiler_options, true , " input" );
1089
+ asr = LFortran::LPython::python_ast_to_asr (al, lm, *casted_ast, diagnostics, compiler_options, true , " input" );
1089
1090
out = diagnostics.render (input, lm, compiler_options);
1090
1091
if (asr.ok ) {
1091
1092
LFortran::Result<LFortran::Vec<uint8_t >>
@@ -1112,7 +1113,7 @@ EMSCRIPTEN_KEEPALIVE char* emit_cpp_from_source(char *input) {
1112
1113
if (ast.ok ) {
1113
1114
auto casted_ast = (LFortran::LPython::AST::ast_t *)ast.result ;
1114
1115
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
1115
- asr = LFortran::LPython::python_ast_to_asr (al, *casted_ast, diagnostics, compiler_options, true , " input" );
1116
+ asr = LFortran::LPython::python_ast_to_asr (al, lm, *casted_ast, diagnostics, compiler_options, true , " input" );
1116
1117
out = diagnostics.render (input, lm, compiler_options);
1117
1118
if (asr.ok ) {
1118
1119
auto res = LFortran::asr_to_cpp (al, *asr.result , diagnostics,
@@ -1150,7 +1151,7 @@ EMSCRIPTEN_KEEPALIVE char* emit_wasm_from_source(char *input) {
1150
1151
if (ast.ok ) {
1151
1152
auto casted_ast = (LFortran::LPython::AST::ast_t *)ast.result ;
1152
1153
LFortran::Result<LFortran::ASR::TranslationUnit_t*>
1153
- asr = LFortran::LPython::python_ast_to_asr (al, *casted_ast, diagnostics, compiler_options, true , " input" );
1154
+ asr = LFortran::LPython::python_ast_to_asr (al, lm, *casted_ast, diagnostics, compiler_options, true , " input" );
1154
1155
out = diagnostics.render (input, lm, compiler_options);
1155
1156
if (asr.ok ) {
1156
1157
LFortran::Result<LFortran::Vec<uint8_t >>
0 commit comments