mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-22 18:29:26 +01:00
Reduce duplicate code
git-svn-id: trunk@65159 -
This commit is contained in:
parent
cfa20195b1
commit
a822d5c8f7
@ -409,19 +409,6 @@ type
|
||||
function GetAsCardinal: QWord; override;
|
||||
procedure SetAsCardinal(AValue: QWord); override;
|
||||
function GetDataSize: TFpDbgValueSize; override;
|
||||
end;
|
||||
|
||||
{ TFpValueDwarfStructTypeCast }
|
||||
|
||||
TFpValueDwarfStructTypeCast = class(TFpValueDwarfStructBase)
|
||||
private
|
||||
FDataAddressDone: Boolean;
|
||||
protected
|
||||
procedure Reset; override;
|
||||
function GetFieldFlags: TFpValueFieldFlags; override;
|
||||
function GetKind: TDbgSymbolKind; override;
|
||||
function GetAsCardinal: QWord; override;
|
||||
function GetDataSize: TFpDbgValueSize; override;
|
||||
function IsValidTypeCast: Boolean; override;
|
||||
end;
|
||||
|
||||
@ -3074,7 +3061,9 @@ begin
|
||||
//TODO: svfDataAddress should depend on (hidden) Pointer or Ref in the TypeInfo
|
||||
if Kind in [skClass] then begin
|
||||
Result := Result + [svfOrdinal, svfDataAddress, svfDataSize]; // svfDataSize
|
||||
if (FDataSymbol <> nil) and FDataSymbol.HasAddress then
|
||||
if ((FDataSymbol <> nil) and FDataSymbol.HasAddress) or
|
||||
(HasTypeCastInfo and (Kind = skClass))
|
||||
then
|
||||
Result := Result + [svfSizeOfPointer];
|
||||
end
|
||||
else begin
|
||||
@ -3106,79 +3095,39 @@ begin
|
||||
end;
|
||||
|
||||
function TFpValueDwarfStruct.GetDataSize: TFpDbgValueSize;
|
||||
begin
|
||||
Assert((FDataSymbol = nil) or (FDataSymbol.TypeInfo is TFpSymbolDwarf));
|
||||
if (FDataSymbol <> nil) and (FDataSymbol.TypeInfo <> nil) then begin
|
||||
if FDataSymbol.TypeInfo.Kind = skClass then begin
|
||||
if not TFpSymbolDwarf(FDataSymbol.TypeInfo).DoReadDataSize(Self, Result) then
|
||||
Result := ZeroSize;
|
||||
end
|
||||
else
|
||||
if not GetSize(Result) then
|
||||
Result := ZeroSize;
|
||||
end
|
||||
else
|
||||
Result := ZeroSize;
|
||||
end;
|
||||
|
||||
{ TFpValueDwarfStructTypeCast }
|
||||
|
||||
procedure TFpValueDwarfStructTypeCast.Reset;
|
||||
begin
|
||||
inherited Reset;
|
||||
FDataAddressDone := False;
|
||||
end;
|
||||
|
||||
function TFpValueDwarfStructTypeCast.GetFieldFlags: TFpValueFieldFlags;
|
||||
begin
|
||||
Result := inherited GetFieldFlags;
|
||||
Result := Result + [svfMembers];
|
||||
if kind = skClass then // todo detect hidden pointer
|
||||
Result := Result + [svfDataSize]
|
||||
else
|
||||
Result := Result + [svfSize];
|
||||
|
||||
//TODO: svfDataAddress should depend on (hidden) Pointer or Ref in the TypeInfo
|
||||
if Kind in [skClass] then
|
||||
Result := Result + [svfOrdinal, svfDataAddress, svfSizeOfPointer]; // svfDataSize
|
||||
end;
|
||||
|
||||
function TFpValueDwarfStructTypeCast.GetKind: TDbgSymbolKind;
|
||||
begin
|
||||
Result := FTypeSymbol.Kind;
|
||||
end;
|
||||
|
||||
function TFpValueDwarfStructTypeCast.GetAsCardinal: QWord;
|
||||
var
|
||||
Addr: TFpDbgMemLocation;
|
||||
ti: TFpSymbolDwarf;
|
||||
begin
|
||||
if not GetDwarfDataAddress(Addr) then
|
||||
Result := 0
|
||||
else
|
||||
Result := QWord(LocToAddrOrNil(Addr));
|
||||
Result := ZeroSize;
|
||||
ti := nil;
|
||||
if HasTypeCastInfo then begin
|
||||
Assert((FTypeSymbol = nil) or (FTypeSymbol is TFpSymbolDwarf));
|
||||
ti := FTypeSymbol;
|
||||
end
|
||||
else begin
|
||||
Assert((FDataSymbol = nil) or (FDataSymbol.TypeInfo is TFpSymbolDwarf));
|
||||
if (FDataSymbol <> nil) then
|
||||
ti := TFpSymbolDwarf(FDataSymbol.TypeInfo);
|
||||
end;
|
||||
|
||||
function TFpValueDwarfStructTypeCast.GetDataSize: TFpDbgValueSize;
|
||||
begin
|
||||
Assert((FTypeSymbol = nil) or (FTypeSymbol is TFpSymbolDwarf));
|
||||
if FTypeSymbol <> nil then begin
|
||||
if FTypeSymbol.Kind = skClass then begin
|
||||
if not TFpSymbolDwarf(FTypeSymbol).DoReadDataSize(Self, Result) then
|
||||
if (ti <> nil) and (ti.Kind = skClass) then begin
|
||||
if not ti.DoReadDataSize(Self, Result) then
|
||||
Result := ZeroSize;
|
||||
end
|
||||
else
|
||||
if not GetSize(Result) then
|
||||
Result := ZeroSize;
|
||||
end
|
||||
else
|
||||
Result := ZeroSize;
|
||||
end;
|
||||
|
||||
function TFpValueDwarfStructTypeCast.IsValidTypeCast: Boolean;
|
||||
function TFpValueDwarfStruct.IsValidTypeCast: Boolean;
|
||||
var
|
||||
f: TFpValueFieldFlags;
|
||||
SrcSize, TypeSize: TFpDbgValueSize;
|
||||
begin
|
||||
if not HasTypeCastInfo then begin
|
||||
Result := inherited IsValidTypeCast;
|
||||
end
|
||||
else begin
|
||||
Result := HasTypeCastInfo;
|
||||
if not Result then
|
||||
exit;
|
||||
@ -3222,6 +3171,7 @@ begin
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TFpValueDwarfConstAddress }
|
||||
|
||||
@ -5503,9 +5453,6 @@ function TFpSymbolDwarfTypeStructure.GetTypedValueObject(ATypeCast: Boolean;
|
||||
begin
|
||||
if AnOuterType = nil then
|
||||
AnOuterType := Self;
|
||||
if ATypeCast then
|
||||
Result := TFpValueDwarfStructTypeCast.Create(AnOuterType)
|
||||
else
|
||||
Result := TFpValueDwarfStruct.Create(AnOuterType);
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user