<> <> <> DIRECTORY BcdDefs: TYPE USING [VersionStamp], CBinary: TYPE USING [DebugTab], CompilerUtil: TYPE USING [StreamId, TableId, PrintSymbols, PrintBodies], FileSegment: TYPE USING [Pages, nullPages], IO: TYPE USING [Close, int, Put, PutChar, PutRope, STREAM], ListerOps: TYPE USING [], ListerUtil: TYPE USING [ CreateStream, LoadBcd, LoadModule, Message, PutFileID, PutVersions, SetExtension, SetRoutineSymbols, UnknownModule], LiteralOps: TYPE USING [Initialize, Finalize], OSMiscOps: TYPE USING [FindFile, FileError], PrincOps: TYPE USING [PageNumber, PageCount], PrincOpsUtils: TYPE USING [CodeBase, GlobalFrame], Rope: TYPE USING [ROPE], SymbolTable: TYPE USING [Acquire, Base, Release, SetCacheSize], TreeOps: TYPE USING [Finalize, Initialize], UnsafeStorage: TYPE USING [GetSystemUZone]; SLList: PROGRAM IMPORTS CBinary, CompilerUtil, IO, ListerUtil, LiteralOps, OSMiscOps, PrincOpsUtils, SymbolTable, TreeOps, UnsafeStorage EXPORTS CompilerUtil, ListerOps = { OPEN ListerUtil; <> out: IO.STREAM _ NIL; OpenOutput: PROC [output: Rope.ROPE] = { output _ ListerUtil.SetExtension[output, "sl"]; out _ ListerUtil.CreateStream[output]}; CloseOutput: PROC = { IO.Close[out]; out _ NIL}; <> symbols: SymbolTable.Base _ NIL; <> CommandOption: TYPE = {none, bodies, symbols, both}; MapOptions: ARRAY BOOL OF ARRAY BOOL OF CommandOption = [ [$none, $bodies], [$symbols, $both]]; SymbolSeg: TYPE = RECORD [ base: PrincOps.PageNumber, pages: PrincOps.PageCount]; PrintSyms: PROC [ sseg: FileSegment.Pages, option: CommandOption, versions: BOOL] = { SymbolTable.SetCacheSize[0]; -- flush cache symbols _ SymbolTable.Acquire[sseg]; ListerUtil.SetRoutineSymbols[symbols]; IF versions THEN { version, creator: BcdDefs.VersionStamp; version _ symbols.stHandle.version; creator _ symbols.stHandle.creator; ListerUtil.PutVersions[out, @version, @creator]}; TreeOps.Initialize[NIL, NIL]; LiteralOps.Initialize[NIL, UnsafeStorage.GetSystemUZone[]]; IF option = $symbols OR option = $both THEN CompilerUtil.PrintSymbols[NIL, symbols.stHandle.definitionsFile]; IF option = $bodies OR option = $both THEN CompilerUtil.PrintBodies[NIL]; LiteralOps.Finalize[]; TreeOps.Finalize[]; SymbolTable.Release[symbols]; symbols _ NIL}; DoSymbols: PROC [root, output: Rope.ROPE, option: CommandOption] = { OPEN ListerUtil; bcdFile: Rope.ROPE; bcdSeg, sSeg: FileSegment.Pages; bcdFile _ ListerUtil.SetExtension[root, "bcd"]; bcdSeg _ LoadBcd[bcdFile]; IF bcdSeg = FileSegment.nullPages THEN GO TO NoFile; [symbols: sSeg] _ LoadModule[bcdSeg, root ! UnknownModule => {GOTO NoModule}]; IF sSeg = FileSegment.nullPages THEN GO TO NoSymbols; OpenOutput[output]; ListerUtil.PutFileID[out]; PrintSyms[sSeg, option, FALSE]; CloseOutput[]; EXITS NoFile => Message["File could not be opened"]; NoModule => { Message["File does not contain module "]; Message[root]}; NoSymbols => Message["Symbols not available"]}; DoSymbolSegment: PROC [ root: Rope.ROPE, pages: SymbolSeg, option: CommandOption] = { bcdFile: Rope.ROPE; sseg: FileSegment.Pages; bcdFile _ ListerUtil.SetExtension[root, "bcd"]; sseg _ [ file: OSMiscOps.FindFile[bcdFile ! OSMiscOps.FileError => {GO TO NoFile}], span: [pages.base, pages.pages] --! SwapProblem[] => {GO TO BadSegment}--]; OpenOutput[root]; IO.PutRope[out, "Symbol Table in file: "]; IO.PutRope[out, root]; IO.PutRope[out, ", base: "]; IO.Put[out, IO.int[pages.base]]; IO.PutRope[out, ", pages: "]; IO.Put[out, IO.int[pages.pages]]; IO.PutChar[out, '\n]; PrintSyms[sseg, option, TRUE]; EXITS NoFile => Message["FS not found"]; --BadSegment => Message["Bad Segment"]--}; ListSymbols: PUBLIC PROC [root, output: Rope.ROPE, symbols, trees: BOOL] = { DoSymbols[root, output, MapOptions[symbols][trees]]}; <> <> AcquireTable: PUBLIC PROC [id: CompilerUtil.TableId] RETURNS [LONG POINTER] = { RETURN[ IF id # $debug THEN NIL ELSE PrincOpsUtils.CodeBase[LOOPHOLE[PrincOpsUtils.GlobalFrame[CBinary.DebugTab]]]]}; ReleaseTable: PUBLIC PROC [CompilerUtil.TableId] = {}; AcquireStream: PUBLIC PROC [id: CompilerUtil.StreamId] RETURNS [IO.STREAM] = { RETURN[IF id = $log THEN out ELSE NIL]}; ReleaseStream: PUBLIC PROC [CompilerUtil.StreamId] = {}; }.