MG: acclerated parser read-undo-read combinations

git-svn-id: trunk@1501 -
This commit is contained in:
lazarus 2002-03-11 18:12:11 +00:00
parent 8752d483cc
commit c40bc842d5
3 changed files with 35 additions and 31 deletions

View File

@ -68,6 +68,7 @@ type
SrcLen: integer;
CurNode: TCodeTreeNode;
LastAtoms: TAtomRing;
NextPos: TAtomPosition;
CheckFilesOnDisk: boolean;
IndentSize: integer;
@ -199,6 +200,7 @@ begin
CurPos.StartPos:=1;
CurPos.EndPos:=-1;
LastAtoms.Clear;
NextPos.StartPos:=-1;
end;
procedure TCustomCodeTool.RaiseException(const AMessage: string);
@ -539,11 +541,16 @@ procedure TCustomCodeTool.ReadNextAtom;
var c1, c2: char;
CommentLvl: integer;
begin
// Skip all spaces and comments
CommentLvl:=0;
if (CurPos.StartPos<CurPos.EndPos) and (CurPos.StartPos>=1) then
LastAtoms.Add(CurPos);
if NextPos.StartPos>=1 then begin
CurPos:=NextPos;
NextPos.StartPos:=-1;
exit;
end;
CurPos.StartPos:=CurPos.EndPos;
// Skip all spaces and comments
CommentLvl:=0;
//if CurPos.StartPos<1 then CurPos.StartPos:=SrcLen+1;
while CurPos.StartPos<=SrcLen do begin
if IsCommentStartChar[Src[CurPos.StartPos]] then begin
@ -747,6 +754,7 @@ begin
UndoReadNextAtom;
exit;
end;
NextPos:=CurPos;
// Skip all spaces and comments
CommentLvl:=0;
dec(CurPos.StartPos);
@ -1009,6 +1017,7 @@ end;
procedure TCustomCodeTool.UndoReadNextAtom;
begin
if LastAtoms.Count>0 then begin
NextPos:=CurPos;
CurPos:=LastAtoms.GetValueAt(0);
LastAtoms.UndoLastAdd;
end else
@ -1147,15 +1156,14 @@ begin
CurPos.StartPos:=1;
CurPos.EndPos:=1;
LastAtoms.Clear;
NextPos.StartPos:=-1;
CurNode:=nil;
if DeleteNodes then DoDeleteNodes;
end;
procedure TCustomCodeTool.MoveCursorToNodeStart(ANode: TCodeTreeNode);
begin
CurPos.StartPos:=ANode.StartPos;
CurPos.EndPos:=ANode.StartPos;
LastAtoms.Clear;
MoveCursorToCleanPos(ANode.StartPos);
CurNode:=ANode;
end;
@ -1164,6 +1172,7 @@ begin
CurPos.StartPos:=ACleanPos;
CurPos.EndPos:=ACleanPos;
LastAtoms.Clear;
NextPos.StartPos:=-1;
CurNode:=nil;
end;
@ -1368,6 +1377,7 @@ begin
// search first atom in line
CurPos.StartPos:=ALineStart;
CurPos.EndPos:=ALineStart;
NextPos.StartPos:=-1;
ReadNextAtom;
AFirstAtomStart:=CurPos.StartPos;
// search last atom in line

View File

@ -2960,8 +2960,7 @@ begin
if (GrandPaNode=nil) or (GrandPaNode.Desc<>ctnClass) then exit;
GrandPaNode:=GrandPaNode.Parent;
if GrandPaNode.Desc<>ctnTypeDefinition then exit;
CurPos.StartPos:=GrandPaNode.StartPos;
CurPos.EndPos:=CurPos.StartPos;
MoveCursorToCleanPos(GrandPaNode.StartPos);
ReadNextAtom;
if not AtomIsWord then exit;
TheClassName:=GetAtom;

View File

@ -34,31 +34,27 @@ end;
function TGraphic.Equals(Graphic: TGraphic): Boolean;
var
SelfImage, GraphicsImage: TMemoryStream;
IsEmpty: boolean;
begin
Result := (Graphic <> nil);
Result := (Graphic <> nil) and (ClassType = Graphic.ClassType);
if not Result then exit;
Result:=(ClassType = Graphic.ClassType);
if not Result then exit;
if Empty or Graphic.Empty then
begin
Result := Empty and Graphic.Empty;
Exit;
end;
if Result then begin
SelfImage := TMemoryStream.Create;
IsEmpty:=Empty;
Result:=(IsEmpty=Graphic.Empty);
if (not Result) or IsEmpty or (Self=Graphic) then exit;
// ToDo: check for same resource
SelfImage := TMemoryStream.Create;
try
WriteData(SelfImage);
GraphicsImage := TMemoryStream.Create;
try
WriteData(SelfImage);
GraphicsImage := TMemoryStream.Create;
try
Graphic.WriteData(GraphicsImage);
Result := (SelfImage.Size = GraphicsImage.Size) and
CompareMem(SelfImage.Memory, GraphicsImage.Memory, SelfImage.Size);
finally
GraphicsImage.Free;
end;
Graphic.WriteData(GraphicsImage);
Result := (SelfImage.Size = GraphicsImage.Size) and
CompareMem(SelfImage.Memory, GraphicsImage.Memory, SelfImage.Size);
finally
SelfImage.Free;
GraphicsImage.Free;
end;
finally
SelfImage.Free;
end;
end;
@ -104,17 +100,16 @@ end;
procedure TGraphic.SetModified(Value: Boolean);
begin
if Value then
FModified := true // Changed(Self);
Changed(Self);
else
FModified := False;
end;
procedure TGraphic.SetTransparent(Value: Boolean);
begin
if Value <> FTransparent then
begin
if Value <> FTransparent then begin
FTransparent := Value;
//Changed(Self);
Changed(Self);
end;
end;