Skip to content

Commit 70d4505

Browse files
Rename LFORTRAN_ASSERT to LCOMPILERS_ASSERT
1 parent ed807bb commit 70d4505

46 files changed

Lines changed: 351 additions & 351 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/bin/lpython.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int emit_tokens(const std::string &infile, bool line_numbers, const CompilerOpti
103103
if (res.ok) {
104104
toks = res.result;
105105
} else {
106-
LFORTRAN_ASSERT(diagnostics.has_error())
106+
LCOMPILERS_ASSERT(diagnostics.has_error())
107107
return 1;
108108
}
109109

@@ -139,7 +139,7 @@ int emit_ast(const std::string &infile,
139139
std::cerr << diagnostics.render(lm, compiler_options);
140140
}
141141
if (!r.ok) {
142-
LFORTRAN_ASSERT(diagnostics.has_error())
142+
LCOMPILERS_ASSERT(diagnostics.has_error())
143143
return 1;
144144
}
145145
LFortran::LPython::AST::ast_t* ast = r.result;
@@ -184,7 +184,7 @@ int emit_asr(const std::string &infile,
184184
compiler_options, true, infile);
185185
std::cerr << diagnostics.render(lm, compiler_options);
186186
if (!r.ok) {
187-
LFORTRAN_ASSERT(diagnostics.has_error())
187+
LCOMPILERS_ASSERT(diagnostics.has_error())
188188
return 2;
189189
}
190190
LFortran::ASR::TranslationUnit_t* asr = r.result;
@@ -231,7 +231,7 @@ int emit_cpp(const std::string &infile,
231231
r1 = LFortran::LPython::python_ast_to_asr(al, lm, *ast, diagnostics, compiler_options, true, infile);
232232
std::cerr << diagnostics.render(lm, compiler_options);
233233
if (!r1.ok) {
234-
LFORTRAN_ASSERT(diagnostics.has_error())
234+
LCOMPILERS_ASSERT(diagnostics.has_error())
235235
return 2;
236236
}
237237
LFortran::ASR::TranslationUnit_t* asr = r1.result;
@@ -241,7 +241,7 @@ int emit_cpp(const std::string &infile,
241241
compiler_options.platform, 0);
242242
std::cerr << diagnostics.render(lm, compiler_options);
243243
if (!res.ok) {
244-
LFORTRAN_ASSERT(diagnostics.has_error())
244+
LCOMPILERS_ASSERT(diagnostics.has_error())
245245
return 3;
246246
}
247247
std::cout << res.result;
@@ -276,7 +276,7 @@ int emit_c(const std::string &infile,
276276
r1 = LFortran::LPython::python_ast_to_asr(al, lm, *ast, diagnostics, compiler_options, true, infile);
277277
std::cerr << diagnostics.render(lm, compiler_options);
278278
if (!r1.ok) {
279-
LFORTRAN_ASSERT(diagnostics.has_error())
279+
LCOMPILERS_ASSERT(diagnostics.has_error())
280280
return 2;
281281
}
282282
LFortran::ASR::TranslationUnit_t* asr = r1.result;
@@ -286,7 +286,7 @@ int emit_c(const std::string &infile,
286286
compiler_options.platform, 0);
287287
std::cerr << diagnostics.render(lm, compiler_options);
288288
if (!res.ok) {
289-
LFORTRAN_ASSERT(diagnostics.has_error())
289+
LCOMPILERS_ASSERT(diagnostics.has_error())
290290
return 3;
291291
}
292292
std::cout << res.result;
@@ -321,7 +321,7 @@ int emit_wat(const std::string &infile,
321321
r1 = LFortran::LPython::python_ast_to_asr(al, lm, *ast, diagnostics, compiler_options, true, infile);
322322
std::cerr << diagnostics.render(lm, compiler_options);
323323
if (!r1.ok) {
324-
LFORTRAN_ASSERT(diagnostics.has_error())
324+
LCOMPILERS_ASSERT(diagnostics.has_error())
325325
return 2;
326326
}
327327
LFortran::ASR::TranslationUnit_t* asr = r1.result;
@@ -330,15 +330,15 @@ int emit_wat(const std::string &infile,
330330
LFortran::Result<LFortran::Vec<uint8_t>> r2 = LFortran::asr_to_wasm_bytes_stream(*asr, al, diagnostics);
331331
std::cerr << diagnostics.render(lm, compiler_options);
332332
if (!r2.ok) {
333-
LFORTRAN_ASSERT(diagnostics.has_error())
333+
LCOMPILERS_ASSERT(diagnostics.has_error())
334334
return 3;
335335
}
336336

337337
diagnostics.diagnostics.clear();
338338
LFortran::Result<std::string> res = LFortran::wasm_to_wat(r2.result, al, diagnostics);
339339
std::cerr << diagnostics.render(lm, compiler_options);
340340
if (!res.ok) {
341-
LFORTRAN_ASSERT(diagnostics.has_error())
341+
LCOMPILERS_ASSERT(diagnostics.has_error())
342342
return 4;
343343
}
344344
std::cout << res.result;
@@ -590,7 +590,7 @@ int emit_llvm(const std::string &infile,
590590
r1 = LFortran::LPython::python_ast_to_asr(al, lm, *ast, diagnostics, compiler_options, true, infile);
591591
std::cerr << diagnostics.render(lm, compiler_options);
592592
if (!r1.ok) {
593-
LFORTRAN_ASSERT(diagnostics.has_error())
593+
LCOMPILERS_ASSERT(diagnostics.has_error())
594594
return 2;
595595
}
596596
LFortran::ASR::TranslationUnit_t* asr = r1.result;
@@ -602,7 +602,7 @@ int emit_llvm(const std::string &infile,
602602
res = fe.get_llvm3(*asr, pass_manager, diagnostics, infile);
603603
std::cerr << diagnostics.render(lm, compiler_options);
604604
if (!res.ok) {
605-
LFORTRAN_ASSERT(diagnostics.has_error())
605+
LCOMPILERS_ASSERT(diagnostics.has_error())
606606
return 3;
607607
}
608608
std::cout << (res.result)->str();
@@ -658,7 +658,7 @@ int compile_python_to_object_file(
658658
times.push_back(std::make_pair("AST to ASR", std::chrono::duration<double, std::milli>(ast_to_asr_end - ast_to_asr_start).count()));
659659
std::cerr << diagnostics.render(lm, compiler_options);
660660
if (!r1.ok) {
661-
LFORTRAN_ASSERT(diagnostics.has_error())
661+
LCOMPILERS_ASSERT(diagnostics.has_error())
662662
print_time_report(times, time_report);
663663
return 2;
664664
}
@@ -682,7 +682,7 @@ int compile_python_to_object_file(
682682
times.push_back(std::make_pair("ASR to LLVM", std::chrono::duration<double, std::milli>(asr_to_llvm_end - asr_to_llvm_start).count()));
683683
std::cerr << diagnostics.render(lm, compiler_options);
684684
if (!res.ok) {
685-
LFORTRAN_ASSERT(diagnostics.has_error())
685+
LCOMPILERS_ASSERT(diagnostics.has_error())
686686
print_time_report(times, time_report);
687687
return 3;
688688
}
@@ -748,7 +748,7 @@ int compile_to_binary_wasm(
748748
times.push_back(std::make_pair("AST to ASR", std::chrono::duration<double, std::milli>(ast_to_asr_end - ast_to_asr_start).count()));
749749
std::cerr << diagnostics.render(lm, compiler_options);
750750
if (!r1.ok) {
751-
LFORTRAN_ASSERT(diagnostics.has_error())
751+
LCOMPILERS_ASSERT(diagnostics.has_error())
752752
print_time_report(times, time_report);
753753
return 2;
754754
}
@@ -769,7 +769,7 @@ int compile_to_binary_wasm(
769769
std::cerr << diagnostics.render(lm, compiler_options);
770770
print_time_report(times, time_report);
771771
if (!res.ok) {
772-
LFORTRAN_ASSERT(diagnostics.has_error())
772+
LCOMPILERS_ASSERT(diagnostics.has_error())
773773
return 3;
774774
}
775775
return 0;
@@ -821,7 +821,7 @@ int compile_to_binary_x86(
821821
times.push_back(std::make_pair("AST to ASR", std::chrono::duration<double, std::milli>(ast_to_asr_end - ast_to_asr_start).count()));
822822
std::cerr << diagnostics.render(lm, compiler_options);
823823
if (!r1.ok) {
824-
LFORTRAN_ASSERT(diagnostics.has_error())
824+
LCOMPILERS_ASSERT(diagnostics.has_error())
825825
print_time_report(times, time_report);
826826
return 2;
827827
}
@@ -842,7 +842,7 @@ int compile_to_binary_x86(
842842
std::cerr << diagnostics.render(lm, compiler_options);
843843
print_time_report(times, time_report);
844844
if (!r3.ok) {
845-
LFORTRAN_ASSERT(diagnostics.has_error())
845+
LCOMPILERS_ASSERT(diagnostics.has_error())
846846
return 3;
847847
}
848848
return 0;
@@ -895,7 +895,7 @@ int compile_to_binary_wasm_to_x86(
895895
times.push_back(std::make_pair("AST to ASR", std::chrono::duration<double, std::milli>(ast_to_asr_end - ast_to_asr_start).count()));
896896
std::cerr << diagnostics.render(lm, compiler_options);
897897
if (!r1.ok) {
898-
LFORTRAN_ASSERT(diagnostics.has_error())
898+
LCOMPILERS_ASSERT(diagnostics.has_error())
899899
print_time_report(times, time_report);
900900
return 2;
901901
}
@@ -915,7 +915,7 @@ int compile_to_binary_wasm_to_x86(
915915
times.push_back(std::make_pair("ASR to WASM", std::chrono::duration<double, std::milli>(asr_to_wasm_end - asr_to_wasm_start).count()));
916916
std::cerr << diagnostics.render(lm, compiler_options);
917917
if (!r3.ok) {
918-
LFORTRAN_ASSERT(diagnostics.has_error())
918+
LCOMPILERS_ASSERT(diagnostics.has_error())
919919
print_time_report(times, time_report);
920920
return 3;
921921
}
@@ -940,7 +940,7 @@ int compile_to_binary_wasm_to_x86(
940940
std::cerr << diagnostics.render(lm, compiler_options);
941941
print_time_report(times, time_report);
942942
if (!is_result_ok) {
943-
LFORTRAN_ASSERT(diagnostics.has_error())
943+
LCOMPILERS_ASSERT(diagnostics.has_error())
944944
return 4;
945945
}
946946
return 0;
@@ -1089,7 +1089,7 @@ int link_executable(const std::vector<std::string> &infiles,
10891089
}
10901090
return 0;
10911091
} else {
1092-
LFORTRAN_ASSERT(false);
1092+
LCOMPILERS_ASSERT(false);
10931093
return 1;
10941094
}
10951095
}
@@ -1599,7 +1599,7 @@ int main(int argc, char *argv[])
15991599
std::cerr << "The C++ backend does not work with the -S option yet." << std::endl;
16001600
return 1;
16011601
} else {
1602-
LFORTRAN_ASSERT(false);
1602+
LCOMPILERS_ASSERT(false);
16031603
}
16041604
}
16051605

src/libasr/alloc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Allocator
5353
// doing it. This try/catch approach effectively achieves the same using
5454
// standard C++.
5555
try {
56-
LFORTRAN_ASSERT(start != nullptr);
56+
LCOMPILERS_ASSERT(start != nullptr);
5757
size_t addr = current_pos;
5858
current_pos += align(s);
5959
if (size_current() > size_total()) throw std::bad_alloc();
@@ -77,7 +77,7 @@ class Allocator
7777
size_t addr = current_pos;
7878
current_pos += align(s);
7979

80-
LFORTRAN_ASSERT(size_current() <= size_total());
80+
LCOMPILERS_ASSERT(size_current() <= size_total());
8181
return (void*)addr;
8282
}
8383

src/libasr/asdl_cpp.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def visitSum(self, sum, base):
279279
self.emit("template <class Visitor>")
280280
self.emit("static void visit_%s_t(const %s_t &x, Visitor &v) {" \
281281
% (base, base))
282-
self.emit( "LFORTRAN_ASSERT(x.base.type == %sType::%s)" \
282+
self.emit( "LCOMPILERS_ASSERT(x.base.type == %sType::%s)" \
283283
% (subs["mod"], base), 1)
284284
self.emit( "switch (x.type) {", 1)
285285
for type_ in sum.types:
@@ -535,7 +535,7 @@ def visitModule(self, mod):
535535
self.emit( "}", 1)
536536
self.emit( "void dec_indent() {", 1)
537537
self.emit( "indent_level--;", 2)
538-
self.emit( "LFORTRAN_ASSERT(indent_level >= 0);", 2)
538+
self.emit( "LCOMPILERS_ASSERT(indent_level >= 0);", 2)
539539
self.emit( "indtd = indtd.substr(0, indent_level*indent_spaces);",2)
540540
self.emit( "}", 1)
541541
self.mod = mod
@@ -814,23 +814,23 @@ def visitModule(self, mod):
814814

815815
super(ExprStmtDuplicatorVisitor, self).visitModule(mod)
816816
self.duplicate_stmt.append((" default: {", 2))
817-
self.duplicate_stmt.append((' LFORTRAN_ASSERT_MSG(false, "Duplication of " + std::to_string(x->type) + " statement is not supported yet.");', 3))
817+
self.duplicate_stmt.append((' LCOMPILERS_ASSERT_MSG(false, "Duplication of " + std::to_string(x->type) + " statement is not supported yet.");', 3))
818818
self.duplicate_stmt.append((" }", 2))
819819
self.duplicate_stmt.append((" }", 1))
820820
self.duplicate_stmt.append(("", 0))
821821
self.duplicate_stmt.append((" return nullptr;", 1))
822822
self.duplicate_stmt.append((" }", 0))
823823

824824
self.duplicate_expr.append((" default: {", 2))
825-
self.duplicate_expr.append((' LFORTRAN_ASSERT_MSG(false, "Duplication of " + std::to_string(x->type) + " expression is not supported yet.");', 3))
825+
self.duplicate_expr.append((' LCOMPILERS_ASSERT_MSG(false, "Duplication of " + std::to_string(x->type) + " expression is not supported yet.");', 3))
826826
self.duplicate_expr.append((" }", 2))
827827
self.duplicate_expr.append((" }", 1))
828828
self.duplicate_expr.append(("", 0))
829829
self.duplicate_expr.append((" return nullptr;", 1))
830830
self.duplicate_expr.append((" }", 0))
831831

832832
self.duplicate_case_stmt.append((" default: {", 2))
833-
self.duplicate_case_stmt.append((' LFORTRAN_ASSERT_MSG(false, "Duplication of " + std::to_string(x->type) + " case statement is not supported yet.");', 3))
833+
self.duplicate_case_stmt.append((' LCOMPILERS_ASSERT_MSG(false, "Duplication of " + std::to_string(x->type) + " case statement is not supported yet.");', 3))
834834
self.duplicate_case_stmt.append((" }", 2))
835835
self.duplicate_case_stmt.append((" }", 1))
836836
self.duplicate_case_stmt.append(("", 0))
@@ -1026,7 +1026,7 @@ def visitModule(self, mod):
10261026
super(ExprBaseReplacerVisitor, self).visitModule(mod)
10271027

10281028
self.replace_expr.append((" default: {", 2))
1029-
self.replace_expr.append((' LFORTRAN_ASSERT_MSG(false, "Duplication of " + std::to_string(x->type) + " expression is not supported yet.");', 3))
1029+
self.replace_expr.append((' LCOMPILERS_ASSERT_MSG(false, "Duplication of " + std::to_string(x->type) + " expression is not supported yet.");', 3))
10301030
self.replace_expr.append((" }", 2))
10311031
self.replace_expr.append((" }", 1))
10321032
self.replace_expr.append(("", 0))
@@ -1127,7 +1127,7 @@ def visitModule(self, mod):
11271127
super(StmtBaseReplacerVisitor, self).visitModule(mod)
11281128

11291129
self.replace_stmt.append((" default: {", 2))
1130-
self.replace_stmt.append((' LFORTRAN_ASSERT_MSG(false, "Replacement of " + std::to_string(x->type) + " statement is not supported yet.");', 3))
1130+
self.replace_stmt.append((' LCOMPILERS_ASSERT_MSG(false, "Replacement of " + std::to_string(x->type) + " statement is not supported yet.");', 3))
11311131
self.replace_stmt.append((" }", 2))
11321132
self.replace_stmt.append((" }", 1))
11331133
self.replace_stmt.append(("", 0))
@@ -1208,7 +1208,7 @@ def visitModule(self, mod):
12081208
self.emit( "}",1)
12091209
self.emit( "void dec_indent() {", 1)
12101210
self.emit( "indent_level--;", 2)
1211-
self.emit( "LFORTRAN_ASSERT(indent_level >= 0);", 2)
1211+
self.emit( "LCOMPILERS_ASSERT(indent_level >= 0);", 2)
12121212
self.emit( "indented = std::string(indent_level*indent_spaces, ' ');",2)
12131213
self.emit( "}",1)
12141214
self.mod = mod
@@ -1503,7 +1503,7 @@ def visitModule(self, mod):
15031503
self.emit( "}",1)
15041504
self.emit( "void dec_indent() {", 1)
15051505
self.emit( "indent_level--;", 2)
1506-
self.emit( "LFORTRAN_ASSERT(indent_level >= 0);", 2)
1506+
self.emit( "LCOMPILERS_ASSERT(indent_level >= 0);", 2)
15071507
self.emit( "indtd = std::string(indent_level*indent_spaces, ' ');",2)
15081508
self.emit( "}",1)
15091509
self.emit( "void append_location(std::string &s, uint32_t first, uint32_t last) {", 1)
@@ -2163,12 +2163,12 @@ def visitConstructor(self, cons, _):
21632163
# symbol table that was not constructed yet. If
21642164
# that ever happens, we would have to remember
21652165
# this and come back later to fix the pointer.
2166-
lines.append("LFORTRAN_ASSERT(id_symtab_map.find(m_%s_counter) != id_symtab_map.end());" % f.name)
2166+
lines.append("LCOMPILERS_ASSERT(id_symtab_map.find(m_%s_counter) != id_symtab_map.end());" % f.name)
21672167
lines.append("SymbolTable *m_%s = id_symtab_map[m_%s_counter];" % (f.name, f.name))
21682168
else:
21692169
# We construct a new table. It should not
21702170
# be present:
2171-
lines.append("LFORTRAN_ASSERT(id_symtab_map.find(m_%s_counter) == id_symtab_map.end());" % f.name)
2171+
lines.append("LCOMPILERS_ASSERT(id_symtab_map.find(m_%s_counter) == id_symtab_map.end());" % f.name)
21722172
lines.append("SymbolTable *m_%s = al.make_new<SymbolTable>(nullptr);" % (f.name))
21732173
lines.append("if (load_symtab_id) m_%s->counter = m_%s_counter;" % (f.name, f.name))
21742174
lines.append("id_symtab_map[m_%s_counter] = m_%s;" % (f.name, f.name))
@@ -2245,7 +2245,7 @@ def visitModule(self, mod):
22452245
self.emit("""\
22462246
static inline ASR::ttype_t* expr_type0(const ASR::expr_t *f)
22472247
{
2248-
LFORTRAN_ASSERT(f != nullptr);
2248+
LCOMPILERS_ASSERT(f != nullptr);
22492249
switch (f->type) {""")
22502250

22512251
super(ExprTypeVisitor, self).visitModule(mod)
@@ -2278,8 +2278,8 @@ def make_visitor(self, name, fields):
22782278
ASR::symbol_t *s = ((ASR::%s_t*)f)->m_v;
22792279
if (s->type == ASR::symbolType::ExternalSymbol) {
22802280
ASR::ExternalSymbol_t *e = ASR::down_cast<ASR::ExternalSymbol_t>(s);
2281-
LFORTRAN_ASSERT(e->m_external);
2282-
LFORTRAN_ASSERT(!ASR::is_a<ASR::ExternalSymbol_t>(*e->m_external));
2281+
LCOMPILERS_ASSERT(e->m_external);
2282+
LCOMPILERS_ASSERT(!ASR::is_a<ASR::ExternalSymbol_t>(*e->m_external));
22832283
s = e->m_external;
22842284
}
22852285
return ASR::down_cast<ASR::Variable_t>(s)->m_type;
@@ -2316,7 +2316,7 @@ def visitModule(self, mod):
23162316
self.emit("""\
23172317
static inline ASR::expr_t* expr_value0(ASR::expr_t *f)
23182318
{
2319-
LFORTRAN_ASSERT(f != nullptr);
2319+
LCOMPILERS_ASSERT(f != nullptr);
23202320
switch (f->type) {""")
23212321

23222322
super(ExprValueVisitor, self).visitModule(mod)
@@ -2349,7 +2349,7 @@ def make_visitor(self, name, fields):
23492349
ASR::symbol_t *s = ((ASR::%s_t*)f)->m_v;
23502350
if (s->type == ASR::symbolType::ExternalSymbol) {
23512351
ASR::ExternalSymbol_t *e = ASR::down_cast<ASR::ExternalSymbol_t>(s);
2352-
LFORTRAN_ASSERT(!ASR::is_a<ASR::ExternalSymbol_t>(*e->m_external));
2352+
LCOMPILERS_ASSERT(!ASR::is_a<ASR::ExternalSymbol_t>(*e->m_external));
23532353
s = e->m_external;
23542354
}
23552355
return ASR::down_cast<ASR::Variable_t>(s)->m_value;
@@ -2451,8 +2451,8 @@ def add_masks(fields, node):
24512451
template <class T, class U>
24522452
static inline T* down_cast(const U *f)
24532453
{
2454-
LFORTRAN_ASSERT(f != nullptr);
2455-
LFORTRAN_ASSERT(is_a<T>(*f));
2454+
LCOMPILERS_ASSERT(f != nullptr);
2455+
LCOMPILERS_ASSERT(is_a<T>(*f));
24562456
return (T*)f;
24572457
}
24582458

src/libasr/asr_scopes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ ASR::symbol_t *SymbolTable::find_scoped_symbol(const std::string &name,
116116
}
117117
if (s->scope.find(name) != scope.end()) {
118118
ASR::symbol_t *sym = s->scope.at(name);
119-
LFORTRAN_ASSERT(sym)
119+
LCOMPILERS_ASSERT(sym)
120120
return sym;
121121
} else {
122122
// The `name` not found in the appropriate symbol table

src/libasr/asr_scopes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct SymbolTable {
6565

6666
void erase_symbol(const std::string &name) {
6767
//auto it = scope.find(to_lower(name));
68-
LFORTRAN_ASSERT(scope.find(name) != scope.end())
68+
LCOMPILERS_ASSERT(scope.find(name) != scope.end())
6969
scope.erase(name);
7070
}
7171

0 commit comments

Comments
 (0)