Lolly 1.4.27
Loading...
Searching...
No Matches
Functions | Variables
basic.cpp File Reference
#include "basic.hpp"
#include "analyze.hpp"
#include "string.hpp"
Include dependency graph for basic.cpp:

Go to the source code of this file.

Functions

int hash (pointer ptr)
 Computes a hash value for a pointer.
 
void tm_throw (const char *msg)
 Function used to throw an exception with a specified error message.
 
void handle_exceptions ()
 Function used to handle exceptions by displaying and clearing the exception message.
 
int new_type_identifier ()
 Generates a new type identifier.
 
tm_ostreamoperator<< (tm_ostream &out, display_control ctrl)
 Output operator for display control options.
 

Variables

string the_exception
 Global variable used to store the current exception message.
 
string the_report
 
static int current_indent = 0
 

Function Documentation

◆ hash()

int hash ( pointer ptr)

Computes a hash value for a pointer.

Parameters
ptrThe pointer to hash.
Returns
The hash value.

Definition at line 17 of file basic.cpp.

17 {
18 return ((int) ((intptr_t) ptr)) + (((int) ((intptr_t) ptr)) % 19);
19}
The list class represents a linked list.
Definition list.hpp:48

◆ tm_throw()

void tm_throw ( const char * msg)

Function used to throw an exception with a specified error message.

Parameters
msgThe error message to throw with the exception.

Definition at line 27 of file basic.cpp.

27 {
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}
string the_exception
Global variable used to store the current exception message.
Definition basic.cpp:22
string the_report
Definition basic.cpp:23
@ LF
Definition basic.hpp:287
tm_ostream & cout

◆ handle_exceptions()

void handle_exceptions ( )

Function used to handle exceptions by displaying and clearing the exception message.

Note
if catching an exception throwed by tm_throw, this function must be appended after catch(){...} block.

Definition at line 38 of file basic.cpp.

38 {
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}
int N(array< T > a)
Get the length of the array.
Definition array.hpp:170

◆ new_type_identifier()

int new_type_identifier ( )

Generates a new type identifier.

Returns
The new type identifier.

Definition at line 53 of file basic.cpp.

53 {
54 static int id= 0;
55 id--;
56 return id;
57}

◆ operator<<()

Output operator for display control options.

Parameters
outThe output stream to write to.
ctrlThe display control option.
Returns
The output stream.

Definition at line 61 of file basic.cpp.

62 {
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}
static int current_indent
Definition basic.cpp:59
@ UNINDENT
Definition basic.hpp:287
@ HRULE
Definition basic.hpp:287
@ INDENT
Definition basic.hpp:287

Variable Documentation

◆ the_exception

string the_exception

Global variable used to store the current exception message.

Definition at line 22 of file basic.cpp.

◆ the_report

string the_report

Definition at line 23 of file basic.cpp.

◆ current_indent

int current_indent = 0
static

Definition at line 59 of file basic.cpp.