Lolly 1.4.28
Loading...
Searching...
No Matches
basic.cpp
Go to the documentation of this file.
1
2/******************************************************************************
3 * MODULE : basic.cpp
4 * DESCRIPTION: fast global new and delete
5 * COPYRIGHT : (C) 1999 Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11
12#include "basic.hpp"
13#include "analyze.hpp"
14#include "string.hpp"
15
16int
18 return ((int) ((intptr_t) ptr)) + (((int) ((intptr_t) ptr)) % 19);
19}
20
21#ifdef USE_EXCEPTIONS
24// string get_crash_report (const char* msg);
25
26void
27tm_throw (const char* msg) {
29 // the_report = get_crash_report (msg);
30 cout << "Throwing " << msg << LF;
31 cout << "-------------------------------------------------\n";
32 cout << the_report << LF;
33 cout << "-------------------------------------------------\n";
34 throw string (msg);
35}
36
37void
39 if (N (the_exception) != 0) {
40 // formatted arg (verbatim_to_tree (the_report, false, "utf-8"));
41 // failed_error << "Exception, " << the_exception << arg << LF;
42 the_exception= "";
43 the_report = "";
44 }
45}
46#endif
47
48/******************************************************************************
49 * miscellaneous routines
50 ******************************************************************************/
51
52int
54 static int id= 0;
55 id--;
56 return id;
57}
58
59static int current_indent= 0;
60
63 int i;
64 switch (ctrl) {
65 case INDENT:
66 out << " ";
68 break;
69 case UNINDENT:
70 out << "\b\b";
72 break;
73 case HRULE:
74 for (i= current_indent; i < 78; i++)
75 out << "-";
76 case LF:
77 out << "\n";
78 for (i= 0; i < current_indent; i++)
79 out << " ";
80 break;
81 }
82 return out;
83}
int N(array< T > a)
Get the length of the array.
Definition array.hpp:170
int hash(pointer ptr)
Computes a hash value for a pointer.
Definition basic.cpp:17
int new_type_identifier()
Generates a new type identifier.
Definition basic.cpp:53
void handle_exceptions()
Function used to handle exceptions by displaying and clearing the exception message.
Definition basic.cpp:38
tm_ostream & operator<<(tm_ostream &out, display_control ctrl)
Output operator for display control options.
Definition basic.cpp:62
void tm_throw(const char *msg)
Function used to throw an exception with a specified error message.
Definition basic.cpp:27
string the_exception
Global variable used to store the current exception message.
Definition basic.cpp:22
static int current_indent
Definition basic.cpp:59
string the_report
Definition basic.cpp:23
void * pointer
Definition basic.hpp:24
display_control
Enumeration of display control options.
Definition basic.hpp:287
@ UNINDENT
Definition basic.hpp:287
@ LF
Definition basic.hpp:287
@ HRULE
Definition basic.hpp:287
@ INDENT
Definition basic.hpp:287
The list class represents a linked list.
Definition list.hpp:48
tm_ostream & cout