mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-02 19:29:21 +00:00
Add most of the infrastructure to support 64-bit decimal constants.
Right now, decimal constants can have long long types based on their suffix, but they are still limited to a maximum value of 2^32-1. This also implements the C99 change where decimal constants without a u suffix always have signed types. Thus, decimal constants of 2^31 and up now have type long long, even if their values could be represented in the type unsigned long.
This commit is contained in:
parent
058c0565c6
commit
c37fae0f3b
25
Scanner.pas
25
Scanner.pas
@ -3351,22 +3351,35 @@ else if numString[1] <> '0' then begin {convert a decimal integer}
|
|||||||
or (not unsigned and (stringIndex = 5) and (numString > '32767'))
|
or (not unsigned and (stringIndex = 5) and (numString > '32767'))
|
||||||
or (unsigned and (stringIndex = 5) and (numString > '65535')) then
|
or (unsigned and (stringIndex = 5) and (numString > '65535')) then
|
||||||
isLong := true;
|
isLong := true;
|
||||||
if (stringIndex > 10) or
|
if (stringIndex > 10)
|
||||||
|
or (not unsigned and (stringIndex = 10) and (numString > '2147483647'))
|
||||||
|
or (unsigned and (stringIndex = 10) and (numString > '4294967295')) then
|
||||||
|
isLongLong := true;
|
||||||
|
if (stringIndex > 10) or {TODO increase limits}
|
||||||
((stringIndex = 10) and (numString > '4294967295')) then begin
|
((stringIndex = 10) and (numString > '4294967295')) then begin
|
||||||
numString := '0';
|
numString := '0';
|
||||||
if flagOverflows then
|
if flagOverflows then
|
||||||
FlagError(6);
|
FlagError(6);
|
||||||
end; {if}
|
end; {if}
|
||||||
if isLong then begin
|
if isLongLong then begin
|
||||||
|
token.class := longlongConstant;
|
||||||
|
token.qval.hi := 0;
|
||||||
|
token.qval.lo := Convertsl(numString); {TODO support full 64-bit range}
|
||||||
|
if unsigned then
|
||||||
|
token.kind := ulonglongConst
|
||||||
|
else begin
|
||||||
|
token.kind := longlongConst;
|
||||||
|
if token.qval.hi < 0 then
|
||||||
|
FlagError(6);
|
||||||
|
end; {else}
|
||||||
|
end {if}
|
||||||
|
else if isLong then begin
|
||||||
token.class := longConstant;
|
token.class := longConstant;
|
||||||
token.lval := Convertsl(numString);
|
token.lval := Convertsl(numString);
|
||||||
if unsigned then
|
if unsigned then
|
||||||
token.kind := ulongConst
|
token.kind := ulongConst
|
||||||
else begin
|
else
|
||||||
token.kind := longConst;
|
token.kind := longConst;
|
||||||
if token.lval < 0 then
|
|
||||||
token.kind := ulongConst;
|
|
||||||
end; {else}
|
|
||||||
end {if}
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
if unsigned then
|
if unsigned then
|
||||||
|
Loading…
Reference in New Issue
Block a user