~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to components/codetools/finddeclarationcache.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
    procedure ConsistencyCheck;
80
80
    property Tool: TPascalParserTool read FTool;
81
81
    property Complete: boolean read FComplete write SetComplete;
82
 
    property Items: TAVLTree read FItems;
 
82
    property Items: TAVLTree read FItems; // Tree of PInterfaceIdentCacheEntry
83
83
    function CalcMemSize: PtrUInt;
84
84
  end;
85
85
 
102
102
      These are: class, interface, proc, record, withstatement
103
103
      
104
104
      Because node caches can store information of used units, the cache must be
105
 
      deleted every time a used unit is changed. Currently all node caches are
106
 
      resetted every time the GlobalWriteLock increases.
107
 
 
 
105
      deleted every time a used unit is changed.
108
106
  }
109
107
const
110
108
  AllNodeCacheDescs =
111
 
    AllClasses+[ctnProcedure, ctnRecordType, ctnWithStatement];
 
109
    AllClasses+[ctnProcedure, ctnWithStatement];
112
110
  
113
111
type
114
112
  TNodeCacheEntryFlag = (ncefSearchedInParents, ncefSearchedInAncestors);
172
170
      4. 'longint' identifier node points points to its range.
173
171
      
174
172
      FindBaseTypeOfNode will search this chain, and on success will create
175
 
      TBaseTypeCache(s). All four nodes will point directly to the range.
 
173
      TBaseTypeCache(s). The All four nodes will point directly to the range.
176
174
 
177
175
  }
178
176
 
181
179
  TBaseTypeCache = class
182
180
  private
183
181
  public
184
 
    NewNode: TCodeTreeNode;
185
 
    NewTool: TPascalParserTool;
186
 
    Next: TBaseTypeCache; // used for mem manager
 
182
    BaseNode: TCodeTreeNode; // final base type
 
183
    BaseTool: TPascalParserTool;
 
184
    NextNode: TCodeTreeNode; // next node on path to the BaseNode
 
185
    NextTool: TPascalParserTool;
 
186
    NextCache: TBaseTypeCache; // used for mem manager
187
187
    Owner: TCodeTreeNode;
188
188
    procedure BindToOwner(NewOwner: TCodeTreeNode);
189
189
    procedure UnbindFromOwner;
198
198
    Node- and BaseTypeCache depends on their codetool and the
199
199
    node- and basetypecaches of other codetools (=used codetools). The used
200
200
    codetools dependencies are saved in the TCodeToolDependencies, which is
201
 
    simple an TAVLTree of codetools. This allows to decide, wether the cache of
 
201
    simple an TAVLTree of codetools. This allows one to decide, wether the cache of
202
202
    a codetools must be rebuild.
203
203
  }
204
204
 
205
205
 
206
 
 
207
206
  //----------------------------------------------------------------------------
208
207
type
209
208
 
269
268
 
270
269
  //----------------------------------------------------------------------------
271
270
  // stacks for circle checking
 
271
const
 
272
  CodeTreeNodeFixedItemCount = 12;
272
273
type
273
 
  TCodeTreeNodeStackEntry = TCodeTreeNode;
 
274
  TCodeTreeNodeStackEntry = record
 
275
    Tool: TPascalParserTool;
 
276
    Node: TCodeTreeNode;
 
277
  end;
 
278
  PCodeTreeNodeStackEntry = ^TCodeTreeNodeStackEntry;
274
279
 
275
280
  TCodeTreeNodeStack = record
276
 
    Fixedtems: array[0..9] of TCodeTreeNodeStackEntry;
277
 
    DynItems: TFPList; // list of TCodeTreeNodeStackEntry
 
281
    FixedItems: array[0..CodeTreeNodeFixedItemCount-1] of TCodeTreeNodeStackEntry;
 
282
    DynItems: PCodeTreeNodeStackEntry;
278
283
    StackPtr: integer;
 
284
    Capacity: integer; // size of  DynItems in entries
279
285
  end;
280
286
  PCodeTreeNodeStack = ^TCodeTreeNodeStack;
281
287
 
282
288
  procedure InitializeNodeStack(NodeStack: PCodeTreeNodeStack);
283
289
  function GetNodeStackEntry(NodeStack: PCodeTreeNodeStack;
284
 
    Index: integer): TCodeTreeNodeStackEntry;
 
290
    Index: integer): PCodeTreeNodeStackEntry;
285
291
  procedure AddNodeToStack(NodeStack: PCodeTreeNodeStack;
286
 
    NewNode: TCodeTreeNode);
 
292
    NewTool: TPascalParserTool; NewNode: TCodeTreeNode);
287
293
  function NodeExistsInStack(NodeStack: PCodeTreeNodeStack;
288
294
    Node: TCodeTreeNode): boolean;
289
295
  procedure FinalizeNodeStack(NodeStack: PCodeTreeNodeStack);
1184
1190
 
1185
1191
procedure InitializeNodeStack(NodeStack: PCodeTreeNodeStack);
1186
1192
begin
1187
 
  NodeStack^.StackPtr:=0;
 
1193
  NodeStack^.StackPtr:=-1;
1188
1194
  NodeStack^.DynItems:=nil;
 
1195
  NodeStack^.Capacity:=0;
1189
1196
end;
1190
1197
 
1191
1198
function GetNodeStackEntry(NodeStack: PCodeTreeNodeStack;
1192
 
  Index: integer): TCodeTreeNodeStackEntry;
 
