]>
Commit | Line | Data |
---|---|---|
1eee94d3 GM |
1 | (* M2RTS.def Implements the run time system facilities of Modula-2. |
2 | ||
83ffe9cd | 3 | Copyright (C) 2001-2023 Free Software Foundation, Inc. |
1eee94d3 GM |
4 | Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. |
5 | ||
6 | This file is part of GNU Modula-2. | |
7 | ||
8 | GNU Modula-2 is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 3, or (at your option) | |
11 | any later version. | |
12 | ||
13 | GNU Modula-2 is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | General Public License for more details. | |
17 | ||
18 | Under Section 7 of GPL version 3, you are granted additional | |
19 | permissions described in the GCC Runtime Library Exception, version | |
20 | 3.1, as published by the Free Software Foundation. | |
21 | ||
22 | You should have received a copy of the GNU General Public License and | |
23 | a copy of the GCC Runtime Library Exception along with this program; | |
24 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
25 | <http://www.gnu.org/licenses/>. *) | |
26 | ||
27 | DEFINITION MODULE M2RTS ; | |
28 | ||
29 | FROM SYSTEM IMPORT ADDRESS ; | |
30 | ||
31 | ||
32 | TYPE | |
33 | ArgCVEnvP = PROCEDURE (INTEGER, ADDRESS, ADDRESS) ; | |
34 | ||
35 | ||
36 | PROCEDURE ConstructModules (applicationmodule: ADDRESS; | |
37 | argc: INTEGER; argv, envp: ADDRESS) ; | |
38 | ||
39 | PROCEDURE DeconstructModules (applicationmodule: ADDRESS; | |
40 | argc: INTEGER; argv, envp: ADDRESS) ; | |
41 | ||
42 | ||
43 | (* | |
44 | RegisterModule - adds module name to the list of outstanding | |
45 | modules which need to have their dependencies | |
46 | explored to determine initialization order. | |
47 | *) | |
48 | ||
49 | PROCEDURE RegisterModule (name: ADDRESS; | |
50 | init, fini: ArgCVEnvP; | |
51 | dependencies: PROC) ; | |
52 | ||
53 | ||
54 | (* | |
55 | RequestDependant - used to specify that modulename is dependant upon | |
56 | module dependantmodule. | |
57 | *) | |
58 | ||
59 | PROCEDURE RequestDependant (modulename, dependantmodule: ADDRESS) ; | |
60 | ||
61 | ||
62 | (* | |
63 | InstallTerminationProcedure - installs a procedure, p, which will | |
64 | be called when the procedure | |
65 | ExecuteTerminationProcedures | |
66 | is invoked. It returns TRUE is the | |
67 | procedure is installed. | |
68 | *) | |
69 | ||
70 | PROCEDURE InstallTerminationProcedure (p: PROC) : BOOLEAN ; | |
71 | ||
72 | ||
73 | (* | |
74 | ExecuteInitialProcedures - executes the initial procedures installed | |
75 | by InstallInitialProcedure. | |
76 | *) | |
77 | ||
78 | PROCEDURE ExecuteInitialProcedures ; | |
79 | ||
80 | ||
81 | (* | |
82 | InstallInitialProcedure - installs a procedure to be executed just | |
83 | before the BEGIN code section of the main | |
84 | program module. | |
85 | *) | |
86 | ||
87 | PROCEDURE InstallInitialProcedure (p: PROC) : BOOLEAN ; | |
88 | ||
89 | ||
90 | (* | |
91 | ExecuteTerminationProcedures - calls each installed termination procedure | |
92 | in reverse order. | |
93 | *) | |
94 | ||
95 | PROCEDURE ExecuteTerminationProcedures ; | |
96 | ||
97 | ||
98 | (* | |
99 | Terminate - provides compatibility for pim. It call exit with | |
100 | the exitcode provided in a prior call to ExitOnHalt | |
101 | (or zero if ExitOnHalt was never called). It does | |
102 | not call ExecuteTerminationProcedures. | |
103 | *) | |
104 | ||
105 | PROCEDURE Terminate <* noreturn *> ; | |
106 | ||
107 | ||
108 | (* | |
109 | HALT - terminate the current program. The procedure Terminate | |
110 | is called before the program is stopped. The parameter | |
111 | exitcode is optional. If the parameter is not supplied | |
112 | HALT will call libc 'abort', otherwise it will exit with | |
113 | the code supplied. Supplying a parameter to HALT has the | |
114 | same effect as calling ExitOnHalt with the same code and | |
115 | then calling HALT with no parameter. | |
116 | *) | |
117 | ||
118 | PROCEDURE HALT ([exitcode: INTEGER = -1]) <* noreturn *> ; | |
119 | ||
120 | ||
121 | (* | |
122 | Halt - provides a more user friendly version of HALT, which takes | |
123 | four parameters to aid debugging. | |
124 | *) | |
125 | ||
126 | PROCEDURE Halt (file: ARRAY OF CHAR; line: CARDINAL; | |
127 | function: ARRAY OF CHAR; description: ARRAY OF CHAR) | |
128 | <* noreturn *> ; | |
129 | ||
130 | ||
131 | (* | |
132 | ExitOnHalt - if HALT is executed then call exit with the exit code, e. | |
133 | *) | |
134 | ||
135 | PROCEDURE ExitOnHalt (e: INTEGER) ; | |
136 | ||
137 | ||
138 | (* | |
139 | ErrorMessage - emits an error message to stderr and then calls exit (1). | |
140 | *) | |
141 | ||
142 | PROCEDURE ErrorMessage (message: ARRAY OF CHAR; | |
143 | file: ARRAY OF CHAR; | |
144 | line: CARDINAL; | |
145 | function: ARRAY OF CHAR) <* noreturn *> ; | |
146 | ||
147 | ||
148 | (* | |
149 | Length - returns the length of a string, a. This is called whenever | |
150 | the user calls LENGTH and the parameter cannot be calculated | |
151 | at compile time. | |
152 | *) | |
153 | ||
154 | PROCEDURE Length (a: ARRAY OF CHAR) : CARDINAL ; | |
155 | ||
156 | ||
157 | (* | |
158 | The following are the runtime exception handler routines. | |
159 | *) | |
160 | ||
161 | PROCEDURE AssignmentException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
162 | PROCEDURE ReturnException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
163 | PROCEDURE IncException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
164 | PROCEDURE DecException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
165 | PROCEDURE InclException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
166 | PROCEDURE ExclException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
167 | PROCEDURE ShiftException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
168 | PROCEDURE RotateException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
169 | PROCEDURE StaticArraySubscriptException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
170 | PROCEDURE DynamicArraySubscriptException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
171 | PROCEDURE ForLoopBeginException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
172 | PROCEDURE ForLoopToException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
173 | PROCEDURE ForLoopEndException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
174 | PROCEDURE PointerNilException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
175 | PROCEDURE NoReturnException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
176 | PROCEDURE CaseException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
177 | PROCEDURE WholeNonPosDivException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
178 | PROCEDURE WholeNonPosModException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
179 | PROCEDURE WholeZeroDivException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
180 | PROCEDURE WholeZeroRemException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
181 | PROCEDURE WholeValueException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
182 | PROCEDURE RealValueException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
183 | PROCEDURE ParameterException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
184 | PROCEDURE NoException (filename: ADDRESS; line, column: CARDINAL; scope, message: ADDRESS) ; | |
185 | ||
186 | ||
187 | END M2RTS. |