From 68d14314b2ac22a94a5f474f86f4e688ba4b3c53 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 2 Aug 2024 22:43:29 +0200 Subject: [PATCH] FpDebug: allow comparing (equal) pointer = number. --- components/fpdebug/fpdbginfo.pas | 2 ++ components/fpdebug/fppascalparser.pas | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/fpdebug/fpdbginfo.pas b/components/fpdebug/fpdbginfo.pas index a1188752cc..6593fd3cbd 100644 --- a/components/fpdebug/fpdbginfo.pas +++ b/components/fpdebug/fpdbginfo.pas @@ -1455,7 +1455,9 @@ end; function TFpValueConstNumber.GetAsInteger: Int64; begin + {$push}{$R-}{$Q-} Result := Int64(FValue); + {$pop} end; function TFpValueConstNumber.GetAsFloat: Extended; diff --git a/components/fpdebug/fppascalparser.pas b/components/fpdebug/fppascalparser.pas index 36c49cc8f8..bfaf9a2248 100644 --- a/components/fpdebug/fppascalparser.pas +++ b/components/fpdebug/fppascalparser.pas @@ -4146,7 +4146,7 @@ begin if FStartChar^ in ['0'..'9'] then Result := TFpValueConstNumber.Create(i, False) else - Result := TFpValueConstNumber.Create(Int64(i), True); // hex,oct,bin values default to signed + Result := TFpValueConstNumber.Create(i, True); // hex,oct,bin values default to signed {$IFDEF WITH_REFCOUNT_DEBUG}Result.DbgRenameReference(nil, 'DoGetResultValue'){$ENDIF}; end; @@ -6855,6 +6855,8 @@ function TFpPascalExpressionPartOperatorCompare.DoGetResultValue: TFpValue; skInteger: Result := TFpValueConstBool.Create((AIntVal.AsInteger = AOtherVal.AsInteger) xor AReverse); skCardinal: Result := TFpValueConstBool.Create((AIntVal.AsInteger = AOtherVal.AsCardinal) xor AReverse); skFloat: Result := TFpValueConstBool.Create((AIntVal.AsInteger = AOtherVal.AsFloat) xor AReverse); + skPointer, skAddress: + Result := TFpValueConstBool.Create((AIntVal.AsCardinal = AOtherVal.AsCardinal) xor AReverse) else SetError('= not supported'); end; end; @@ -6865,6 +6867,8 @@ function TFpPascalExpressionPartOperatorCompare.DoGetResultValue: TFpValue; skInteger: Result := TFpValueConstBool.Create((ACardinalVal.AsCardinal = AOtherVal.AsInteger) xor AReverse); skCardinal: Result := TFpValueConstBool.Create((ACardinalVal.AsCardinal = AOtherVal.AsCardinal) xor AReverse); skFloat: Result := TFpValueConstBool.Create((ACardinalVal.AsCardinal = AOtherVal.AsFloat) xor AReverse); + skPointer, skAddress: + Result := TFpValueConstBool.Create((ACardinalVal.AsCardinal = AOtherVal.AsCardinal) xor AReverse) else SetError('= not supported'); end; end; @@ -6881,7 +6885,9 @@ function TFpPascalExpressionPartOperatorCompare.DoGetResultValue: TFpValue; function AddressPtrEqualToValue(AIntVal, AOtherVal: TFpValue; AReverse: Boolean = False): TFpValue; begin Result := nil; - if AOtherVal.Kind in [skClass,skInterface,skAddress,skPointer] then + if (AOtherVal.Kind in [skClass,skInterface,skAddress,skPointer]) or + ((AIntVal.Kind in [skPointer, skAddress]) and (AOtherVal.Kind in [skInteger,skCardinal])) + then Result := TFpValueConstBool.Create((AIntVal.AsCardinal = AOtherVal.AsCardinal) xor AReverse) else SetError('= not supported');