Skip to content

Commit

Permalink
Rename LFortranException to LCompilersException
Browse files Browse the repository at this point in the history
  • Loading branch information
Smit-create committed Jul 22, 2022
1 parent 0a9ee91 commit 70810c3
Show file tree
Hide file tree
Showing 30 changed files with 116 additions and 116 deletions.
14 changes: 7 additions & 7 deletions grammar/asdl_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def visitSum(self, sum, base):
self.emit("void visit_%s(const %s_t &b) { visit_%s_t(b, self()); }"\
% (base, base, base), 1)
for type_ in sum.types:
self.emit("""void visit_%s(const %s_t & /* x */) { throw LFortran::LFortranException("visit_%s() not implemented"); }""" \
self.emit("""void visit_%s(const %s_t & /* x */) { throw LFortran::LCompilersException("visit_%s() not implemented"); }""" \
% (type_.name, type_.name, type_.name), 2)


Expand Down Expand Up @@ -1512,9 +1512,9 @@ def visitSum(self, sum, *args):
for tp in sum.types:
self.emit( 'case (%s::%sType::%s) : return self().deserialize_%s();' \
% (subs["MOD"], args[0], tp.name, tp.name), 3)
self.emit( 'default : throw LFortranException("Unknown type in deserialize_%s()");' % args[0], 3)
self.emit( 'default : throw LCompilersException("Unknown type in deserialize_%s()");' % args[0], 3)
self.emit( '}', 2)
self.emit( 'throw LFortranException("Switch statement above was not exhaustive.");', 2)
self.emit( 'throw LCompilersException("Switch statement above was not exhaustive.");', 2)

self.emit("}", 1)

Expand All @@ -1528,9 +1528,9 @@ def emit_deserialize_node(self):
for tp in sums:
self.emit( 'case (%s::%sType::%s) : return self().deserialize_%s();' \
% (subs["MOD"], subs["mod"], tp, tp), 3)
self.emit( 'default : throw LFortranException("Unknown type in deserialize_%s()");' % name, 3)
self.emit( 'default : throw LCompilersException("Unknown type in deserialize_%s()");' % name, 3)
self.emit( '}', 2)
self.emit( 'throw LFortranException("Switch statement above was not exhaustive.");', 2)
self.emit( 'throw LCompilersException("Switch statement above was not exhaustive.");', 2)
self.emit( '}', 1)

def visitProduct(self, prod, name):
Expand Down Expand Up @@ -1788,7 +1788,7 @@ def visitModule(self, mod):

super(ExprTypeVisitor, self).visitModule(mod)

self.emit(""" default : throw LFortranException("Not implemented");
self.emit(""" default : throw LCompilersException("Not implemented");
}
}
""")
Expand Down Expand Up @@ -1855,7 +1855,7 @@ def visitModule(self, mod):

super(ExprValueVisitor, self).visitModule(mod)

self.emit(""" default : throw LFortranException("Not implemented");
self.emit(""" default : throw LCompilersException("Not implemented");
}
}
""")
Expand Down
8 changes: 4 additions & 4 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ std::string get_kokkos_dir()
std::cerr << "The code C++ generated by the C++ LFortran backend uses the Kokkos library" << std::endl;
std::cerr << "(https://github.com/kokkos/kokkos). Please define the LFORTRAN_KOKKOS_DIR" << std::endl;
std::cerr << "environment variable to point to the Kokkos installation." << std::endl;
throw LFortran::LFortranException("LFORTRAN_KOKKOS_DIR is not defined");
throw LFortran::LCompilersException("LFORTRAN_KOKKOS_DIR is not defined");
}

#ifdef HAVE_LFORTRAN_LLVM
Expand Down Expand Up @@ -870,7 +870,7 @@ int main(int argc, char *argv[])
return 1;
#endif
} else {
throw LFortran::LFortranException("Unsupported backend.");
throw LFortran::LCompilersException("Unsupported backend.");
}
}

