Browse Source
Remove exception hooks in favor of real C++ exceptions:
Remove exception hooks in favor of real C++ exceptions:
* include/cln/exception.h: New file... * include/cln/cln.h: ...included here... * include/cln/rational.h: ...and here. * include/cln/abort.h: Removed. * include/cln/integer.h (ash_exception, exquo_exception): Add exception types. * include/cln/float.h (floating_point_exception, floating_point_nan_exception, floating_point_overflow_exception, floating_point_underflow_exception): Likewise. * include/cln/number_io.h (read_number_exception, read_number_bad_syntax_exception, read_number_junk_exception, read_number_eof_exception): Likewise. * include/cln/object.h (CL_DEFINE_CONVERTER): Replace dynamic assertion with a compile-time assertion. * include/cln/GV.h: Replace nonreturning functions with exceptions. * include/cln/modinteger.h: Likewise. * include/cln/SV.h: Likewise. * include/cln/ring.h: Likewise. * include/cln/string.h: Likewise. * include/cln/univpoly.h: Likewise. * src/base/cl_abort.cc: Removed. * src/base/cl_N_err_d0.cc: Removed. * src/base/cl_d0_exception.cc: New file. * src/base/cl_as_err.cc: Removed. * src/base/cl_as_exception.cc: New file. * src/base/cl_notreached.cc: Removed. * src/base/cl_notreached_exception.cc: New file. * src/base/input/cl_read_err_bad.cc: Removed. * src/base/input/cl_read_bad_syntax_exception.cc: New file. * src/base/input/cl_read_err_junk.cc: Removed. * src/base/input/cl_read_junk_exception.cc: New file. * src/base/input/cl_read_err_eof.cc: Removed. * src/base/input/cl_read_eof_exception.cc: New file. * src/base/cl_N.h (cl_as_error): Removed (see cln/exception.h). * src/base/macros.h (NOTREACHED): Throw. * src/base/cl_malloc.cc (xmalloc): Throw. * src/base/digitseq/cl_2DS_div.cc: Throw. * src/base/digitseq/cl_DS_div.cc: Throw. * src/base/digitseq/cl_DS_mul.cc: Throw. * src/base/digitseq/cl_DS_mul_fftc.h: Throw. * src/base/digitseq/cl_DS_mul_fftcs.h: Throw. * src/base/digitseq/cl_DS_mul_fftm.h: Throw. * src/base/digitseq/cl_DS_mul_fftp.h: Throw. * src/base/digitseq/cl_DS_mul_fftp3.h: Throw. * src/base/digitseq/cl_DS_mul_fftp3m.h: Throw. * src/base/digitseq/cl_DS_mul_fftr.h: Throw. * src/base/digitseq/cl_DS_mul_nuss.h: Throw. * src/base/digitseq/cl_DS_recipsqrt.cc: Throw. * src/base/digitseq/cl_DS_sqrt.cc: Throw. * src/base/hash/cl_hash.h: Throw. * src/base/hash/cl_hash1.h: Throw. * src/base/hash/cl_hash1weak.h: Throw. * src/base/hash/cl_hash2.h: Throw. * src/base/hash/cl_hash2weak.h: Throw. * src/base/hash/cl_hashset.h: Throw. * src/base/hash/cl_hashuniq.h: Throw. * src/base/hash/cl_hashuniqweak.h: Throw. * src/base/proplist/cl_pl_add.cc: Throw. * src/base/ring/cl_no_ring.cc: Throw. * src/base/string/cl_spushstring.h: Throw. * src/base/symbol/cl_symbol.cc: Throw. * src/integer/bitwise/cl_I_ash.h: Removed (see cln/integer.h.) * src/integer/bitwise/cl_I_asherr.cc: Removed. * src/integer/bitwise/cl_I_ash_exception.cc: New file. * src/integer/division/cl_I_exquoerr.cc: Removed. * src/integer/division/cl_I_exquo_exception.cc: New file. * src/integer/cl_I.h: Throw. * src/integer/division/cl_I_exquopos.cc: Throw. * src/integer/bitwise/cl_I_logbitp_I.cc: Throw. * src/integer/bitwise/cl_I_ash.cc: Throw. * src/integer/bitwise/cl_I_ash_I.cc: Throw. * src/integer/division/cl_I_exquo.cc: Throw. * src/integer/gcd/cl_I_gcd_aux2.cc: Throw. * src/integer/conv/cl_I_to_L.cc: Throw. * src/integer/conv/cl_I_to_Q.cc: Throw. * src/integer/conv/cl_I_to_UL.cc: Throw. * src/integer/conv/cl_I_to_UQ.cc: Throw. * src/integer/conv/cl_I_to_digits.cc: Throw. * src/integer/elem/cl_I_div.cc: Throw. * src/integer/algebraic/cl_I_sqrt.cc: Throw. * src/integer/input/cl_I_read.cc: Throw. * src/integer/input/cl_I_read_stream.cc: Throw. * src/integer/misc/cl_I_as.cc: Throw. * src/rational/elem/cl_RA_from_I_I_div.cc: Throw. * src/rational/elem/cl_RA_recip.cc: Throw. * src/rational/input/cl_RA_read.cc: Throw. * src/rational/input/cl_RA_read_stream.cc: Throw. * src/rational/input/cl_RA_readparsed.cc: Throw. * src/rational/misc/cl_RA_as.cc: Throw. * src/float/base/cl_F_err_nan.cc: Removed. * src/float/base/cl_F_nan_exception.cc: New file. * src/float/base/cl_F_err_un.cc: Removed. * src/float/base/cl_F_underflow_exception.cc: New file. * src/float/base/cl_F_err_ov.cc: Removed. * src/float/base/cl_F_overflow_exception.cc: New file. * src/float/cl_F.h (cl_error_floating_point_nan, cl_error_floating_point_overflow, cl_error_floating_point_underflow): Removed (see cln/float.h.) * src/float/sfloat/cl_SF.h: Throw. * src/float/sfloat/elem/cl_SF_div.cc: Throw. * src/float/sfloat/elem/cl_SF_from_RA.cc: Throw. * src/float/sfloat/elem/cl_SF_scale.cc: Throw. * src/float/sfloat/elem/cl_SF_scale_I.cc: Throw. * src/float/sfloat/misc/cl_SF_as.cc: Throw. * src/float/ffloat/cl_FF.h: Throw. * src/float/ffloat/conv/cl_FF_from_float.cc: Throw. * src/float/ffloat/elem/cl_FF_div.cc: Throw. * src/float/ffloat/elem/cl_FF_from_RA.cc: Throw. * src/float/ffloat/elem/cl_FF_scale.cc: Throw. * src/float/ffloat/elem/cl_FF_scale_I.cc: Throw. * src/float/ffloat/misc/cl_FF_as.cc: Throw. * src/float/dfloat/cl_DF.h: Throw. * src/float/dfloat/conv/cl_DF_from_double.cc: Throw. * src/float/dfloat/elem/cl_DF_div.cc: Throw. * src/float/dfloat/elem/cl_DF_from_RA.cc: Throw. * src/float/dfloat/elem/cl_DF_scale.cc: Throw. * src/float/dfloat/elem/cl_DF_scale_I.cc: Throw. * src/float/dfloat/misc/cl_DF_as.cc: Throw. * src/float/lfloat/algebraic/cl_LF_sqrt.cc: Throw. * src/float/lfloat/elem/cl_LF_1plus.cc: Throw. * src/float/lfloat/elem/cl_LF_I_div.cc: Throw. * src/float/lfloat/elem/cl_LF_I_mul.cc: Throw. * src/float/lfloat/elem/cl_LF_div.cc: Throw. * src/float/lfloat/elem/cl_LF_from_I.cc: Throw. * src/float/lfloat/elem/cl_LF_mul.cc: Throw. * src/float/lfloat/elem/cl_LF_scale.cc: Throw. * src/float/lfloat/elem/cl_LF_scale_I.cc: Throw. * src/float/lfloat/elem/cl_LF_square.cc: Throw. * src/float/lfloat/misc/cl_LF_as.cc: Throw. * src/float/lfloat/misc/cl_LF_shorten.cc: Throw. * src/float/lfloat/misc/cl_LF_shortenrel.cc: Throw. * src/float/lfloat/misc/cl_LF_shortenwith.cc: Throw. * src/float/input/cl_F_read.cc: Throw. * src/float/input/cl_F_read_stream.cc: Throw. * src/float/misc/cl_F_as.cc: Throw. * src/float/misc/cl_F_shortenrel.cc: Throw. * src/float/transcendental/cl_LF_coshsinh_aux.cc: Throw. * src/float/transcendental/cl_LF_cossin_aux.cc: Throw. * src/float/transcendental/cl_LF_exp_aux.cc: Throw. * src/float/transcendental/cl_LF_ratseries_a.cc: Throw. * src/float/transcendental/cl_LF_ratseries_ab.cc: Throw. * src/float/transcendental/cl_LF_ratseries_b.cc: Throw. * src/float/transcendental/cl_LF_ratseries_p.cc: Throw. * src/float/transcendental/cl_LF_ratseries_pa.cc: Throw. * src/float/transcendental/cl_LF_ratseries_pab.cc: Throw. * src/float/transcendental/cl_LF_ratseries_pb.cc: Throw. * src/float/transcendental/cl_LF_ratseries_pq.cc: Throw. * src/float/transcendental/cl_LF_ratseries_pqa.cc: Throw. * src/float/transcendental/cl_LF_ratseries_pqab.cc: Throw. * src/float/transcendental/cl_LF_ratseries_pqb.cc: Throw. * src/float/transcendental/cl_LF_ratseries_q.cc: Throw. * src/float/transcendental/cl_LF_ratseries_qa.cc: Throw. * src/float/transcendental/cl_LF_ratseries_qab.cc: Throw. * src/float/transcendental/cl_LF_ratseries_qb.cc: Throw. * src/float/transcendental/cl_LF_ratseries_stream_pq.cc: Throw. * src/float/transcendental/cl_LF_ratseries_stream_pqa.cc: Throw. * src/float/transcendental/cl_LF_ratseries_stream_pqab.cc: Throw. * src/float/transcendental/cl_LF_ratseries_stream_pqb.cc: Throw. * src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc: Throw. * src/float/transcendental/cl_LF_ratsumseries_pqd.cc: Throw. * src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc: Throw. * src/float/transcendental/cl_LF_zeta_int.cc: Throw. * src/real/elem/cl_R_div.cc: Throw. * src/real/format-output/cl_fmt_cardinal.cc: Throw. * src/real/format-output/cl_fmt_newroman.cc: Throw. * src/real/format-output/cl_fmt_oldroman.cc: Throw. * src/real/input/cl_R_read.cc: Throw. * src/real/input/cl_R_read_stream.cc: Throw. * src/real/misc/cl_R_as.cc: Throw. * src/real/random/cl_R_random.cc: Throw. * src/real/transcendental/cl_R_atan2.cc: Throw. * src/real/transcendental/cl_R_log.cc: Throw. * src/complex/input/cl_N_read.cc: Throw. * src/complex/input/cl_N_read_stream.cc: Throw. * src/complex/misc/cl_N_as.cc: Throw. * src/complex/transcendental/cl_C_atanh_aux.cc: Throw. * src/complex/transcendental/cl_C_expt_C.cc: Throw. * src/complex/transcendental/cl_C_log.cc: Throw. * src/complex/transcendental/cl_C_log2.cc: Throw. * src/numtheory/cl_nt_cornacchia1.cc: Throw. * src/numtheory/cl_nt_cornacchia4.cc: Throw. * src/numtheory/cl_nt_isprobprime.cc: Throw. * src/numtheory/cl_nt_jacobi.cc: Throw. * src/numtheory/cl_nt_jacobi_low.cc: Throw. * src/numtheory/cl_nt_sqrtmodp.cc: Throw. * src/modinteger/cl_MI.cc: Throw. * src/modinteger/cl_MI_int.h: Throw. * src/modinteger/cl_MI_montgom.h: Throw. * src/modinteger/cl_MI_pow2.h: Throw. * src/modinteger/cl_MI_rshift.cc: Throw. * src/modinteger/cl_MI_std.h: Throw. * src/polynomial/elem/cl_UP_GF2.h: Throw. * src/polynomial/elem/cl_UP_MI.h: Throw. * src/polynomial/elem/cl_UP_gen.h: Throw. * src/polynomial/elem/cl_UP_named.cc: Throw. * src/polynomial/elem/cl_UP_no_ring.cc (uninitialized_error, uninitialized_ring): Removed (see cln/ring.h.) * src/polynomial/elem/cl_UP_number.h: Throw. * src/polynomial/elem/cl_UP_unnamed.cc: Throw. * src/vector/cl_GV_I.cc: Throw. * src/vector/cl_GV_number.cc: Throw. * tests/timediv2adic-compare.cc: Use default abort(), not cl_abort(). * tests/timeprint-compare.cc: Likewise. * tests/timerecip2adic-compare.cc: Likewise. * doc/cln.tex: Document the exception classes. * examples/contfrac.cc: Use try/catch instead of setjmp/longjmp. * INSTALL: undocument -fno-exceptions. * README: Add exceptions to list of used C++ features.master
210 changed files with 1394 additions and 1170 deletions
-
212ChangeLog
-
7INSTALL
-
3NEWS
-
6README
-
117doc/cln.tex
-
55examples/contfrac.cc
-
10include/cln/GV.h
-
6include/cln/SV.h
-
16include/cln/abort.h
-
2include/cln/cln.h
-
39include/cln/exception.h
-
28include/cln/float.h
-
13include/cln/integer.h
-
44include/cln/modinteger.h
-
38include/cln/number_io.h
-
2include/cln/object.h
-
1include/cln/rational.h
-
42include/cln/ring.h
-
8include/cln/string.h
-
40include/cln/univpoly.h
-
3src/base/cl_N.h
-
23src/base/cl_N_err_d0.cc
-
21src/base/cl_abort.cc
-
38src/base/cl_as_err.cc
-
44src/base/cl_as_exception.cc
-
15src/base/cl_d0_exception.cc
-
1src/base/cl_debug.cc
-
6src/base/cl_macros.h
-
5src/base/cl_malloc.cc
-
28src/base/cl_notreached.cc
-
34src/base/cl_notreached_exception.cc
-
4src/base/digitseq/cl_2DS_div.cc
-
13src/base/digitseq/cl_DS_div.cc
-
4src/base/digitseq/cl_DS_mul.cc
-
42src/base/digitseq/cl_DS_mul_fftc.h
-
36src/base/digitseq/cl_DS_mul_fftcs.h
-
16src/base/digitseq/cl_DS_mul_fftm.h
-
30src/base/digitseq/cl_DS_mul_fftp.h
-
22src/base/digitseq/cl_DS_mul_fftp3.h
-
26src/base/digitseq/cl_DS_mul_fftp3m.h
-
36src/base/digitseq/cl_DS_mul_fftr.h
-
24src/base/digitseq/cl_DS_mul_nuss.h
-
2src/base/digitseq/cl_DS_recip.cc
-
10src/base/digitseq/cl_DS_recipsqrt.cc
-
12src/base/digitseq/cl_DS_sqrt.cc
-
6src/base/hash/cl_hash.h
-
6src/base/hash/cl_hash1.h
-
2src/base/hash/cl_hash1weak.h
-
6src/base/hash/cl_hash2.h
-
2src/base/hash/cl_hash2weak.h
-
6src/base/hash/cl_hashset.h
-
6src/base/hash/cl_hashuniq.h
-
2src/base/hash/cl_hashuniqweak.h
-
32src/base/input/cl_read_bad_syntax_exception.cc
-
11src/base/input/cl_read_eof_exception.cc
-
26src/base/input/cl_read_err_bad.cc
-
31src/base/input/cl_read_err_junk.cc
-
37src/base/input/cl_read_junk_exception.cc
-
4src/base/proplist/cl_pl_add.cc
-
68src/base/ring/cl_no_ring.cc
-
4src/base/string/cl_spushstring.h
-
2src/base/symbol/cl_symbol.cc
-
15src/complex/input/cl_N_read.cc
-
4src/complex/input/cl_N_read_stream.cc
-
3src/complex/misc/cl_N_as.cc
-
4src/complex/transcendental/cl_C_atanh_aux.cc
-
2src/complex/transcendental/cl_C_expt_C.cc
-
2src/complex/transcendental/cl_C_log.cc
-
2src/complex/transcendental/cl_C_log2.cc
-
23src/float/base/cl_F_err_nan.cc
-
23src/float/base/cl_F_err_ov.cc
-
23src/float/base/cl_F_err_un.cc
-
20src/float/base/cl_F_nan_exception.cc
-
20src/float/base/cl_F_overflow_exception.cc
-
20src/float/base/cl_F_underflow_exception.cc
-
7src/float/cl_F.h
-
24src/float/dfloat/cl_DF.h
-
16src/float/dfloat/conv/cl_DF_from_double.cc
-
4src/float/dfloat/elem/cl_DF_div.cc
-
4src/float/dfloat/elem/cl_DF_from_RA.cc
-
4src/float/dfloat/elem/cl_DF_scale.cc
-
4src/float/dfloat/elem/cl_DF_scale_I.cc
-
2src/float/dfloat/misc/cl_DF_as.cc
-
12src/float/ffloat/cl_FF.h
-
8src/float/ffloat/conv/cl_FF_from_float.cc
-
2src/float/ffloat/elem/cl_FF_div.cc
-
4src/float/ffloat/elem/cl_FF_from_RA.cc
-
4src/float/ffloat/elem/cl_FF_scale.cc
-
4src/float/ffloat/elem/cl_FF_scale_I.cc
-
2src/float/ffloat/misc/cl_FF_as.cc
-
4src/float/input/cl_F_read.cc
-
4src/float/input/cl_F_read_stream.cc
-
4src/float/lfloat/algebraic/cl_LF_sqrt.cc
-
8src/float/lfloat/elem/cl_LF_1plus.cc
-
6src/float/lfloat/elem/cl_LF_I_div.cc
-
4src/float/lfloat/elem/cl_LF_I_mul.cc
-
12src/float/lfloat/elem/cl_LF_div.cc
-
4src/float/lfloat/elem/cl_LF_from_I.cc
-
8src/float/lfloat/elem/cl_LF_mul.cc
-
4src/float/lfloat/elem/cl_LF_scale.cc
@ -1,16 +0,0 @@ |
|||
// Abnormal program exit. |
|||
|
|||
#ifndef _CL_ABORT_H |
|||
#define _CL_ABORT_H |
|||
|
|||
namespace cln { |
|||
|
|||
#ifdef _CL_MACROS_H |
|||
nonreturning_function(extern, cl_abort, (void)); |
|||
#else |
|||
extern void cl_abort (void); |
|||
#endif |
|||
|
|||
} // namespace cln |
|||
|
|||
#endif /* _CL_ABORT_H */ |
@ -0,0 +1,39 @@ |
|||
// Exception types. |
|||
|
|||
#ifndef _CL_EXCEPTION_H |
|||
#define _CL_EXCEPTION_H |
|||
|
|||
#include <stdexcept> |
|||
|
|||
namespace cln { |
|||
|
|||
// Base class of all exception classes thrown by CLN. |
|||
class runtime_exception : public std::runtime_error { |
|||
public: |
|||
runtime_exception () |
|||
: std::runtime_error(std::string()) {} |
|||
explicit runtime_exception (const std::string & what) |
|||
: std::runtime_error(what) {} |
|||
}; |
|||
|
|||
// Thrown when an assertion is violated. |
|||
class notreached_exception : public runtime_exception { |
|||
public: |
|||
notreached_exception (const char* filename, int lineno); |
|||
}; |
|||
|
|||
// Thrown when a pole is encountered. |
|||
class division_by_0_exception : public runtime_exception { |
|||
public: |
|||
division_by_0_exception (); |
|||
}; |
|||
|
|||
// Thrown when a conversion with As(TYPE)(VALUE) fails. |
|||
class as_exception : public runtime_exception { |
|||
public: |
|||
as_exception (const class cl_number& obj, const char * typestring, const char * filename, int line); |
|||
}; |
|||
|
|||
} // namespace cln |
|||
|
|||
#endif /* _CL_EXCEPTION_H */ |
@ -1,23 +0,0 @@ |
|||
// cl_error_division_by_0().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_N.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include "cln/abort.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
void cl_error_division_by_0 (void) |
|||
{ |
|||
fprint(std::cerr, "Division by zero.\n"); |
|||
cl_abort(); |
|||
} |
|||
|
|||
} // namespace cln
|
@ -1,21 +0,0 @@ |
|||
// cl_abort().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cln/abort.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include <cstdlib>
|
|||
|
|||
namespace cln { |
|||
|
|||
void cl_abort (void) |
|||
{ |
|||
exit(1); |
|||
} |
|||
|
|||
} // namespace cln
|
@ -1,38 +0,0 @@ |
|||
// cl_as_error().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_N.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include "cln/abort.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
void cl_as_error (const cl_number& obj, const char * typestring, const char * filename, int line) |
|||
{ |
|||
fprint(std::cerr, "Type assertion failed: in file "); |
|||
fprint(std::cerr, filename); |
|||
fprint(std::cerr, ", line "); |
|||
fprintdecimal(std::cerr, line); |
|||
fprint(std::cerr, ", not "); |
|||
fprint(std::cerr, typestring); |
|||
fprint(std::cerr, ": "); |
|||
#if 0 // This brings in a dependency from the complex and float printer and all the float stuff.
|
|||
fprint(std::cerr, obj); |
|||
#else
|
|||
fprint(std::cerr, "@0x"); |
|||
fprinthexadecimal(std::cerr, (unsigned long)(void*)&obj); |
|||
fprint(std::cerr, ": 0x"); |
|||
fprinthexadecimal(std::cerr, (unsigned long)obj.word); |
|||
#endif
|
|||
fprint(std::cerr, "\n"); |
|||
cl_abort(); |
|||
} |
|||
|
|||
} // namespace cln
|
@ -0,0 +1,44 @@ |
|||
// as_exception().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cln/exception.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include "cl_N.h"
|
|||
#include <sstream>
|
|||
|
|||
namespace cln { |
|||
|
|||
static inline const std::string |
|||
as_error_msg (const cl_number& obj, const char * typestring, const char * filename, int line) |
|||
{ |
|||
std::ostringstream buf; |
|||
fprint(buf, "Type assertion failed: in file "); |
|||
fprint(buf, filename); |
|||
fprint(buf, ", line "); |
|||
fprintdecimal(buf, line); |
|||
fprint(buf, ", not "); |
|||
fprint(buf, typestring); |
|||
fprint(buf, ": "); |
|||
#if 0 // This brings in a dependency from the complex and float printer and all the float stuff.
|
|||
fprint(buf, obj); |
|||
#else
|
|||
fprint(buf, "@0x"); |
|||
fprinthexadecimal(buf, (unsigned long)(void*)&obj); |
|||
fprint(buf, ": 0x"); |
|||
fprinthexadecimal(buf, (unsigned long)obj.word); |
|||
#endif
|
|||
return buf.str(); |
|||
} |
|||
|
|||
as_exception::as_exception (const cl_number& obj, const char * typestring, const char * filename, int line) |
|||
: runtime_exception(as_error_msg(obj, typestring, filename, line)) |
|||
{} |
|||
|
|||
} // namespace cln
|
@ -0,0 +1,15 @@ |
|||
// division_by_0_exception().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cln/exception.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
division_by_0_exception::division_by_0_exception () |
|||
: runtime_exception("Division by zero.") |
|||
{} |
|||
|
|||
} // namespace cln
|
@ -1,28 +0,0 @@ |
|||
// cl_notreached_abort().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_macros.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include "cln/abort.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
void cl_notreached_abort (const char* filename, int lineno) |
|||
{ |
|||
fprint(std::cerr, "Internal error: statement in file "); |
|||
fprint(std::cerr, filename); |
|||
fprint(std::cerr, ", line "); |
|||
fprintdecimal(std::cerr, lineno); |
|||
fprint(std::cerr, " has been reached!!\n"); |
|||
fprint(std::cerr, "Please send the authors of the program a description how you produced this error!\n"); |
|||
cl_abort(); |
|||
} |
|||
|
|||
} // namespace cln
|
@ -0,0 +1,34 @@ |
|||
// cl_notreached_exception().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_macros.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include <sstream>
|
|||
|
|||
namespace cln { |
|||
|
|||
static inline const std::string |
|||
notreached_error_msg (const char* filename, int lineno) |
|||
{ |
|||
std::ostringstream buf; |
|||
fprint(buf, "Internal error: statement in file "); |
|||
fprint(buf, filename); |
|||
fprint(buf, ", line "); |
|||
fprintdecimal(buf, lineno); |
|||
fprint(buf, " has been reached!!\n"); |
|||
fprint(buf, "Please send the authors of the program a description how you produced this error!"); |
|||
return buf.str(); |
|||
} |
|||
|
|||
notreached_exception::notreached_exception (const char* filename, int lineno) |
|||
: runtime_exception(notreached_error_msg(filename, lineno)) |
|||
{} |
|||
|
|||
} // namespace cln
|
@ -0,0 +1,32 @@ |
|||
// read_number_bad_syntax_exception().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cln/number_io.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include <sstream>
|
|||
#include "cln/io.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
static inline const std::string |
|||
read_number_bad_syntax_msg (const char * string, const char * string_limit) |
|||
{ |
|||
std::ostringstream buf; |
|||
fprint(buf, "Illegal number syntax: \""); |
|||
for (const char * ptr = string; ptr != string_limit; ptr++) |
|||
fprintchar(buf, *ptr); |
|||
fprint(buf, "\""); |
|||
return buf.str(); |
|||
} |
|||
|
|||
read_number_bad_syntax_exception::read_number_bad_syntax_exception (const char * string, const char * string_limit) |
|||
: read_number_exception(read_number_bad_syntax_msg(string, string_limit)) |
|||
{} |
|||
|
|||
} // namespace cln
|
@ -1,26 +0,0 @@ |
|||
// read_number_bad_syntax().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cln/number_io.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include "cln/abort.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
void read_number_bad_syntax (const char * string, const char * string_limit) |
|||
{ |
|||
fprint(std::cerr, "Illegal number syntax: \""); |
|||
for (const char * ptr = string; ptr != string_limit; ptr++) |
|||
fprintchar(std::cerr, *ptr); |
|||
fprint(std::cerr, "\"\n"); |
|||
cl_abort(); |
|||
} |
|||
|
|||
} // namespace cln
|
@ -1,31 +0,0 @@ |
|||
// read_number_junk().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cln/number_io.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include "cln/abort.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
void read_number_junk (const char * string_rest, const char * string, const char * string_limit) |
|||
{ |
|||
fprint(std::cerr, "Junk after number: "); |
|||
{ for (const char * ptr = string; ptr != string_rest; ptr++) |
|||
fprintchar(std::cerr, *ptr); |
|||
} |
|||
fprint(std::cerr, "\""); |
|||
{ for (const char * ptr = string_rest; ptr != string_limit; ptr++) |
|||
fprintchar(std::cerr, *ptr); |
|||
} |
|||
fprint(std::cerr, "\"\n"); |
|||
cl_abort(); |
|||
} |
|||
|
|||
} // namespace cln
|
@ -0,0 +1,37 @@ |
|||
// read_number_junk_exception().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cln/number_io.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include <sstream>
|
|||
#include "cln/io.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
static inline const std::string |
|||
read_number_junk_msg (const char * string_rest, const char * string, const char * string_limit) |
|||
{ |
|||
std::ostringstream buf; |
|||
fprint(buf, "Junk after number: "); |
|||
{ for (const char * ptr = string; ptr != string_rest; ptr++) |
|||
fprintchar(buf, *ptr); |
|||
} |
|||
fprint(buf, "\""); |
|||
{ for (const char * ptr = string_rest; ptr != string_limit; ptr++) |
|||
fprintchar(buf, *ptr); |
|||
} |
|||
fprint(buf, "\""); |
|||
return buf.str(); |
|||
} |
|||
|
|||
read_number_junk_exception::read_number_junk_exception (const char * string_rest, const char * string, const char * string_limit) |
|||
: read_number_exception(read_number_junk_msg(string_rest, string, string_limit)) |
|||
{} |
|||
|
|||
} // namespace cln
|
@ -1,23 +0,0 @@ |
|||
// cl_error_floating_point_overflow().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_F.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include "cln/abort.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
void cl_error_floating_point_nan (void) |
|||
{ |
|||
fprint(std::cerr, "floating point NaN occurred.\n"); |
|||
cl_abort(); |
|||
} |
|||
|
|||
} // namespace cln
|
@ -1,23 +0,0 @@ |
|||
// cl_error_floating_point_overflow().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_F.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include "cln/abort.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
void cl_error_floating_point_overflow (void) |
|||
{ |
|||
fprint(std::cerr, "Floating point overflow.\n"); |
|||
cl_abort(); |
|||
} |
|||
|
|||
} // namespace cln
|
@ -1,23 +0,0 @@ |
|||
// cl_error_floating_point_underflow().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_F.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
#include "cln/abort.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
void cl_error_floating_point_underflow (void) |
|||
{ |
|||
fprint(std::cerr, "Floating point underflow.\n"); |
|||
cl_abort(); |
|||
} |
|||
|
|||
} // namespace cln
|
@ -0,0 +1,20 @@ |
|||
// floating_point_nan_exception().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_F.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
floating_point_nan_exception::floating_point_nan_exception () |
|||
: floating_point_exception("floating point NaN occurred.") |
|||
{} |
|||
|
|||
} // namespace cln
|
@ -0,0 +1,20 @@ |
|||
// floating_point_overflow_exception().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_F.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
floating_point_overflow_exception::floating_point_overflow_exception () |
|||
: floating_point_exception("floating point overflow.") |
|||
{} |
|||
|
|||
} // namespace cln
|
@ -0,0 +1,20 @@ |
|||
// floating_point_underflow_exception().
|
|||
|
|||
// General includes.
|
|||
#include "cl_sysdep.h"
|
|||
|
|||
// Specification.
|
|||
#include "cl_F.h"
|
|||
|
|||
|
|||
// Implementation.
|
|||
|
|||
#include "cln/io.h"
|
|||
|
|||
namespace cln { |
|||
|
|||
floating_point_underflow_exception::floating_point_underflow_exception () |
|||
: floating_point_exception("floating point underflow.") |
|||
{} |
|||
|
|||
} // namespace cln
|
Some files were not shown because too many files changed in this diff
Reference in new issue
xxxxxxxxxx