| 1 |
(* M2Batch.def implements a queue for modules pending compilation. |
| 2 |
|
| 3 |
Copyright (C) 2001-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 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 |
You should have received a copy of the GNU General Public License |
| 19 |
along with GNU Modula-2; see the file COPYING3. If not see |
| 20 |
<http://www.gnu.org/licenses/>. *) |
| 21 |
|
| 22 |
DEFINITION MODULE M2Batch ; |
| 23 |
|
| 24 |
(* |
| 25 |
Author : Gaius Mulley |
| 26 |
Title : M2Batch |
| 27 |
Date : 29/5/87 |
| 28 |
Description: Implements a queue modules pending compilation. |
| 29 |
MakeSource enters modules for later compilation. |
| 30 |
GetSource collects the next module to be compiled. |
| 31 |
*) |
| 32 |
|
| 33 |
FROM DynamicStrings IMPORT String ; |
| 34 |
FROM NameKey IMPORT Name ; |
| 35 |
EXPORT QUALIFIED MakeDefinitionSource, |
| 36 |
MakeImplementationSource, |
| 37 |
MakeProgramSource, |
| 38 |
GetSource, GetModuleNo, IsModuleKnown, |
| 39 |
AssociateDefinition, GetDefinitionModuleFile, |
| 40 |
AssociateModule, GetModuleFile, Get, |
| 41 |
ForeachSourceModuleDo, IsSourceSeen, IsModuleSeen, |
| 42 |
LookupModule, LookupOuterModule, DisplayModules ; |
| 43 |
|
| 44 |
TYPE |
| 45 |
DoProcedure = PROCEDURE (CARDINAL) ; |
| 46 |
|
| 47 |
|
| 48 |
(* |
| 49 |
MakeDefinitionSource - is given a Name, n, which is used to create a Definition |
| 50 |
module. |
| 51 |
The Definition Module will be placed onto the |
| 52 |
compilation pending queue if it has not yet been |
| 53 |
compiled. |
| 54 |
If the module has been compiled then no action is |
| 55 |
taken. The Module Sym is returned. |
| 56 |
*) |
| 57 |
|
| 58 |
PROCEDURE MakeDefinitionSource (tok: CARDINAL; n: Name) : CARDINAL ; |
| 59 |
|
| 60 |
|
| 61 |
(* |
| 62 |
MakeImplementationSource - is given a Name, n, which is used to create an |
| 63 |
implementation module. |
| 64 |
The implementation Module will be placed onto |
| 65 |
the compilation pending |
| 66 |
queue if it has not yet been compiled. |
| 67 |
If the module has been compiled then no |
| 68 |
action is taken. The Module Sym is returned. |
| 69 |
*) |
| 70 |
|
| 71 |
PROCEDURE MakeImplementationSource (tok: CARDINAL; n: Name) : CARDINAL ; |
| 72 |
|
| 73 |
|
| 74 |
(* |
| 75 |
MakeProgramSource - is given a Name, n, which is used to create a program module. |
| 76 |
The program module will be placed onto the compilation |
| 77 |
pending queue if it has not yet been compiled. |
| 78 |
If the module has been compiled then no action is taken. |
| 79 |
The Module Sym is returned. |
| 80 |
*) |
| 81 |
|
| 82 |
PROCEDURE MakeProgramSource (tok: CARDINAL; n: Name) : CARDINAL ; |
| 83 |
|
| 84 |
|
| 85 |
(* |
| 86 |
GetSource - returns with the symbol Sym of the next module to be compiled. |
| 87 |
If Sym returns with value NulSym then no module should be |
| 88 |
compiled. |
| 89 |
*) |
| 90 |
|
| 91 |
PROCEDURE GetSource () : CARDINAL ; |
| 92 |
|
| 93 |
|
| 94 |
(* |
| 95 |
GetModuleNo - returns with symbol number of the module which was |
| 96 |
the nth module to be read in Pass 1. |
| 97 |
The modules are numbered from 1..n |
| 98 |
*) |
| 99 |
|
| 100 |
PROCEDURE GetModuleNo (nth: CARDINAL) : CARDINAL ; |
| 101 |
|
| 102 |
|
| 103 |
(* |
| 104 |
IsModuleKnown - returns TRUE if the Name, n, matches a module. |
| 105 |
*) |
| 106 |
|
| 107 |
PROCEDURE IsModuleKnown (n: Name) : BOOLEAN ; |
| 108 |
|
| 109 |
|
| 110 |
(* |
| 111 |
AssociateDefinition - associate the source file, filename, with the definition module, |
| 112 |
Sym. |
| 113 |
*) |
| 114 |
|
| 115 |
PROCEDURE AssociateDefinition (filename: String; Sym: CARDINAL) : String ; |
| 116 |
|
| 117 |
|
| 118 |
(* |
| 119 |
GetDefinitionModuleFile - returns the filename associated with the definition module, Sym. |
| 120 |
It may return a temporary preprocessed file. |
| 121 |
*) |
| 122 |
|
| 123 |
PROCEDURE GetDefinitionModuleFile (Sym: CARDINAL) : String ; |
| 124 |
|
| 125 |
|
| 126 |
(* |
| 127 |
AssociateModule - associate the source file, filename, with the implementation/program |
| 128 |
module, Sym. |
| 129 |
*) |
| 130 |
|
| 131 |
PROCEDURE AssociateModule (filename: String; Sym: CARDINAL) : String ; |
| 132 |
|
| 133 |
|
| 134 |
(* |
| 135 |
GetModuleFile - returns the filename associated with the implementation/program module, Sym. |
| 136 |
It may return a temporary preprocessed file. |
| 137 |
*) |
| 138 |
|
| 139 |
PROCEDURE GetModuleFile (Sym: CARDINAL) : String ; |
| 140 |
|
| 141 |
|
| 142 |
(* |
| 143 |
ForeachSourceModuleDo - call each procedure, p, for which there is a known |
| 144 |
source file. |
| 145 |
*) |
| 146 |
|
| 147 |
PROCEDURE ForeachSourceModuleDo (p: DoProcedure) ; |
| 148 |
|
| 149 |
|
| 150 |
(* |
| 151 |
IsSourceSeen - returns TRUE if the source for module, sym, has been seen. |
| 152 |
*) |
| 153 |
|
| 154 |
PROCEDURE IsSourceSeen (sym: CARDINAL) : BOOLEAN ; |
| 155 |
|
| 156 |
|
| 157 |
(* |
| 158 |
IsModuleSeen - returns TRUE if the source for module, name, has been seen. |
| 159 |
*) |
| 160 |
|
| 161 |
PROCEDURE IsModuleSeen (n: Name) : BOOLEAN ; |
| 162 |
|
| 163 |
|
| 164 |
(* |
| 165 |
LookupModule - looks up a module in the current scope, if a module does not exist |
| 166 |
then it creates a DefImp module. |
| 167 |
*) |
| 168 |
|
| 169 |
PROCEDURE LookupModule (tok: CARDINAL; n: Name) : CARDINAL ; |
| 170 |
|
| 171 |
|
| 172 |
(* |
| 173 |
LookupOuterModule - looks up a module in the order of: current scope, then outer scope, finally if a |
| 174 |
module does not exist then it creates a DefImp module. |
| 175 |
*) |
| 176 |
|
| 177 |
PROCEDURE LookupOuterModule (tok: CARDINAL; n: Name) : CARDINAL ; |
| 178 |
|
| 179 |
|
| 180 |
(* |
| 181 |
Get - returns the module symbol matching name, n. |
| 182 |
*) |
| 183 |
|
| 184 |
PROCEDURE Get (n: Name) : CARDINAL ; |
| 185 |
|
| 186 |
|
| 187 |
(* |
| 188 |
DisplayModules - a debugging routine to textually emit the names of modules in the DoneQ. |
| 189 |
*) |
| 190 |
|
| 191 |
PROCEDURE DisplayModules ; |
| 192 |
|
| 193 |
|
| 194 |
END M2Batch. |