Expand All @@ -886,7 +886,7 @@ int main(int argc, char *argv[])
return 1;
#endif
} else {
throw LFortran::LFortranException("Unsupported backend.");
throw LFortran::LCompilersException("Unsupported backend.");
}
if (err) return err;
return link_executable({tmp_o}, outfile, runtime_library_dir,
Expand All @@ -895,7 +895,7 @@ int main(int argc, char *argv[])
return link_executable(arg_files, outfile, runtime_library_dir,
backend, static_link, true, compiler_options);
}
} catch(const LFortran::LFortranException &e) {
} catch(const LFortran::LCompilersException &e) {
std::cerr << "Internal Compiler Error: Unhandled exception" << std::endl;
std::vector<LFortran::StacktraceItem> d = e.stacktrace_addresses();
get_local_addresses(d);
Expand Down
4 changes: 2 additions & 2 deletions src/libasr/asr_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ASR::Module_t* extract_module(const ASR::TranslationUnit_t &m) {
LFORTRAN_ASSERT(ASR::is_a<ASR::Module_t>(*a.second));
return ASR::down_cast<ASR::Module_t>(a.second);
}
throw LFortranException("ICE: Module not found");
throw LCompilersException("ICE: Module not found");
}

ASR::Module_t* load_module(Allocator &al, SymbolTable *symtab,
Expand Down Expand Up @@ -393,7 +393,7 @@ bool is_op_overloaded(ASR::binopType op, std::string& intrinsic_op_name,
break;
}
default: {
throw LFortranException("Binary operator '" + ASRUtils::binop_to_str_python(op) + "' not supported yet");
throw LCompilersException("Binary operator '" + ASRUtils::binop_to_str_python(op) + "' not supported yet");
}
}
if( result && curr_scope->get_symbol(intrinsic_op_name) == nullptr ) {
Expand Down
38 changes: 19 additions & 19 deletions src/libasr/asr_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static inline ASR::ttype_t* symbol_type(const ASR::symbol_t *f)
return ASR::down_cast<ASR::Variable_t>(f)->m_type;
}
default: {
throw LFortranException("Cannot return type of, " +
throw LCompilersException("Cannot return type of, " +
std::to_string(f->type) + " symbol.");
}
}
Expand Down Expand Up @@ -149,7 +149,7 @@ static inline std::string type_to_str(const ASR::ttype_t *t)
return type_to_str(ASRUtils::type_get_past_pointer(
const_cast<ASR::ttype_t*>(t))) + " pointer";
}
default : throw LFortranException("Not implemented " + std::to_string(t->type) + ".");
default : throw LCompilersException("Not implemented " + std::to_string(t->type) + ".");
}
}

Expand All @@ -159,7 +159,7 @@ static inline std::string binop_to_str(const ASR::binopType t) {
case (ASR::binopType::Sub): { return " - "; }
case (ASR::binopType::Mul): { return "*"; }
case (ASR::binopType::Div): { return "/"; }
default : throw LFortranException("Cannot represent the binary operator as a string");
default : throw LCompilersException("Cannot represent the binary operator as a string");
}
}

Expand All @@ -171,7 +171,7 @@ static inline std::string cmpop_to_str(const ASR::cmpopType t) {
case (ASR::cmpopType::LtE): { return " <= "; }
case (ASR::cmpopType::Gt): { return " > "; }
case (ASR::cmpopType::GtE): { return " >= "; }
default : throw LFortranException("Cannot represent the comparison as a string");
default : throw LCompilersException("Cannot represent the comparison as a string");
}
}

Expand All @@ -181,7 +181,7 @@ static inline std::string logicalbinop_to_str_python(const ASR::logicalbinopType
case (ASR::logicalbinopType::Or): { return " || "; }
case (ASR::logicalbinopType::Eqv): { return " == "; }
case (ASR::logicalbinopType::NEqv): { return " != "; }
default : throw LFortranException("Cannot represent the boolean operator as a string");
default : throw LCompilersException("Cannot represent the boolean operator as a string");
}
}

Expand Down Expand Up @@ -229,7 +229,7 @@ static inline char *symbol_name(const ASR::symbol_t *f)
case ASR::symbolType::Block: {
return ASR::down_cast<ASR::Block_t>(f)->m_name;
}
default : throw LFortranException("Not implemented");
default : throw LCompilersException("Not implemented");
}
}

Expand Down Expand Up @@ -272,7 +272,7 @@ static inline SymbolTable *symbol_parent_symtab(const ASR::symbol_t *f)
case ASR::symbolType::Block: {
return ASR::down_cast<ASR::Block_t>(f)->m_symtab->parent;
}
default : throw LFortranException("Not implemented");
default : throw LCompilersException("Not implemented");
}
}

