2
0

browcol.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. {
  2. $Id$
  3. Fake browcol unit
  4. }
  5. unit browcol;
  6. interface
  7. uses
  8. objects;
  9. const
  10. SymbolTypLen : integer=6;
  11. type
  12. { possible types for symtable entries }
  13. tsymtyp = (abstractsym,varsym,typesym,procsym,unitsym,programsym,
  14. constsym,enumsym,typedconstsym,errorsym,syssym,
  15. labelsym,absolutesym,propertysym,funcretsym,
  16. macrosym);
  17. type
  18. TStoreCollection = object(TStringCollection)
  19. function Add(const S: string): PString;
  20. end;
  21. PModuleNameCollection = ^TModuleNameCollection;
  22. TModuleNameCollection = object(TStoreCollection)
  23. end;
  24. PTypeNameCollection = ^TTypeNameCollection;
  25. TTypeNameCollection = object(TStoreCollection)
  26. end;
  27. PSymbolCollection = ^TSymbolCollection;
  28. PSortedSymbolCollection = ^TSortedSymbolCollection;
  29. PReferenceCollection = ^TReferenceCollection;
  30. PReference = ^TReference;
  31. TReference = object(TObject)
  32. FileName : PString;
  33. Position : TPoint;
  34. constructor Init(AFileName: PString; ALine, AColumn: Sw_integer);
  35. function GetFileName: string;
  36. destructor Done; virtual;
  37. end;
  38. PSymbolMemInfo = ^TSymbolMemInfo;
  39. TSymbolMemInfo = record
  40. Addr : longint;
  41. LocalAddr : longint;
  42. Size : longint;
  43. PushSize : longint;
  44. end;
  45. PSymbol = ^TSymbol;
  46. TSymbol = object(TObject)
  47. Name : PString;
  48. Typ : tsymtyp;
  49. Params : PString;
  50. References : PReferenceCollection;
  51. Items : PSymbolCollection;
  52. DType : PString;
  53. VType : PString;
  54. ObjectID : longint;
  55. AncestorID : longint;
  56. Ancestor : PSymbol;
  57. Flags : longint;
  58. MemInfo : PSymbolMemInfo;
  59. constructor Init(const AName: string; ATyp: tsymtyp; AParams: string; AMemInfo: PSymbolMemInfo);
  60. procedure SetMemInfo(const AMemInfo: TSymbolMemInfo);
  61. function GetReferenceCount: Sw_integer;
  62. function GetReference(Index: Sw_integer): PReference;
  63. function GetItemCount: Sw_integer;
  64. function GetItem(Index: Sw_integer): PSymbol;
  65. function GetName: string;
  66. function GetText: string;
  67. function GetTypeName: string;
  68. destructor Done; virtual;
  69. end;
  70. PObjectSymbolCollection = ^TObjectSymbolCollection;
  71. PObjectSymbol = ^TObjectSymbol;
  72. TObjectSymbol = object(TObject)
  73. Parent : PObjectSymbol;
  74. Symbol : PSymbol;
  75. Expanded : boolean;
  76. constructor Init(AParent: PObjectSymbol; ASymbol: PSymbol);
  77. constructor InitName(const AName: string);
  78. function GetName: string;
  79. function GetDescendantCount: sw_integer;
  80. function GetDescendant(Index: sw_integer): PObjectSymbol;
  81. procedure AddDescendant(P: PObjectSymbol);
  82. destructor Done; virtual;
  83. private
  84. Name: PString;
  85. Descendants: PObjectSymbolCollection;
  86. end;
  87. TSymbolCollection = object(TSortedCollection)
  88. function At(Index: Sw_Integer): PSymbol;
  89. procedure Insert(Item: Pointer); virtual;
  90. function LookUp(const S: string; var Idx: sw_integer): string; virtual;
  91. end;
  92. TSortedSymbolCollection = object(TSymbolCollection)
  93. function Compare(Key1, Key2: Pointer): Sw_Integer; virtual;
  94. procedure Insert(Item: Pointer); virtual;
  95. function LookUp(const S: string; var Idx: sw_integer): string; virtual;
  96. end;
  97. PIDSortedSymbolCollection = ^TIDSortedSymbolCollection;
  98. TIDSortedSymbolCollection = object(TSymbolCollection)
  99. function Compare(Key1, Key2: Pointer): Sw_Integer; virtual;
  100. procedure Insert(Item: Pointer); virtual;
  101. function SearchSymbolByID(AID: longint): PSymbol;
  102. end;
  103. TObjectSymbolCollection = object(TSortedCollection)
  104. function Compare(Key1, Key2: Pointer): Sw_Integer; virtual;
  105. function LookUp(const S: string; var Idx: sw_integer): string; virtual;
  106. function At(Index: Sw_Integer): PObjectSymbol;
  107. end;
  108. TReferenceCollection = object(TCollection)
  109. function At(Index: Sw_Integer): PReference;
  110. end;
  111. PSourceFile = ^TSourceFile;
  112. TSourceFile = object(TObject)
  113. SourceFileName: PString;
  114. ObjFileName: PString;
  115. PPUFileName: PString;
  116. constructor Init(ASourceFileName, AObjFileName, APPUFileName: string);
  117. destructor Done; virtual;
  118. function GetSourceFilename: string;
  119. function GetObjFileName: string;
  120. function GetPPUFileName: string;
  121. end;
  122. PSourceFileCollection = ^TSourceFileCollection;
  123. TSourceFileCollection = object(TCollection)
  124. function At(Index: sw_Integer): PSourceFile;
  125. end;
  126. const
  127. Modules : PSymbolCollection = nil;
  128. ModuleNames : PModuleNameCollection = nil;
  129. TypeNames : PTypeNameCollection = nil;
  130. ObjectTree : PObjectSymbol = nil;
  131. SourceFiles : PSourceFileCollection = nil;
  132. function SearchObjectForSymbol(O: PSymbol): PObjectSymbol;
  133. procedure InitBrowserCol;
  134. procedure DoneBrowserCol;
  135. function LoadBrowserCol(S: PStream): boolean;
  136. function StoreBrowserCol(S: PStream): boolean;
  137. procedure RegisterSymbols;
  138. implementation
  139. {****************************************************************************
  140. Helpers
  141. ****************************************************************************}
  142. function GetStr(P: PString): string;
  143. begin
  144. if P=nil then
  145. GetStr:=''
  146. else
  147. GetStr:=P^;
  148. end;
  149. {****************************************************************************
  150. TStoreCollection
  151. ****************************************************************************}
  152. function TStoreCollection.Add(const S: string): PString;
  153. begin
  154. Add:=nil;
  155. end;
  156. {****************************************************************************
  157. TSymbolCollection
  158. ****************************************************************************}
  159. function TSymbolCollection.At(Index: Sw_integer): PSymbol;
  160. begin
  161. At:=nil;
  162. end;
  163. procedure TSymbolCollection.Insert(Item: Pointer);
  164. begin
  165. end;
  166. function TSymbolCollection.LookUp(const S: string; var Idx: sw_integer): string;
  167. begin
  168. Idx:=-1;
  169. LookUp:='';
  170. end;
  171. {****************************************************************************
  172. TReferenceCollection
  173. ****************************************************************************}
  174. function TReferenceCollection.At(Index: Sw_integer): PReference;
  175. begin
  176. At:=nil;
  177. end;
  178. {****************************************************************************
  179. TSortedSymbolCollection
  180. ****************************************************************************}
  181. function TSortedSymbolCollection.Compare(Key1, Key2: Pointer): Sw_Integer;
  182. begin
  183. Compare:=0;
  184. end;
  185. procedure TSortedSymbolCollection.Insert(Item: Pointer);
  186. begin
  187. end;
  188. function TSortedSymbolCollection.LookUp(const S: string; var Idx: sw_integer): string;
  189. begin
  190. Idx:=-1;
  191. LookUp:='';
  192. end;
  193. {****************************************************************************
  194. TIDSortedSymbolCollection
  195. ****************************************************************************}
  196. function TIDSortedSymbolCollection.Compare(Key1, Key2: Pointer): Sw_Integer;
  197. begin
  198. Compare:=0;
  199. end;
  200. procedure TIDSortedSymbolCollection.Insert(Item: Pointer);
  201. begin
  202. end;
  203. function TIDSortedSymbolCollection.SearchSymbolByID(AID: longint): PSymbol;
  204. begin
  205. SearchSymbolByID:=nil;
  206. end;
  207. {****************************************************************************
  208. TObjectSymbolCollection
  209. ****************************************************************************}
  210. function TObjectSymbolCollection.At(Index: Sw_Integer): PObjectSymbol;
  211. begin
  212. At:=nil;
  213. end;
  214. function TObjectSymbolCollection.Compare(Key1, Key2: Pointer): Sw_Integer;
  215. begin
  216. Compare:=0;
  217. end;
  218. function TObjectSymbolCollection.LookUp(const S: string; var Idx: sw_integer): string;
  219. begin
  220. LookUp:='';
  221. end;
  222. {****************************************************************************
  223. TReference
  224. ****************************************************************************}
  225. constructor TReference.Init(AFileName: PString; ALine, AColumn: Sw_integer);
  226. begin
  227. end;
  228. function TReference.GetFileName: string;
  229. begin
  230. GetFileName:='';
  231. end;
  232. destructor TReference.Done;
  233. begin
  234. end;
  235. {****************************************************************************
  236. TSymbol
  237. ****************************************************************************}
  238. constructor TSymbol.Init(const AName: string; ATyp: tsymtyp; AParams: string; AMemInfo: PSymbolMemInfo);
  239. begin
  240. end;
  241. procedure TSymbol.SetMemInfo(const AMemInfo: TSymbolMemInfo);
  242. begin
  243. end;
  244. function TSymbol.GetReferenceCount: Sw_integer;
  245. begin
  246. GetReferenceCount:=0;
  247. end;
  248. function TSymbol.GetReference(Index: Sw_integer): PReference;
  249. begin
  250. GetReference:=nil;
  251. end;
  252. function TSymbol.GetItemCount: Sw_integer;
  253. begin
  254. GetItemCount:=0;
  255. end;
  256. function TSymbol.GetItem(Index: Sw_integer): PSymbol;
  257. begin
  258. GetItem:=nil;
  259. end;
  260. function TSymbol.GetName: string;
  261. begin
  262. GetName:='';
  263. end;
  264. function TSymbol.GetText: string;
  265. begin
  266. GetText:='';
  267. end;
  268. function TSymbol.GetTypeName: string;
  269. begin
  270. GetTypeName:='';
  271. end;
  272. destructor TSymbol.Done;
  273. begin
  274. end;
  275. {*****************************************************************************
  276. TObjectSymbol
  277. *****************************************************************************}
  278. constructor TObjectSymbol.Init(AParent: PObjectSymbol; ASymbol: PSymbol);
  279. begin
  280. end;
  281. constructor TObjectSymbol.InitName(const AName: string);
  282. begin
  283. end;
  284. function TObjectSymbol.GetName: string;
  285. begin
  286. GetName:='';
  287. end;
  288. function TObjectSymbol.GetDescendantCount: sw_integer;
  289. begin
  290. GetDescendantCount:=0;
  291. end;
  292. function TObjectSymbol.GetDescendant(Index: sw_integer): PObjectSymbol;
  293. begin
  294. GetDescendant:=nil;
  295. end;
  296. procedure TObjectSymbol.AddDescendant(P: PObjectSymbol);
  297. begin
  298. end;
  299. destructor TObjectSymbol.Done;
  300. begin
  301. end;
  302. {****************************************************************************
  303. TSourceFile
  304. ****************************************************************************}
  305. constructor TSourceFile.Init(ASourceFileName, AObjFileName, APPUFileName: string);
  306. begin
  307. inherited Init;
  308. SourceFileName:=NewStr(ASourceFileName);
  309. ObjFileName:=NewStr(AObjFileName);
  310. PPUFileName:=NewStr(APPUFileName);
  311. end;
  312. destructor TSourceFile.Done;
  313. begin
  314. inherited Done;
  315. if assigned(SourceFileName) then DisposeStr(SourceFileName);
  316. if assigned(ObjFileName) then DisposeStr(ObjFileName);
  317. if assigned(PPUFileName) then DisposeStr(PPUFileName);
  318. end;
  319. function TSourceFile.GetSourceFilename: string;
  320. begin
  321. GetSourceFilename:=GetStr(SourceFileName);
  322. end;
  323. function TSourceFile.GetObjFileName: string;
  324. begin
  325. GetObjFilename:=GetStr(ObjFileName);
  326. end;
  327. function TSourceFile.GetPPUFileName: string;
  328. begin
  329. GetPPUFilename:=GetStr(PPUFileName);
  330. end;
  331. function TSourceFileCollection.At(Index: sw_Integer): PSourceFile;
  332. begin
  333. At:=inherited At(Index);
  334. end;
  335. {*****************************************************************************
  336. Main Routines
  337. *****************************************************************************}
  338. procedure CreateBrowserCols;
  339. begin
  340. end;
  341. function SearchObjectForSymbol(O: PSymbol): PObjectSymbol;
  342. begin
  343. SearchObjectForSymbol:=nil;
  344. end;
  345. {*****************************************************************************
  346. Load/Store
  347. *****************************************************************************}
  348. function LoadBrowserCol(S: PStream): boolean;
  349. begin
  350. LoadBrowserCol:=true;
  351. end;
  352. function StoreBrowserCol(S: PStream): boolean;
  353. begin
  354. StoreBrowserCol:=true;
  355. end;
  356. procedure RegisterSymbols;
  357. begin
  358. end;
  359. {*****************************************************************************
  360. Initialize
  361. *****************************************************************************}
  362. var
  363. oldexit : pointer;
  364. procedure browcol_exit;{$ifndef FPC}far;{$endif}
  365. begin
  366. exitproc:=oldexit;
  367. if assigned(Modules) then
  368. begin
  369. dispose(Modules,Done);
  370. Modules:=nil;
  371. end;
  372. if assigned(ModuleNames) then
  373. begin
  374. dispose(ModuleNames,Done);
  375. ModuleNames:=nil;
  376. end;
  377. if assigned(TypeNames) then
  378. begin
  379. dispose(TypeNames,Done);
  380. TypeNames:=nil;
  381. end;
  382. end;
  383. procedure InitBrowserCol;
  384. begin
  385. New(Modules, Init(1,1));
  386. New(ModuleNames, Init(1,1));
  387. New(TypeNames, Init(1,1));
  388. end;
  389. procedure DoneBrowserCol;
  390. begin
  391. CreateBrowserCols;
  392. end;
  393. begin
  394. oldexit:=exitproc;
  395. exitproc:=@browcol_exit;
  396. end.
  397. {
  398. $Log$
  399. Revision 1.1 2000-07-13 09:48:33 michael
  400. + Initial import
  401. Revision 1.5 2000/01/27 23:42:33 peter
  402. * storebrowsercol returns boolean now
  403. Revision 1.4 1999/08/17 13:25:16 peter
  404. * updates with the compiler browcol
  405. Revision 1.3 1999/08/05 16:54:35 peter
  406. * win32 fixes
  407. Revision 1.2 1999/04/07 21:55:39 peter
  408. + object support for browser
  409. * html help fixes
  410. * more desktop saving things
  411. * NODEBUG directive to exclude debugger
  412. Revision 1.1 1999/01/28 19:56:12 peter
  413. * moved to include compiler/gdb independent of each other
  414. Revision 1.3 1999/01/22 10:24:16 peter
  415. + gdbcon fake unit
  416. Revision 1.2 1999/01/21 11:54:08 peter
  417. + tools menu
  418. + speedsearch in symbolbrowser
  419. * working run command
  420. Revision 1.1 1999/01/12 15:00:46 peter
  421. * fake unit
  422. }