mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 10:39:30 +02:00
fixed finddeclaration for long expression with same operator lvl
git-svn-id: trunk@3971 -
This commit is contained in:
parent
34da3919b8
commit
73c8cd5c83
@ -2914,7 +2914,7 @@ type
|
|||||||
theOperator: TAtomPosition;
|
theOperator: TAtomPosition;
|
||||||
OperatorLvl: integer;
|
OperatorLvl: integer;
|
||||||
end;
|
end;
|
||||||
TExprStack = array[0..3] of TOperandAndOperator;
|
TExprStack = array[0..4] of TOperandAndOperator;
|
||||||
var
|
var
|
||||||
CurExprType: TExpressionType;
|
CurExprType: TExpressionType;
|
||||||
ExprStack: TExprStack;
|
ExprStack: TExprStack;
|
||||||
@ -2930,16 +2930,16 @@ var
|
|||||||
end;
|
end;
|
||||||
LastPos:=CurPos.StartPos;
|
LastPos:=CurPos.StartPos;
|
||||||
while (StackPtr>0)
|
while (StackPtr>0)
|
||||||
and (ExprStack[StackPtr].OperatorLvl>ExprStack[StackPtr-1].OperatorLvl) do
|
and (ExprStack[StackPtr].OperatorLvl>=ExprStack[StackPtr-1].OperatorLvl) do
|
||||||
begin
|
begin
|
||||||
// next operand has a lower priority/precedence
|
// next operand has a lower or equal priority/precedence
|
||||||
// -> calculate last two operands
|
// -> calculate last two operands
|
||||||
NewOperand:=CalculateBinaryOperator(ExprStack[StackPtr-1].Operand,
|
NewOperand:=CalculateBinaryOperator(ExprStack[StackPtr-1].Operand,
|
||||||
ExprStack[StackPtr].Operand,ExprStack[StackPtr-1].theOperator,
|
ExprStack[StackPtr].Operand,ExprStack[StackPtr-1].theOperator,
|
||||||
Params);
|
Params);
|
||||||
// put result on stack
|
// put result on stack
|
||||||
|
ExprStack[StackPtr-1]:=ExprStack[StackPtr];
|
||||||
dec(StackPtr);
|
dec(StackPtr);
|
||||||
ExprStack[StackPtr]:=ExprStack[StackPtr+1];
|
|
||||||
ExprStack[StackPtr].Operand:=NewOperand;
|
ExprStack[StackPtr].Operand:=NewOperand;
|
||||||
end;
|
end;
|
||||||
MoveCursorToCleanPos(LastPos);
|
MoveCursorToCleanPos(LastPos);
|
||||||
@ -2955,7 +2955,13 @@ var
|
|||||||
RaiseException('[TFindDeclarationTool.FindExpressionResultType]'
|
RaiseException('[TFindDeclarationTool.FindExpressionResultType]'
|
||||||
+' internal error: unknown precedence lvl for operator '+GetAtom);
|
+' internal error: unknown precedence lvl for operator '+GetAtom);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure RaiseInternalErrorStack;
|
||||||
|
begin
|
||||||
|
RaiseException('[TFindDeclarationTool.FindExpressionResultType]'
|
||||||
|
+' internal error: stackptr too big ');
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
OldFlags: TFindDeclarationFlags;
|
OldFlags: TFindDeclarationFlags;
|
||||||
begin
|
begin
|
||||||
@ -2977,6 +2983,8 @@ begin
|
|||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
// put operand on stack
|
// put operand on stack
|
||||||
inc(StackPtr);
|
inc(StackPtr);
|
||||||
|
if StackPtr>High(ExprStack) then
|
||||||
|
RaiseInternalErrorStack;
|
||||||
ExprStack[StackPtr].Operand:=CurExprType;
|
ExprStack[StackPtr].Operand:=CurExprType;
|
||||||
ExprStack[StackPtr].theOperator.StartPos:=-1;
|
ExprStack[StackPtr].theOperator.StartPos:=-1;
|
||||||
ExprStack[StackPtr].OperatorLvl:=5;
|
ExprStack[StackPtr].OperatorLvl:=5;
|
||||||
|
Loading…
Reference in New Issue
Block a user