From a8caa8505215b4e3f69a861e7cfe4ed9a1fb97b0 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 2 May 2014 00:53:39 +0000 Subject: [PATCH] FpDebug: added nil,true,false git-svn-id: trunk@44881 - --- components/fpdebug/fpdbginfo.pas | 11 ++++++- components/fpdebug/fppascalparser.pas | 47 ++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/components/fpdebug/fpdbginfo.pas b/components/fpdebug/fpdbginfo.pas index 9ccd6a0b12..10eaed7ea1 100644 --- a/components/fpdebug/fpdbginfo.pas +++ b/components/fpdebug/fpdbginfo.pas @@ -266,6 +266,7 @@ type function GetKind: TDbgSymbolKind; override; function GetFieldFlags: TFpDbgValueFieldFlags; override; function GetAsBool: Boolean; override; + function GetAsCardinal: QWord; override; public constructor Create(AValue: Boolean); end; @@ -795,7 +796,7 @@ end; function TFpDbgValueConstBool.GetFieldFlags: TFpDbgValueFieldFlags; begin - Result := [{svfOrdinal, }svfBoolean]; + Result := [svfOrdinal, svfBoolean]; end; function TFpDbgValueConstBool.GetAsBool: Boolean; @@ -803,6 +804,14 @@ begin Result := FValue; end; +function TFpDbgValueConstBool.GetAsCardinal: QWord; +begin + if FValue then + Result := 1 + else + Result := 0; +end; + constructor TFpDbgValueConstBool.Create(AValue: Boolean); begin inherited Create; diff --git a/components/fpdebug/fppascalparser.pas b/components/fpdebug/fppascalparser.pas index 39a78f8020..5b9f89782c 100644 --- a/components/fpdebug/fppascalparser.pas +++ b/components/fpdebug/fppascalparser.pas @@ -1357,14 +1357,38 @@ begin end; function TFpPascalExpressionPartIdentifer.DoGetResultValue: TFpDbgValue; +var + s: String; + tmp: TFpDbgValueConstAddress; begin - Result := FExpression.GetDbgSymbolForIdentifier(GetText); + s := GetText; + Result := FExpression.GetDbgSymbolForIdentifier(s); if Result = nil then begin - SetError(fpErrSymbolNotFound, [GetText]); - exit; - end; + s := LowerCase(s); + if s = 'nil' then begin + tmp := TFpDbgValueConstAddress.Create(NilLoc); + Result := TFpPasParserValueAddressOf.Create(tmp, Expression.Context); + tmp.ReleaseReference; + {$IFDEF WITH_REFCOUNT_DEBUG}Result.DbgRenameReference(nil, 'DoGetResultValue');{$ENDIF} + end + else + if s = 'true' then begin + Result := TFpDbgValueConstBool.Create(True); + {$IFDEF WITH_REFCOUNT_DEBUG}Result.DbgRenameReference(nil, 'DoGetResultValue');{$ENDIF} + end + else + if s = 'false' then begin + Result := TFpDbgValueConstBool.Create(False); + {$IFDEF WITH_REFCOUNT_DEBUG}Result.DbgRenameReference(nil, 'DoGetResultValue');{$ENDIF} + end + else begin + SetError(fpErrSymbolNotFound, [GetText]); + exit; + end; + end - Result.AddReference{$IFDEF WITH_REFCOUNT_DEBUG}(nil, 'DoGetResultValue'){$ENDIF}; + else + Result.AddReference{$IFDEF WITH_REFCOUNT_DEBUG}(nil, 'DoGetResultValue'){$ENDIF}; end; function GetFirstToken(AText: PChar): String; @@ -1530,12 +1554,18 @@ var if (TokenEndPtr^ = DecimalSeparator) and (TokenEndPtr[1] <> '.') then begin inc(TokenEndPtr); while TokenEndPtr^ in ['0'..'9'] do inc(TokenEndPtr); - AddPart(TFpPascalExpressionPartConstantNumberFloat); + if TokenEndPtr^ in ['a'..'z', 'A'..'Z', '_'] then + SetError(fpErrPasParserUnexpectedToken, [GetFirstToken(CurPtr), PosFromPChar(CurPtr)]) + else + AddPart(TFpPascalExpressionPartConstantNumberFloat); exit; end; end; end; - AddPart(TFpPascalExpressionPartConstantNumber); + if TokenEndPtr^ in ['a'..'z', 'A'..'Z', '_'] then + SetError(fpErrPasParserUnexpectedToken, [GetFirstToken(CurPtr), PosFromPChar(CurPtr)]) + else + AddPart(TFpPascalExpressionPartConstantNumber); end; procedure HandleComma; @@ -1720,6 +1750,7 @@ begin if FResultValDone then exit; FResultValue := DoGetResultValue; + {$IFDEF WITH_REFCOUNT_DEBUG}FResultValue.DbgRenameReference(nil, 'DoGetResultValue', @FResultValue, 'DoGetResultValue');{$ENDIF} FResultValDone := True; Result := FResultValue; end; @@ -1866,7 +1897,7 @@ destructor TFpPascalExpressionPart.Destroy; begin inherited Destroy; //FResultType.ReleaseReference{$IFDEF WITH_REFCOUNT_DEBUG}(nil, 'DoGetResultType'){$ENDIF}; - FResultValue.ReleaseReference{$IFDEF WITH_REFCOUNT_DEBUG}(nil, 'DoGetResultValue'){$ENDIF}; + FResultValue.ReleaseReference{$IFDEF WITH_REFCOUNT_DEBUG}(@FResultValue, 'DoGetResultValue'){$ENDIF}; end; function TFpPascalExpressionPart.HandleNextPart(APart: TFpPascalExpressionPart): TFpPascalExpressionPart;