; Syntax10.Scn.Fnt InfoElemsAlloc#Syntax10.Scn.Fnt$$"Title": Commands extending the System module. "Copyright": 1996, 1997 by Claudio Nieder . This module is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 8FoldElemsNew#Syntax10.Scn.Fnt!! SYSTEM,Log,Modules ,arguments;88#Syntax10.Scn.Fnt** Imps=POINTER TO ARRAY OF Modules.Module;8r8#Syntax10.Scn.Fnt VAR i:LONGINT; imps:Imps; mod:Modules.Module; found:BOOLEAN; BEGIN mod:=Modules.modules; WHILE (mod#NIL) & (moduleName#mod.name) DO mod:=mod.next; END; RETURN mod; END findModule; 8,8#Syntax10.Scn.FntNN VAR i:LONGINT; imps:Imps; mod:Modules.Module; found:BOOLEAN; BEGIN mod:=Modules.modules; WHILE mod#NIL DO imps:=SYSTEM.VAL(Imps,mod.imports); i:=LEN(imps^); found:=FALSE; WHILE ~found &(i>1) DO DEC(i); found:=imps[i]=module; END; IF found THEN freeModule(mod.name); END; mod:=mod.next; END; END freeAbove;818#Syntax10.Scn.FntRR VAR command:Modules.Command; module:Modules.Module; BEGIN arguments.removeExtension(moduleName); module:=findModule(moduleName); IF module=NIL THEN Log.Str(moduleName); Log.Str(" not loaded."); Log.Ln; ELSIF module.refcnt>0 THEN freeAbove(module); IF module.refcnt=0 THEN command:=Modules.ThisCommand(module,"expunge"); IF command#NIL THEN command(); (* Should either remove all its handlers, or cause a trap *) Modules.Free(moduleName,FALSE); Log.Str(moduleName); Log.Str(" unloaded."); Log.Ln; ELSE Modules.Free(moduleName,FALSE); Log.Str(moduleName); Log.Str(" unloaded without expunge."); Log.Ln; END; ELSE Log.Str(moduleName); Log.Str(" still used."); Log.Ln; END; ELSE command:=Modules.ThisCommand(module,"expunge"); IF command#NIL THEN command(); (* Should either remove all its handlers, or cause a trap *) Modules.Free(moduleName,FALSE); Log.Str(moduleName); Log.Str(" unloaded."); Log.Ln; ELSE Modules.Free(moduleName,FALSE); Log.Str(moduleName); Log.Str(" unloaded without expunge."); Log.Ln; END; END; END freeModule;89858 Syntax10b.Scn.Fnt8w8 MODULE sys;  IMPORT TYPE PROCEDURE ^freeModule(moduleName:ARRAY OF CHAR); PROCEDURE findModule(moduleName:ARRAY OF CHAR):Modules.Module; PROCEDURE freeAbove(module:Modules.Module); PROCEDURE freeModule(moduleName:ARRAY OF CHAR); PROCEDURE freeModule2(parameter:arguments.ParameterPtr); BEGIN freeModule(parameter.name^); END freeModule2; PROCEDURE free*; VAR parameter:arguments.ParameterPtr; BEGIN NEW(parameter); arguments.forEachName(freeModule2,parameter); END free; END sys.