def.pas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. {
  2. pas2jni - JNI bridge generator for Pascal.
  3. Copyright (c) 2013 by Yury Sidorov.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************}
  16. unit def;
  17. {$mode objfpc}{$H+}
  18. interface
  19. uses
  20. Classes, SysUtils, contnrs;
  21. type
  22. TDefType = (dtNone, dtUnit, dtClass, dtProc, dtField, dtProp, dtParam, dtVar,
  23. dtType, dtConst, dtProcType, dtEnum, dtSet, dtPointer, dtArray,
  24. dtJniObject, dtJniEnv, dtClassRef);
  25. TDefClass = class of TDef;
  26. { TDef }
  27. TDef = class
  28. private
  29. FAliasName: string;
  30. FRefCnt: integer;
  31. FItems: TObjectList;
  32. FInSetUsed: boolean;
  33. procedure CheckItems;
  34. function GetAliasName: string;
  35. function GetCount: integer;
  36. function GetIsUsed: boolean;
  37. function GetItem(Index: Integer): TDef;
  38. procedure SetItem(Index: Integer; const AValue: TDef);
  39. protected
  40. procedure SetIsUsed(const AValue: boolean); virtual;
  41. function ResolveDef(d: TDef; ExpectedClass: TDefClass = nil): TDef;
  42. procedure AddRef;
  43. procedure DecRef;
  44. procedure SetExtUsed(ExtDef: TDef; AUsed: boolean; var HasRef: boolean);
  45. function ShouldUseChild(d: TDef): boolean; virtual;
  46. public
  47. DefType: TDefType;
  48. DefId: integer;
  49. SymId: integer;
  50. Name: string;
  51. Parent: TDef;
  52. Tag: integer;
  53. IsPrivate: boolean;
  54. constructor Create; virtual; overload;
  55. constructor Create(AParent: TDef; AType: TDefType); virtual; overload;
  56. destructor Destroy; override;
  57. function Add(ADef: TDef): integer;
  58. function Insert(Index: integer; ADef: TDef): integer;
  59. function FindDef(ADefId: integer; Recursive: boolean = True): TDef;
  60. procedure ResolveDefs; virtual;
  61. procedure SetNotUsed;
  62. function GetRefDef: TDef; virtual;
  63. function GetRefDef2: TDef; virtual;
  64. property Items[Index: Integer]: TDef read GetItem write SetItem; default;
  65. property Count: integer read GetCount;
  66. property IsUsed: boolean read GetIsUsed write SetIsUsed;
  67. property RefCnt: integer read FRefCnt;
  68. property AliasName: string read GetAliasName write FAliasName;
  69. end;
  70. TClassType = (ctClass, ctInterface, ctObject, ctRecord);
  71. { TClassDef }
  72. TClassDef = class(TDef)
  73. private
  74. FHasClassRef: boolean;
  75. protected
  76. procedure SetIsUsed(const AValue: boolean); override;
  77. function ShouldUseChild(d: TDef): boolean; override;
  78. public
  79. CType: TClassType;
  80. AncestorClass: TClassDef;
  81. HasAbstractMethods: boolean;
  82. HasReplacedItems: boolean;
  83. ImplementsReplacedItems: boolean;
  84. Size: integer;
  85. IID: string;
  86. procedure ResolveDefs; override;
  87. function GetRefDef: TDef; override;
  88. end;
  89. TBasicType = (btVoid, btByte, btShortInt, btWord, btSmallInt, btLongWord, btLongInt, btInt64,
  90. btSingle, btDouble, btString, btWideString, btBoolean, btChar, btWideChar, btEnum,
  91. btGuid);
  92. { TTypeDef }
  93. TTypeDef = class(TDef)
  94. protected
  95. procedure SetIsUsed(const AValue: boolean); override;
  96. public
  97. BasicType: TBasicType;
  98. end;
  99. { TPointerDef }
  100. TPointerDef = class(TDef)
  101. private
  102. FHasPtrRef: boolean;
  103. protected
  104. procedure SetIsUsed(const AValue: boolean); override;
  105. public
  106. PtrType: TDef;
  107. procedure ResolveDefs; override;
  108. function IsObjPtr: boolean;
  109. function GetRefDef: TDef; override;
  110. end;
  111. { TReplDef }
  112. TReplDef = class(TDef)
  113. protected
  114. procedure SetIsUsed(const AValue: boolean); override;
  115. public
  116. IsReplaced: boolean;
  117. IsReplImpl: boolean;
  118. ReplacedItem: TReplDef;
  119. function CanReplaced: boolean; virtual;
  120. function IsReplacedBy(d: TReplDef): boolean; virtual;
  121. procedure CheckReplaced;
  122. end;
  123. TVarOption = (voRead, voWrite, voConst, voVar, voOut);
  124. TVarOptions = set of TVarOption;
  125. { TVarDef }
  126. TVarDef = class(TReplDef)
  127. private
  128. FHasTypeRef: boolean;
  129. protected
  130. procedure SetIsUsed(const AValue: boolean); override;
  131. public
  132. VarOpt: TVarOptions;
  133. VarType: TDef;
  134. constructor Create; override;
  135. procedure ResolveDefs; override;
  136. function IsReplacedBy(d: TReplDef): boolean; override;
  137. function CanReplaced: boolean; override;
  138. function GetRefDef: TDef; override;
  139. end;
  140. TProcType = (ptProcedure, ptFunction, ptConstructor, ptDestructor);
  141. TProcOption = (poOverride, poOverload, poMethodPtr, poPrivate, poProtected, poClassMethod);
  142. TProcOptions = set of TProcOption;
  143. { TProcDef }
  144. TProcDef = class(TReplDef)
  145. private
  146. FHasRetTypeRef: boolean;
  147. protected
  148. procedure SetIsUsed(const AValue: boolean); override;
  149. function ShouldUseChild(d: TDef): boolean; override;
  150. public
  151. ProcType: TProcType;
  152. ReturnType: TDef;
  153. ProcOpt: TProcOptions;
  154. procedure ResolveDefs; override;
  155. function IsReplacedBy(d: TReplDef): boolean; override;
  156. function CanReplaced: boolean; override;
  157. function GetRefDef: TDef; override;
  158. end;
  159. TUnitDef = class(TDef)
  160. public
  161. OS: string;
  162. CPU: string;
  163. IntfCRC: string;
  164. PPUVer: integer;
  165. UsedUnits: array of TUnitDef;
  166. Processed: boolean;
  167. IsUnitUsed: boolean;
  168. end;
  169. TConstDef = class(TVarDef)
  170. public
  171. Value: string;
  172. end;
  173. { TSetDef }
  174. TSetDef = class(TDef)
  175. private
  176. FHasElTypeRef: boolean;
  177. protected
  178. procedure SetIsUsed(const AValue: boolean); override;
  179. public
  180. Size: integer;
  181. Base: integer;
  182. ElMax: integer;
  183. ElType: TTypeDef;
  184. function GetRefDef: TDef; override;
  185. end;
  186. { TArrayDef }
  187. TArrayDef = class(TDef)
  188. private
  189. FHasElTypeRef: boolean;
  190. FHasRTypeRef: boolean;
  191. protected
  192. procedure SetIsUsed(const AValue: boolean); override;
  193. public
  194. ElType: TDef;
  195. RangeType: TDef;
  196. RangeLow, RangeHigh: integer;
  197. function GetRefDef: TDef; override;
  198. function GetRefDef2: TDef; override;
  199. end;
  200. { TClassRefDef }
  201. TClassRefDef = class(TDef)
  202. private
  203. FHasClassRef: boolean;
  204. protected
  205. procedure SetIsUsed(const AValue: boolean); override;
  206. public
  207. ClassRef: TDef;
  208. procedure ResolveDefs; override;
  209. function GetRefDef: TDef; override;
  210. end;
  211. const
  212. ReplDefs = [dtField, dtProp, dtProc];
  213. var
  214. OnCanUseDef: function (def, refdef: TDef): boolean;
  215. implementation
  216. function IsSameType(t1, t2: TDef): boolean;
  217. begin
  218. Result:=t1 = t2;
  219. if Result then
  220. exit;
  221. if (t1 = nil) or (t2 = nil) or (t1.DefType <> t2.DefType) then
  222. exit;
  223. if t1.DefType <> dtType then
  224. exit;
  225. Result:=TTypeDef(t1).BasicType = TTypeDef(t2).BasicType;
  226. end;
  227. { TClassRefDef }
  228. procedure TClassRefDef.SetIsUsed(const AValue: boolean);
  229. begin
  230. inherited SetIsUsed(AValue);
  231. SetExtUsed(ClassRef, AValue, FHasClassRef);
  232. end;
  233. procedure TClassRefDef.ResolveDefs;
  234. begin
  235. inherited ResolveDefs;
  236. ClassRef:=ResolveDef(ClassRef);
  237. end;
  238. function TClassRefDef.GetRefDef: TDef;
  239. begin
  240. Result:=ClassRef;
  241. end;
  242. { TArrayDef }
  243. procedure TArrayDef.SetIsUsed(const AValue: boolean);
  244. begin
  245. inherited SetIsUsed(AValue);
  246. SetExtUsed(ElType, AValue, FHasElTypeRef);
  247. SetExtUsed(RangeType, AValue, FHasRTypeRef);
  248. end;
  249. function TArrayDef.GetRefDef: TDef;
  250. begin
  251. Result:=ElType;
  252. end;
  253. function TArrayDef.GetRefDef2: TDef;
  254. begin
  255. Result:=RangeType;
  256. end;
  257. { TPointerDef }
  258. procedure TPointerDef.SetIsUsed(const AValue: boolean);
  259. begin
  260. if IsObjPtr then begin
  261. inherited SetIsUsed(AValue);
  262. SetExtUsed(PtrType, AValue, FHasPtrRef);
  263. end
  264. else
  265. if AValue then
  266. AddRef
  267. else
  268. DecRef;
  269. end;
  270. procedure TPointerDef.ResolveDefs;
  271. begin
  272. inherited ResolveDefs;
  273. PtrType:=ResolveDef(PtrType);
  274. end;
  275. function TPointerDef.IsObjPtr: boolean;
  276. begin
  277. Result:=(PtrType <> nil) and (PtrType.DefType in [dtClass]);
  278. end;
  279. function TPointerDef.GetRefDef: TDef;
  280. begin
  281. Result:=PtrType;
  282. end;
  283. { TReplDef }
  284. procedure TReplDef.SetIsUsed(const AValue: boolean);
  285. var
  286. i: integer;
  287. begin
  288. i:=RefCnt;
  289. inherited SetIsUsed(AValue);
  290. if (i = 0) and (RefCnt > 0) then
  291. CheckReplaced;
  292. end;
  293. function TReplDef.CanReplaced: boolean;
  294. begin
  295. Result:=not (IsPrivate or (Parent = nil) or (Parent.DefType <> dtClass));
  296. end;
  297. function TReplDef.IsReplacedBy(d: TReplDef): boolean;
  298. begin
  299. Result:=d.CanReplaced and (CompareText(Name, d.Name) = 0);
  300. end;
  301. procedure TReplDef.CheckReplaced;
  302. function _Scan(cls: TClassDef): boolean;
  303. var
  304. i: integer;
  305. d: TReplDef;
  306. c: TClassDef;
  307. begin
  308. Result:=False;
  309. c:=cls.AncestorClass;
  310. if c = nil then
  311. exit;
  312. for i:=0 to c.Count - 1 do begin
  313. d:=TReplDef(c[i]);
  314. if (d.DefType in ReplDefs) and IsReplacedBy(d) then begin
  315. d.IsReplaced:=True;
  316. ReplacedItem:=d;
  317. Result:=True;
  318. break;
  319. end;
  320. end;
  321. if not Result then
  322. Result:=_Scan(c);
  323. if Result then begin
  324. cls.ImplementsReplacedItems:=True;
  325. c.HasReplacedItems:=True;
  326. end;
  327. end;
  328. begin
  329. if not CanReplaced then
  330. exit;
  331. if _Scan(TClassDef(Parent)) then
  332. IsReplImpl:=True;
  333. end;
  334. { TSetDef }
  335. procedure TSetDef.SetIsUsed(const AValue: boolean);
  336. begin
  337. inherited SetIsUsed(AValue);
  338. SetExtUsed(ElType, AValue, FHasElTypeRef);
  339. end;
  340. function TSetDef.GetRefDef: TDef;
  341. begin
  342. Result:=ElType;
  343. end;
  344. { TTypeDef }
  345. procedure TTypeDef.SetIsUsed(const AValue: boolean);
  346. begin
  347. if BasicType in [btEnum] then
  348. inherited SetIsUsed(AValue)
  349. else
  350. if AValue then
  351. AddRef
  352. else
  353. DecRef;
  354. end;
  355. { TProcDef }
  356. procedure TProcDef.SetIsUsed(const AValue: boolean);
  357. var
  358. i: integer;
  359. begin
  360. if IsPrivate then
  361. exit;
  362. if AValue and (RefCnt = 0) then begin
  363. for i:=0 to Count - 1 do
  364. if (Items[i].DefType = dtParam) and (TVarDef(Items[i]).VarType = nil) then
  365. exit; // If procedure has unsupported parameters, don't use it
  366. end;
  367. inherited SetIsUsed(AValue);
  368. if ReturnType <> Parent then
  369. SetExtUsed(ReturnType, AValue, FHasRetTypeRef);
  370. end;
  371. function TProcDef.ShouldUseChild(d: TDef): boolean;
  372. begin
  373. Result:=d.DefType in [dtParam];
  374. end;
  375. procedure TProcDef.ResolveDefs;
  376. begin
  377. inherited ResolveDefs;
  378. ReturnType:=ResolveDef(ReturnType);
  379. end;
  380. function TProcDef.IsReplacedBy(d: TReplDef): boolean;
  381. var
  382. i: integer;
  383. p: TProcDef;
  384. begin
  385. Result:=False;
  386. if d.DefType <> dtProc then
  387. exit;
  388. p:=TProcDef(d);
  389. if (Count = p.Count) and inherited IsReplacedBy(p) then begin
  390. // Check parameter types
  391. for i:=0 to Count - 1 do
  392. if not IsSameType(TVarDef(Items[i]).VarType, TVarDef(p.Items[i]).VarType) then
  393. exit;
  394. Result:=True;
  395. end;
  396. end;
  397. function TProcDef.CanReplaced: boolean;
  398. begin
  399. Result:=inherited CanReplaced and (ProcType = ptFunction);
  400. end;
  401. function TProcDef.GetRefDef: TDef;
  402. begin
  403. Result:=ReturnType;
  404. end;
  405. { TClassDef }
  406. procedure TClassDef.SetIsUsed(const AValue: boolean);
  407. begin
  408. inherited SetIsUsed(AValue);
  409. SetExtUsed(AncestorClass, AValue, FHasClassRef);
  410. end;
  411. function TClassDef.ShouldUseChild(d: TDef): boolean;
  412. begin
  413. Result:=d.DefType in [dtProc, dtField, dtProp];
  414. end;
  415. procedure TClassDef.ResolveDefs;
  416. begin
  417. inherited ResolveDefs;
  418. AncestorClass:=TClassDef(ResolveDef(AncestorClass, TClassDef));
  419. end;
  420. function TClassDef.GetRefDef: TDef;
  421. begin
  422. Result:=AncestorClass;
  423. end;
  424. { TVarDef }
  425. procedure TVarDef.SetIsUsed(const AValue: boolean);
  426. var
  427. ptr, d: TDef;
  428. begin
  429. if IsPrivate then
  430. exit;
  431. inherited SetIsUsed(AValue);
  432. // Detect circular pointers
  433. if (VarType <> nil) and (VarType.DefType = dtPointer) and (VarType.RefCnt > 0) then begin
  434. ptr:=TPointerDef(VarType).PtrType;
  435. if ptr <> nil then begin
  436. d:=Self;
  437. while d <> nil do begin
  438. if d = ptr then
  439. exit;
  440. d:=d.Parent;;
  441. end;
  442. end;
  443. end;
  444. SetExtUsed(VarType, AValue, FHasTypeRef);
  445. end;
  446. procedure TVarDef.ResolveDefs;
  447. begin
  448. inherited ResolveDefs;
  449. VarType:=ResolveDef(VarType);
  450. end;
  451. function TVarDef.IsReplacedBy(d: TReplDef): boolean;
  452. begin
  453. Result:=(d.DefType in [dtProp, dtField]) and not IsSameType(VarType, TVarDef(d).VarType) and inherited IsReplacedBy(d);
  454. end;
  455. function TVarDef.CanReplaced: boolean;
  456. begin
  457. Result:=(voRead in VarOpt) and inherited CanReplaced;
  458. end;
  459. function TVarDef.GetRefDef: TDef;
  460. begin
  461. Result:=VarType;
  462. end;
  463. constructor TVarDef.Create;
  464. begin
  465. inherited Create;
  466. VarOpt:=[voRead, voWrite];
  467. end;
  468. { TDef }
  469. procedure TDef.CheckItems;
  470. begin
  471. if FItems = nil then
  472. FItems:=TObjectList.Create(True);
  473. end;
  474. function TDef.GetAliasName: string;
  475. begin
  476. if FAliasName <> '' then
  477. Result:=FAliasName
  478. else
  479. Result:=Name;
  480. end;
  481. function TDef.GetCount: integer;
  482. begin
  483. if FItems = nil then
  484. Result:=0
  485. else begin
  486. CheckItems;
  487. Result:=FItems.Count;
  488. end;
  489. end;
  490. function TDef.GetIsUsed: boolean;
  491. begin
  492. Result:=FRefCnt > 0;
  493. end;
  494. function TDef.GetItem(Index: Integer): TDef;
  495. begin
  496. CheckItems;
  497. Result:=TDef(FItems[Index]);
  498. end;
  499. procedure TDef.SetIsUsed(const AValue: boolean);
  500. var
  501. i: integer;
  502. f: boolean;
  503. d: TDef;
  504. begin
  505. if FInSetUsed or (DefType = dtNone) or IsPrivate then
  506. exit;
  507. if AValue then begin
  508. if Assigned(OnCanUseDef) and not OnCanUseDef(Self, Parent) then
  509. exit;
  510. AddRef;
  511. f:=FRefCnt = 1;
  512. end
  513. else begin
  514. if FRefCnt = 0 then
  515. exit;
  516. DecRef;
  517. f:=FRefCnt = 0;
  518. end;
  519. if f then begin
  520. // Update used mark of children only once
  521. FInSetUsed:=True;
  522. try
  523. for i:=0 to Count - 1 do begin
  524. d:=Items[i];
  525. if ShouldUseChild(d) then
  526. d.IsUsed:=AValue;
  527. end;
  528. finally
  529. FInSetUsed:=False;
  530. end;
  531. // Update parent's used mark
  532. if (Parent <> nil) and (Parent.DefType = dtUnit) then
  533. if AValue then
  534. Parent.AddRef
  535. else
  536. Parent.DecRef;
  537. end;
  538. end;
  539. function TDef.ResolveDef(d: TDef; ExpectedClass: TDefClass): TDef;
  540. begin
  541. if (d = nil) or (d.DefType <> dtNone) then
  542. Result:=d
  543. else begin
  544. Result:=d.Parent.FindDef(d.DefId);
  545. if (ExpectedClass <> nil) and (Result <> nil) then
  546. if not (Result is ExpectedClass) then
  547. raise Exception.CreateFmt('Unexpected class. Expected: %s, got: %s', [ExpectedClass.ClassName, Result.ClassName]);
  548. end;
  549. end;
  550. procedure TDef.AddRef;
  551. begin
  552. Inc(FRefCnt);
  553. end;
  554. procedure TDef.DecRef;
  555. begin
  556. if FRefCnt > 0 then
  557. Dec(FRefCnt);
  558. end;
  559. procedure TDef.SetExtUsed(ExtDef: TDef; AUsed: boolean; var HasRef: boolean);
  560. var
  561. OldRefCnt: integer;
  562. begin
  563. if ExtDef = nil then
  564. exit;
  565. if AUsed then begin
  566. if HasRef then
  567. exit;
  568. if Assigned(OnCanUseDef) and not OnCanUseDef(ExtDef, Self) then
  569. exit;
  570. OldRefCnt:=ExtDef.RefCnt;
  571. ExtDef.IsUsed:=True;
  572. HasRef:=OldRefCnt <> ExtDef.RefCnt;
  573. end
  574. else
  575. if HasRef and not IsUsed then begin
  576. ExtDef.IsUsed:=False;
  577. HasRef:=False;
  578. end;
  579. end;
  580. function TDef.ShouldUseChild(d: TDef): boolean;
  581. begin
  582. Result:=True;
  583. end;
  584. procedure TDef.SetItem(Index: Integer; const AValue: TDef);
  585. begin
  586. CheckItems;
  587. FItems[Index]:=AValue;
  588. end;
  589. constructor TDef.Create;
  590. begin
  591. DefId:=-1;
  592. DefType:=dtNone;
  593. end;
  594. constructor TDef.Create(AParent: TDef; AType: TDefType);
  595. begin
  596. Create;
  597. if AParent <> nil then
  598. AParent.Add(Self);
  599. DefType:=AType;
  600. end;
  601. destructor TDef.Destroy;
  602. begin
  603. FreeAndNil(FItems);
  604. if (Parent <> nil) and (Parent.FItems <> nil) then begin
  605. Parent.FItems.OwnsObjects:=False;
  606. try
  607. Parent.FItems.Remove(Self);
  608. finally
  609. Parent.FItems.OwnsObjects:=True;
  610. end;
  611. end;
  612. inherited Destroy;
  613. end;
  614. function TDef.Add(ADef: TDef): integer;
  615. begin
  616. Result:=Insert(Count, ADef);
  617. end;
  618. function TDef.Insert(Index: integer; ADef: TDef): integer;
  619. begin
  620. CheckItems;
  621. Result:=Index;
  622. FItems.Insert(Result, ADef);
  623. ADef.Parent:=Self;
  624. end;
  625. function TDef.FindDef(ADefId: integer; Recursive: boolean): TDef;
  626. function _Find(d: TDef): TDef;
  627. var
  628. i: integer;
  629. begin
  630. Result:=nil;
  631. for i:=0 to d.Count - 1 do
  632. with d[i] do begin
  633. if (DefType <> dtNone) and (DefId = ADefId) then begin
  634. Result:=d[i];
  635. break;
  636. end;
  637. if Recursive and (Count > 0) then begin
  638. Result:=_Find(d[i]);
  639. if Result <> nil then
  640. break;
  641. end;
  642. end;
  643. end;
  644. begin
  645. Result:=_Find(Self);
  646. end;
  647. procedure TDef.ResolveDefs;
  648. var
  649. i: integer;
  650. begin
  651. for i:=0 to Count - 1 do
  652. Items[i].ResolveDefs;
  653. end;
  654. procedure TDef.SetNotUsed;
  655. begin
  656. if FRefCnt = 0 then
  657. exit;
  658. FRefCnt:=1;
  659. IsUsed:=False;
  660. end;
  661. function TDef.GetRefDef: TDef;
  662. begin
  663. Result:=nil;
  664. end;
  665. function TDef.GetRefDef2: TDef;
  666. begin
  667. Result:=nil;
  668. end;
  669. end.