1 (* M2Batch.def implements a queue for modules pending compilation.
3 Copyright (C) 2001-2022 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
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)
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.
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/>. *)
22 DEFINITION MODULE M2Batch ;
28 Description: Implements a queue modules pending compilation.
29 MakeSource enters modules for later compilation.
30 GetSource collects the next module to be compiled.
33 FROM DynamicStrings IMPORT String ;
34 FROM NameKey IMPORT Name ;
35 EXPORT QUALIFIED MakeDefinitionSource,
36 MakeImplementationSource,
38 GetSource, GetModuleNo, IsModuleKnown,
39 AssociateDefinition, GetDefinitionModuleFile,
40 AssociateModule, GetModuleFile, Get,
41 ForeachSourceModuleDo, IsSourceSeen, IsModuleSeen,
42 LookupModule, LookupOuterModule, DisplayModules ;
45 DoProcedure = PROCEDURE (CARDINAL) ;
49 MakeDefinitionSource - is given a Name, n, which is used to create a Definition
51 The Definition Module will be placed onto the
52 compilation pending queue if it has not yet been
54 If the module has been compiled then no action is
55 taken. The Module Sym is returned.
58 PROCEDURE MakeDefinitionSource (tok: CARDINAL; n: Name) : CARDINAL ;
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.
71 PROCEDURE MakeImplementationSource (tok: CARDINAL; n: Name) : CARDINAL ;
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.
82 PROCEDURE MakeProgramSource (tok: CARDINAL; n: Name) : CARDINAL ;
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
91 PROCEDURE GetSource () : CARDINAL ;
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
100 PROCEDURE GetModuleNo (nth: CARDINAL) : CARDINAL ;
104 IsModuleKnown - returns TRUE if the Name, n, matches a module.
107 PROCEDURE IsModuleKnown (n: Name) : BOOLEAN ;
111 AssociateDefinition - associate the source file, filename, with the definition module,
115 PROCEDURE AssociateDefinition (filename: String; Sym: CARDINAL) : String ;
119 GetDefinitionModuleFile - returns the filename associated with the definition module, Sym.
120 It may return a temporary preprocessed file.
123 PROCEDURE GetDefinitionModuleFile (Sym: CARDINAL) : String ;
127 AssociateModule - associate the source file, filename, with the implementation/program
131 PROCEDURE AssociateModule (filename: String; Sym: CARDINAL) : String ;
135 GetModuleFile - returns the filename associated with the implementation/program module, Sym.
136 It may return a temporary preprocessed file.
139 PROCEDURE GetModuleFile (Sym: CARDINAL) : String ;
143 ForeachSourceModuleDo - call each procedure, p, for which there is a known
147 PROCEDURE ForeachSourceModuleDo (p: DoProcedure) ;
151 IsSourceSeen - returns TRUE if the source for module, sym, has been seen.
154 PROCEDURE IsSourceSeen (sym: CARDINAL) : BOOLEAN ;
158 IsModuleSeen - returns TRUE if the source for module, name, has been seen.
161 PROCEDURE IsModuleSeen (n: Name) : BOOLEAN ;
165 LookupModule - looks up a module in the current scope, if a module does not exist
166 then it creates a DefImp module.
169 PROCEDURE LookupModule (tok: CARDINAL; n: Name) : CARDINAL ;
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.
177 PROCEDURE LookupOuterModule (tok: CARDINAL; n: Name) : CARDINAL ;
181 Get - returns the module symbol matching name, n.
184 PROCEDURE Get (n: Name) : CARDINAL ;
188 DisplayModules - a debugging routine to textually emit the names of modules in the DoneQ.
191 PROCEDURE DisplayModules ;