1199
  Index: integer): PCodeTreeNodeStackEntry;
1193
1200
begin
1194
 
  if Index<=High(NodeStack^.Fixedtems) then begin
1195
 
    Result:=NodeStack^.Fixedtems[Index];
 
1201
  if Index<CodeTreeNodeFixedItemCount then begin
 
1202
    Result:=@NodeStack^.FixedItems[Index];
1196
1203
  end else begin
1197
 
    Result:=TCodeTreeNodeStackEntry(
1198
 
                       NodeStack^.DynItems[Index-High(NodeStack^.Fixedtems)-1]);
 
1204
    Result:=@NodeStack^.DynItems[Index-CodeTreeNodeFixedItemCount];
1199
1205
  end;
1200
1206
end;
1201
1207
 
1202
1208
procedure AddNodeToStack(NodeStack: PCodeTreeNodeStack;
1203
 
  NewNode: TCodeTreeNode);
 
1209
  NewTool: TPascalParserTool; NewNode: TCodeTreeNode);
 
1210
var
 
1211
  Entry: PCodeTreeNodeStackEntry;
 
1212
  i: Integer;
1204
1213
begin
1205
 
  if (NodeStack^.StackPtr<=High(NodeStack^.Fixedtems)) then begin
1206
 
    NodeStack^.Fixedtems[NodeStack^.StackPtr]:=NewNode;
1207
 
  end else begin
1208
 
    if NodeStack^.DynItems=nil then begin
1209
 
      NodeStack^.DynItems:=TFPList.Create;
1210
 
    end;
1211
 
    NodeStack^.DynItems.Add(NewNode);
1212
 
  end;
1213
1214
  inc(NodeStack^.StackPtr);
 
1215
  if NodeStack^.StackPtr<CodeTreeNodeFixedItemCount then begin
 
1216
    Entry:=@NodeStack^.FixedItems[NodeStack^.StackPtr];
 
1217
  end else begin
 
1218
    i:=NodeStack^.StackPtr-CodeTreeNodeFixedItemCount;
 
1219
    if NodeStack^.Capacity<=i then begin
 
1220
      inc(NodeStack^.Capacity,CodeTreeNodeFixedItemCount);
 
1221
      ReAllocMem(NodeStack^.DynItems,NodeStack^.Capacity*SizeOf(TCodeTreeNodeStackEntry));
 
1222
    end;
 
1223
    Entry:=@NodeStack^.DynItems[i];
 
1224
  end;
 
1225
  Entry^.Tool:=NewTool;
 
1226
  Entry^.Node:=NewNode;
1214
1227
end;
1215
1228
 
1216
1229
function NodeExistsInStack(NodeStack: PCodeTreeNodeStack;
1219
1232
begin
1220
1233
  Result:=true;
1221
1234
  i:=0;
1222
 
  while i<NodeStack^.StackPtr do begin
1223
 
    if i<=High(NodeStack^.Fixedtems) then begin
1224
 
      if NodeStack^.Fixedtems[i]=Node then exit;
 
1235
  while i<=NodeStack^.StackPtr do begin
 
1236
    if i<CodeTreeNodeFixedItemCount then begin
 
1237
      if NodeStack^.FixedItems[i].Node=Node then exit;
1225
1238
    end else begin
1226
 
      if NodeStack^.DynItems[i-High(NodeStack^.Fixedtems)-1]=Pointer(Node) then
 
1239
      if NodeStack^.DynItems[i-CodeTreeNodeFixedItemCount].Node=Node then
1227
1240
        exit;
1228
1241
    end;
1229
1242
    inc(i);
1233
1246
 
1234
1247
procedure FinalizeNodeStack(NodeStack: PCodeTreeNodeStack);
1235
1248
begin
1236
 
  NodeStack^.DynItems.Free;
 
1249
  if NodeStack^.DynItems=nil then exit;
 
1250
  ReAllocMem(NodeStack^.DynItems,0);
1237
1251
end;
1238
1252
 
1239
1253
 
1246
1260
  if (FFreeCount<FMinFree) or (FFreeCount<((FCount shr 3)*FMaxFreeRatio)) then
1247
1261
  begin
1248
1262
    // add Entry to Free list
1249
 
    BaseTypeCache.Next:=TBaseTypeCache(FFirstFree);
 
1263
    BaseTypeCache.NextCache:=TBaseTypeCache(FFirstFree);
1250
1264
    TBaseTypeCache(FFirstFree):=BaseTypeCache;
1251
1265
    inc(FFreeCount);
1252
1266
  end else begin
1263
1277
var BaseTypeCache: TBaseTypeCache;
1264
1278
begin
1265
1279
  BaseTypeCache:=TBaseTypeCache(FFirstFree);
1266
 
  TBaseTypeCache(FFirstFree):=BaseTypeCache.Next;
 
1280
  TBaseTypeCache(FFirstFree):=BaseTypeCache.NextCache;
1267
1281
  BaseTypeCache.Free;
1268
1282
end;
1269
1283
 
1273
1287
  if FFirstFree<>nil then begin
1274
1288
    // take from free list
1275
1289
    Result:=TBaseTypeCache(FFirstFree);
1276
 
    TBaseTypeCache(FFirstFree):=Result.Next;
 
1290
    TBaseTypeCache(FFirstFree):=Result.NextCache;
1277
1291
    Result.BindToOwner(AnOwner);
1278
1292
    dec(FFreeCount);
1279
1293
  end else begin