Expand All @@ -294,30 +294,30 @@ static inline SymbolTable *symbol_symtab(const ASR::symbol_t *f)
}
case ASR::symbolType::GenericProcedure: {
return nullptr;
//throw LFortranException("GenericProcedure does not have a symtab");
//throw LCompilersException("GenericProcedure does not have a symtab");
}
case ASR::symbolType::DerivedType: {
return ASR::down_cast<ASR::DerivedType_t>(f)->m_symtab;
}
case ASR::symbolType::Variable: {
return nullptr;
//throw LFortranException("Variable does not have a symtab");
//throw LCompilersException("Variable does not have a symtab");
}
case ASR::symbolType::ExternalSymbol: {
return nullptr;
//throw LFortranException("ExternalSymbol does not have a symtab");
//throw LCompilersException("ExternalSymbol does not have a symtab");
}
case ASR::symbolType::ClassProcedure: {
return nullptr;
//throw LFortranException("ClassProcedure does not have a symtab");
//throw LCompilersException("ClassProcedure does not have a symtab");
}
case ASR::symbolType::AssociateBlock: {
return ASR::down_cast<ASR::AssociateBlock_t>(f)->m_symtab;
}
case ASR::symbolType::Block: {
return ASR::down_cast<ASR::Block_t>(f)->m_symtab;
}
default : throw LFortranException("Not implemented");
default : throw LCompilersException("Not implemented");
}
}

