diff options
Diffstat (limited to 'libgcobol/exceptl.h')
-rw-r--r-- | libgcobol/exceptl.h | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/libgcobol/exceptl.h b/libgcobol/exceptl.h index 3580903..dcad545 100644 --- a/libgcobol/exceptl.h +++ b/libgcobol/exceptl.h @@ -117,140 +117,4 @@ extern ec_descr_t *__gg__exception_table_end; */ -// SymException -struct cbl_exception_t { - size_t program, file; - ec_type_t type; - cbl_file_mode_t mode; -}; - - -struct cbl_declarative_t { - enum { files_max = 16 }; - size_t section; // implies program - bool global; - ec_type_t type; - uint32_t nfile, files[files_max]; - cbl_file_mode_t mode; - - cbl_declarative_t( cbl_file_mode_t mode = file_mode_none_e ) - : section(0), global(false), type(ec_none_e) - , nfile(0) - , mode(mode) - { - std::fill(files, files + COUNT_OF(files), 0); - } - cbl_declarative_t( ec_type_t type ) - : section(0), global(false), type(type) - , nfile(0) - , mode(file_mode_none_e) - { - std::fill(files, files + COUNT_OF(files), 0); - } - - cbl_declarative_t( size_t section, ec_type_t type, - const std::list<size_t>& files, - cbl_file_mode_t mode, bool global = false ) - : section(section), global(global), type(type) - , nfile(files.size()) - , mode(mode) - { - assert( files.size() <= COUNT_OF(this->files) ); - std::fill(this->files, this->files + COUNT_OF(this->files), 0); - if( nfile > 0 ) { - std::copy( files.begin(), files.end(), this->files ); - } - } - cbl_declarative_t( const cbl_declarative_t& that ) - : section(that.section), global(that.global), type(that.type) - , nfile(that.nfile) - , mode(that.mode) - { - std::fill(files, files + COUNT_OF(files), 0); - if( nfile > 0 ) { - std::copy( that.files, that.files + nfile, this->files ); - } - } - - /* - * Sort file names before file modes, and file modes before non-IO. - */ - bool operator<( const cbl_declarative_t& that ) const { - // file name declaratives first, in section order - if( nfile != 0 ) { - if( that.nfile != 0 ) return section < that.section; - return true; - } - // file mode declaratives between file name declaratives and non-IO - if( mode != file_mode_none_e ) { - if( that.nfile != 0 ) return false; - if( that.mode == file_mode_none_e ) return true; - return section < that.section; - } - // all others by section, after names and modes - if( that.nfile != 0 ) return false; - if( that.mode != file_mode_none_e ) return false; - return section < that.section; - } - - // TRUE if there are no files to match, or the provided file is in the list. - bool match_file( size_t file ) const { - static const auto pend = files + nfile; - - return nfile == 0 || pend != std::find(files, files + nfile, file); - } - - // USE Format 1 names a file mode, or at least one file, and not an EC. - bool is_format_1() const { - assert(type != ec_none_e || nfile > 0 || mode != file_mode_none_e); - return nfile > 0 || mode != file_mode_none_e; - } -}; - - -/* - * ec_status_t represents the runtime exception condition status for - * any statement. Prior to execution, the generated code - * clears "type", and sets "source_file" and "lineno". - * - * If the statement includes some kind of ON ERROR - * clause, the generated code sets "handled" to the exception type - * handled by that clause, else it sets "handled" to ec_none_e. - * - * Post-execution, the generated code sets "type" to the appropriate - * exception, if any. The match-exception logic compares any raised - * exception to the set of declaratives, and returns a symbol-table - * index to the matching declarative, if any. - */ -class ec_status_t { - char msg[132]; -public: - ec_type_t type, handled; - cbl_name_t statement; // e.g., "ADD" - size_t lineno; - const char *source_file; - - ec_status_t() - : type(ec_none_e) - , handled(ec_none_e) - , lineno(0) - , source_file(NULL) - { - msg[0] = statement[0] = '\0'; - } - - ec_status_t& update(); - ec_status_t& enable( unsigned int mask ); - - const char * exception_location() { - snprintf(msg, sizeof(msg), "%s:%zu: '%s'", source_file, lineno, statement); - return msg; - } - ec_type_t unhandled() const { - return ec_type_t(static_cast<unsigned int>(type) - & - ~static_cast<unsigned int>(handled)); - } -}; - #endif |