From aa389e7e4706fe921fe7400e1ed07a7035e4ccb2 Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 18 Jun 2023 16:03:12 +0200 Subject: [PATCH] FpDebug: fix constant char 'a' as array index. Amend Precedence for [n..m] --- components/fpdebug/fppascalparser.pas | 9 +++++---- .../lazdebuggers/lazdebuggerfp/test/testwatches.pas | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/fpdebug/fppascalparser.pas b/components/fpdebug/fppascalparser.pas index 9611893aca..681bb3b38d 100644 --- a/components/fpdebug/fppascalparser.pas +++ b/components/fpdebug/fppascalparser.pas @@ -620,9 +620,9 @@ const PRECEDENCE_BIT_SHIFT = 12; // << >> shr shr PRECEDENCE_PLUS_MINUS = 13; // a + b PRECEDENCE_OR = 13; // a OR b // XOR - PRECEDENCE_ARRAY_SLICE= 18; // array[5..9] // array slice PRECEDENCE_IN = 19; // enum IN set // officially the same as PRECEDENCE_COMPARE PRECEDENCE_COMPARE = 20; // a <> b // a=b + PRECEDENCE_ARRAY_SLICE= 30; // array[5..9] // array slice type @@ -2595,8 +2595,10 @@ end; function TFpPascalExpressionPartConstantText.DoGetResultValue: TFpValue; begin - //s := GetText; - Result := TFpValueConstString.Create(FValue); + if Length(FValue) = 1 then + Result := TFpValueConstChar.Create(FValue[1]) + else + Result := TFpValueConstString.Create(FValue); {$IFDEF WITH_REFCOUNT_DEBUG}Result.DbgRenameReference(nil, 'DoGetResultValue'){$ENDIF}; end; @@ -2978,7 +2980,6 @@ var end; if not FValid then exit; - // If Length(str) = 1 then // char AddPart(TFpPascalExpressionPartConstantText); TFpPascalExpressionPartConstantText(NewPart).FValue := str; end; diff --git a/components/lazdebuggers/lazdebuggerfp/test/testwatches.pas b/components/lazdebuggers/lazdebuggerfp/test/testwatches.pas index 07e50b9f30..1b52636640 100644 --- a/components/lazdebuggers/lazdebuggerfp/test/testwatches.pas +++ b/components/lazdebuggers/lazdebuggerfp/test/testwatches.pas @@ -3461,12 +3461,12 @@ begin t.Add('Const-Expr: ansistring ', '''abc''''DE''', weAnsiStr('abcDE')).IgnKind; t.Add('Const-Expr: ansistring ', '''abc''#32''DE''', weAnsiStr('abc DE')).IgnKind; t.Add('Const-Expr: ansistring ', '#32''abc''', weAnsiStr(' abc')).IgnKind; - t.Add('Const-Expr: ansistring ', '#49', weAnsiStr('1')).IgnKind; t.Add('Const-Expr: ansistring ', '#49#50', weAnsiStr('12')).IgnKind; t.Add('Const-Expr: ansistring ', '#$30#$31', weAnsiStr('01')).IgnKind; t.Add('Const-Expr: ansistring ', '#&61#&62', weAnsiStr('12')).IgnKind; - t.Add('Const-Expr: ansistring ', '#%110001', weAnsiStr('1')).IgnKind; - t.Add('Const-Expr: ansistring ', '#%00110001', weAnsiStr('1')).IgnKind; + t.Add('Const-Expr: ansistring ', '#49', weChar('1')).IgnKind; + t.Add('Const-Expr: ansistring ', '#%110001', weChar('1')).IgnKind; + t.Add('Const-Expr: ansistring ', '#%00110001', weChar('1')).IgnKind; t.Add('Const-Expr: ansistring ', '''a', weAnsiStr('1')).IgnKind^.AddFlag(ehExpectError); t.Add('Const-Expr: ansistring ', '''', weAnsiStr('1')).IgnKind^.AddFlag(ehExpectError);