Expand Down Expand Up @@ -629,7 +629,7 @@ static inline std::string type_to_str_python(const ASR::ttype_t *t,
case 2: { res = "i16"; break; }
case 4: { res = "i32"; break; }
case 8: { res = "i64"; break; }
default: { throw LFortranException("Integer kind not supported"); }
default: { throw LCompilersException("Integer kind not supported"); }
}
if (i->n_dims == 1 && for_error_message) {
res = type_python_1dim_helper(res, i->m_dims);
Expand All @@ -642,7 +642,7 @@ static inline std::string type_to_str_python(const ASR::ttype_t *t,
switch (r->m_kind) {
case 4: { res = "f32"; break; }
case 8: { res = "f64"; break; }
default: { throw LFortranException("Float kind not supported"); }
default: { throw LCompilersException("Float kind not supported"); }
}
if (r->n_dims == 1 && for_error_message) {
res = type_python_1dim_helper(res, r->m_dims);
Expand All @@ -654,7 +654,7 @@ static inline std::string type_to_str_python(const ASR::ttype_t *t,
switch (c->m_kind) {
case 4: { return "c32"; }
case 8: { return "c64"; }
default: { throw LFortranException("Complex kind not supported"); }
default: { throw LCompilersException("Complex kind not supported"); }
}
}
case ASR::ttypeType::Logical: {
Expand Down Expand Up @@ -698,7 +698,7 @@ static inline std::string type_to_str_python(const ASR::ttype_t *t,
ASR::Pointer_t* p = ASR::down_cast<ASR::Pointer_t>(t);
return "Pointer[" + type_to_str_python(p->m_type) + "]";
}
default : throw LFortranException("Not implemented " + std::to_string(t->type));
default : throw LCompilersException("Not implemented " + std::to_string(t->type));
}
}

Expand All @@ -713,7 +713,7 @@ static inline std::string binop_to_str_python(const ASR::binopType t) {
case (ASR::binopType::BitXor): { return "^"; }
case (ASR::binopType::BitLShift): { return "<<"; }
case (ASR::binopType::BitRShift): { return ">>"; }
default : throw LFortranException("Cannot represent the binary operator as a string");
default : throw LCompilersException("Cannot represent the binary operator as a string");
}
}

Expand Down Expand Up @@ -979,7 +979,7 @@ inline int extract_dimensions_from_ttype(ASR::ttype_t *x,
break;
}
default:
throw LFortranException("Not implemented.");
throw LCompilersException("Not implemented.");
}
return n_dims;
}
Expand Down Expand Up @@ -1041,7 +1041,7 @@ static inline ASR::ttype_t* duplicate_type(Allocator& al, const ASR::ttype_t* t,
return ASRUtils::TYPE(ASR::make_Pointer_t(al, ptr->base.base.loc,
dup_type));
}
default : throw LFortranException("Not implemented " + std::to_string(t->type));
default : throw LCompilersException("Not implemented " + std::to_string(t->type));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libasr/asr_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
// Requires the condition `cond` to be true. Raise an exception otherwise.
void require(bool cond, const std::string &error_msg) {
if (!cond) {
throw LFortranException("ASR verify failed: " + error_msg);
throw LCompilersException("ASR verify failed: " + error_msg);
}
}
void require(bool cond, const std::string &error_msg,
Expand Down
20 changes: 10 additions & 10 deletions src/libasr/bwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class BinaryReader

uint8_t read_int8() {
if (pos+1 > s.size()) {
throw LFortranException("read_int8: String is too short for deserialization.");
throw LCompilersException("read_int8: String is too short for deserialization.");
}
uint8_t n = s[pos];
pos += 1;
Expand All @@ -118,7 +118,7 @@ class BinaryReader

uint32_t read_int32() {
if (pos+4 > s.size()) {
throw LFortranException("read_int32: String is too short for deserialization.");
throw LCompilersException("read_int32: String is too short for deserialization.");
}
uint32_t n = string_to_uint32(&s[pos]);
pos += 4;
Expand All @@ -127,7 +127,7 @@ class BinaryReader

uint64_t read_int64() {
if (pos+8 > s.size()) {
throw LFortranException("read_int64: String is too short for deserialization.");
throw LCompilersException("read_int64: String is too short for deserialization.");
}
uint64_t n = string_to_uint64(&s[pos]);
pos += 8;
Expand All @@ -137,7 +137,7 @@ class BinaryReader
std::string read_string() {
size_t n = read_int64();
if (pos+n > s.size()) {
throw LFortranException("read_string: String is too short for deserialization.");
throw LCompilersException("read_string: String is too short for deserialization.");
}
std::string r = std::string(&s[pos], n);
pos += n;
Expand Down Expand Up @@ -202,7 +202,7 @@ class TextReader
if (n < 255) {
return n;
} else {
throw LFortranException("read_int8: Integer too large to fit 8 bits.");
throw LCompilersException("read_int8: Integer too large to fit 8 bits.");
}
}

Expand All @@ -211,11 +211,11 @@ class TextReader
while (s[pos] != ' ') {
tmp += s[pos];
if (! (s[pos] >= '0' && s[pos] <= '9')) {
throw LFortranException("read_int64: Expected integer, got `" + tmp + "`");
throw LCompilersException("read_int64: Expected integer, got `" + tmp + "`");
}
pos++;
if (pos >= s.size()) {
throw LFortranException("read_int64: String is too short for deserialization.");
throw LCompilersException("read_int64: String is too short for deserialization.");
}
}
pos++;
Expand All @@ -229,7 +229,7 @@ class TextReader
tmp += s[pos];
pos++;
if (pos >= s.size()) {
throw LFortranException("read_float64: String is too short for deserialization.");
throw LCompilersException("read_float64: String is too short for deserialization.");
}
}
pos++;
Expand All @@ -240,12 +240,12 @@ class TextReader
std::string read_string() {
size_t n = read_int64();
if (pos+n > s.size()) {
throw LFortranException("read_string: String is too short for deserialization.");
throw LCompilersException("read_string: String is too short for deserialization.");
}
std::string r = std::string(&s[pos], n);
pos += n;
if (s[pos] != ' ') {
throw LFortranException("read_string: Space expected.");
throw LCompilersException("read_string: Space expected.");
}
pos ++;
return r;
Expand Down
6 changes: 3 additions & 3 deletions src/libasr/codegen/asr_to_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,15 @@ R"(
return "%lli";
}
}
default: { throw LFortranException("Integer kind not supported"); }
default: { throw LCompilersException("Integer kind not supported"); }
}
}
case ASR::ttypeType::Real: {
ASR::Real_t *r = (ASR::Real_t*)t;
switch (r->m_kind) {
case 4: { return "%f"; }
case 8: { return "%lf"; }
default: { throw LFortranException("Float kind not supported"); }
default: { throw LCompilersException("Float kind not supported"); }
}
}
case ASR::ttypeType::Logical: {
Expand All @@ -564,7 +564,7 @@ R"(
return get_print_type(type_ptr->m_type, false);
}
}
default : throw LFortranException("Not implemented");
default : throw LCompilersException("Not implemented");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4429,7 +4429,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
llvm::Value* d = builder->CreatePtrToInt(tmp, getIntType(8, false));
args.push_back(d);
} else {
throw LFortranException("Printing support is not available for " +
throw LCompilersException("Printing support is not available for " +
ASRUtils::type_to_str(t) + " type.");
}
}
Expand Down
Loading

0 comments on commit 70810c3

Please sign in to comment.