mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:39:25 +02:00
codetools: expreval: numbers
git-svn-id: trunk@22800 -
This commit is contained in:
parent
4d7aa9e2ea
commit
bb1d9ea928
@ -218,8 +218,9 @@ begin
|
|||||||
// decimal number
|
// decimal number
|
||||||
if l<15 then begin
|
if l<15 then begin
|
||||||
while l>0 do begin
|
while l>0 do begin
|
||||||
|
c:=p^;
|
||||||
if c in ['0'..'9'] then
|
if c in ['0'..'9'] then
|
||||||
Result:=Result*10+ord(p^)-ord('0')
|
Result:=Result*10+ord(c)-ord('0')
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
inc(p);
|
inc(p);
|
||||||
@ -228,8 +229,9 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
try
|
try
|
||||||
while l>0 do begin
|
while l>0 do begin
|
||||||
|
c:=p^;
|
||||||
if c in ['0'..'9'] then
|
if c in ['0'..'9'] then
|
||||||
Result:=Result*10+ord(p^)-ord('0')
|
Result:=Result*10+ord(c)-ord('0')
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
inc(p);
|
inc(p);
|
||||||
@ -1365,6 +1367,14 @@ var
|
|||||||
end;
|
end;
|
||||||
exit(true);
|
exit(true);
|
||||||
end;
|
end;
|
||||||
|
'0'..'9','$':
|
||||||
|
begin
|
||||||
|
// number
|
||||||
|
if Operand.Free then FreeOperandValue(Operand);
|
||||||
|
Operand.Value:=AtomStart;
|
||||||
|
Operand.Len:=p-AtomStart;
|
||||||
|
exit(true);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
if IsIdentStartChar[AtomStart^] then begin
|
if IsIdentStartChar[AtomStart^] then begin
|
||||||
// identifier => return current value
|
// identifier => return current value
|
||||||
@ -1395,6 +1405,7 @@ var
|
|||||||
// compute stack item
|
// compute stack item
|
||||||
Op:=ExprStack[StackPtr].theOperator;
|
Op:=ExprStack[StackPtr].theOperator;
|
||||||
StackOperand:=@ExprStack[StackPtr].Operand;
|
StackOperand:=@ExprStack[StackPtr].Operand;
|
||||||
|
DebugLn(['ExecuteStack Operator^=',ExprStack[StackPtr].theOperator^]);
|
||||||
case UpChars[Op^] of
|
case UpChars[Op^] of
|
||||||
'*': // multiply
|
'*': // multiply
|
||||||
begin
|
begin
|
||||||
@ -1447,6 +1458,7 @@ var
|
|||||||
Number1:=OperandToInt64(StackOperand^);
|
Number1:=OperandToInt64(StackOperand^);
|
||||||
Number2:=OperandToInt64(Operand);
|
Number2:=OperandToInt64(Operand);
|
||||||
NumberResult:=Number1 shl Number2;
|
NumberResult:=Number1 shl Number2;
|
||||||
|
DebugLn(['ExecuteStack ',Number1,' ',Number2,' ',NumberResult]);
|
||||||
SetOperandValueInt64(Operand,NumberResult);
|
SetOperandValueInt64(Operand,NumberResult);
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
@ -1594,14 +1606,14 @@ begin
|
|||||||
'+','-': if AtomStart-p=1 then OperatorLvl:=2;
|
'+','-': if AtomStart-p=1 then OperatorLvl:=2;
|
||||||
'=': if AtomStart-p=1 then OperatorLvl:=3;
|
'=': if AtomStart-p=1 then OperatorLvl:=3;
|
||||||
'<': if (AtomStart-p=1)
|
'<': if (AtomStart-p=1)
|
||||||
or (AtomStart[2] in ['=','>']) then
|
or (AtomStart[1] in ['=','>']) then
|
||||||
OperatorLvl:=3
|
OperatorLvl:=3
|
||||||
else if AtomStart[2]='<' then
|
else if AtomStart[1]='<' then
|
||||||
OperatorLvl:=1;
|
OperatorLvl:=1;
|
||||||
'>': if (AtomStart-p=1)
|
'>': if (AtomStart-p=1)
|
||||||
or (AtomStart[2]='=') then
|
or (AtomStart[1]='=') then
|
||||||
OperatorLvl:=3
|
OperatorLvl:=3
|
||||||
else if AtomStart[2]='>' then
|
else if AtomStart[1]='>' then
|
||||||
OperatorLvl:=1;
|
OperatorLvl:=1;
|
||||||
'A':
|
'A':
|
||||||
if CompareIdentifiers(AtomStart,'AND')=0 then begin
|
if CompareIdentifiers(AtomStart,'AND')=0 then begin
|
||||||
|
Loading…
Reference in New Issue
Block a user