Process floating-point values within the compiler using the extended type.
This means that floating-point constants can now have the range and precision of the extended type (aka long double), and floating-point constant expressions evaluated within the compiler also have that same range and precision (matching expressions evaluated at run time). This new behavior is intended to match the behavior specified in the C99 and later standards for FLT_EVAL_METHOD 2. This fixes the previous problem where long double constants and constant expressions of type long double were not represented and evaluated with the full range and precision that they should be. It also gives extra range and precision to constants and constant expressions of type double or float. This may have pluses and minuses, but at any rate it is consistent with the existing behavior for expressions evaluated at run time, and with one of the possible models of floating point evaluation specified in the C standards.
This commit is contained in:
parent
77d66ab699
commit
4ad7a65de6
10
CCommon.pas
10
CCommon.pas
|
@ -168,7 +168,7 @@ type
|
||||||
ident, {identifiers}
|
ident, {identifiers}
|
||||||
{constants}
|
{constants}
|
||||||
intconst,uintconst,longconst,ulongconst,longlongconst,
|
intconst,uintconst,longconst,ulongconst,longlongconst,
|
||||||
ulonglongconst,doubleconst,
|
ulonglongconst,extendedconst,
|
||||||
stringconst,
|
stringconst,
|
||||||
{reserved words}
|
{reserved words}
|
||||||
_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy,
|
_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy,
|
||||||
|
@ -209,7 +209,7 @@ type
|
||||||
|
|
||||||
tokenSet = set of tokenEnum;
|
tokenSet = set of tokenEnum;
|
||||||
tokenClass = (reservedWord,reservedSymbol,identifier,intConstant,longConstant,
|
tokenClass = (reservedWord,reservedSymbol,identifier,intConstant,longConstant,
|
||||||
longlongConstant,doubleConstant,stringConstant,macroParameter);
|
longlongConstant,realConstant,stringConstant,macroParameter);
|
||||||
identPtr = ^identRecord; {^ to a symbol table entry}
|
identPtr = ^identRecord; {^ to a symbol table entry}
|
||||||
tokenType = record {a token}
|
tokenType = record {a token}
|
||||||
kind: tokenEnum; {kind of token}
|
kind: tokenEnum; {kind of token}
|
||||||
|
@ -222,7 +222,7 @@ type
|
||||||
intConstant : (ival: integer);
|
intConstant : (ival: integer);
|
||||||
longConstant : (lval: longint);
|
longConstant : (lval: longint);
|
||||||
longlongConstant: (qval: longlong);
|
longlongConstant: (qval: longlong);
|
||||||
doubleConstant: (rval: double);
|
realConstant : (rval: extended);
|
||||||
stringConstant: (sval: longstringPtr;
|
stringConstant: (sval: longstringPtr;
|
||||||
ispstring: boolean);
|
ispstring: boolean);
|
||||||
macroParameter: (pnum: integer);
|
macroParameter: (pnum: integer);
|
||||||
|
@ -325,7 +325,7 @@ type
|
||||||
cgReal,
|
cgReal,
|
||||||
cgDouble,
|
cgDouble,
|
||||||
cgComp,
|
cgComp,
|
||||||
cgExtended: (rVal: double);
|
cgExtended: (rVal: extended);
|
||||||
cgVoid,
|
cgVoid,
|
||||||
ccPointer: (
|
ccPointer: (
|
||||||
pVal: longint;
|
pVal: longint;
|
||||||
|
@ -490,7 +490,7 @@ var
|
||||||
{expression results}
|
{expression results}
|
||||||
{------------------}
|
{------------------}
|
||||||
doDispose: boolean; {dispose of the expression tree as we go?}
|
doDispose: boolean; {dispose of the expression tree as we go?}
|
||||||
realExpressionValue: double; {value of the last real constant expression}
|
realExpressionValue: extended; {value of the last real constant expression}
|
||||||
llExpressionValue: longlong; {value of the last long long constant expression}
|
llExpressionValue: longlong; {value of the last long long constant expression}
|
||||||
expressionValue: longint; {value of the last constant expression}
|
expressionValue: longint; {value of the last constant expression}
|
||||||
expressionType: typePtr; {the type of the expression}
|
expressionType: typePtr; {the type of the expression}
|
||||||
|
|
33
CGC.asm
33
CGC.asm
|
@ -10,8 +10,8 @@
|
||||||
*
|
*
|
||||||
CnvSX start cg
|
CnvSX start cg
|
||||||
rec equ 4 record containing values
|
rec equ 4 record containing values
|
||||||
rec_real equ 0 disp to real value
|
rec_real equ 0 disp to real (extended) value
|
||||||
rec_ext equ 8 disp to extended (SANE) value
|
rec_ext equ 10 disp to extended (SANE) value
|
||||||
|
|
||||||
tsc set up DP
|
tsc set up DP
|
||||||
phd
|
phd
|
||||||
|
@ -25,7 +25,7 @@ rec_ext equ 8 disp to extended (SANE) value
|
||||||
adc #0
|
adc #0
|
||||||
pha
|
pha
|
||||||
phx
|
phx
|
||||||
fd2x convert TOS to extended
|
fx2x convert TOS to extended
|
||||||
move4 0,4 return
|
move4 0,4 return
|
||||||
pld
|
pld
|
||||||
pla
|
pla
|
||||||
|
@ -44,32 +44,15 @@ rec_ext equ 8 disp to extended (SANE) value
|
||||||
*
|
*
|
||||||
CnvSC start cg
|
CnvSC start cg
|
||||||
rec equ 4 record containing values
|
rec equ 4 record containing values
|
||||||
rec_real equ 0 disp to real value
|
rec_real equ 0 disp to real (extended) value
|
||||||
rec_ext equ 8 disp to extended (SANE) value
|
rec_ext equ 10 disp to extended (SANE) value
|
||||||
rec_cmp equ 18 disp to comp (SANE) value
|
rec_cmp equ 20 disp to comp (SANE) value
|
||||||
|
|
||||||
tsc set up DP
|
tsc set up DP
|
||||||
phd
|
phd
|
||||||
tcd
|
tcd
|
||||||
ph4 rec push addr of real number
|
ph4 rec push addr of real number
|
||||||
clc push addr of SANE number
|
clc push addr of SANE comp number
|
||||||
lda rec
|
|
||||||
adc #rec_ext
|
|
||||||
tax
|
|
||||||
lda rec+2
|
|
||||||
adc #0
|
|
||||||
pha
|
|
||||||
phx
|
|
||||||
fd2x convert TOS to extended
|
|
||||||
clc push addr of SANE number
|
|
||||||
lda rec
|
|
||||||
adc #rec_ext
|
|
||||||
tax
|
|
||||||
lda rec+2
|
|
||||||
adc #0
|
|
||||||
pha
|
|
||||||
phx
|
|
||||||
clc push addr of COMP number
|
|
||||||
lda rec
|
lda rec
|
||||||
adc #rec_cmp
|
adc #rec_cmp
|
||||||
tax
|
tax
|
||||||
|
@ -77,7 +60,7 @@ rec_cmp equ 18 disp to comp (SANE) value
|
||||||
adc #0
|
adc #0
|
||||||
pha
|
pha
|
||||||
phx
|
phx
|
||||||
fx2c convert TOS to extended
|
fx2c convert TOS to SANE comp number
|
||||||
move4 0,4 return
|
move4 0,4 return
|
||||||
pld
|
pld
|
||||||
pla
|
pla
|
||||||
|
|
|
@ -175,8 +175,8 @@
|
||||||
sta 2+&op
|
sta 2+&op
|
||||||
mend
|
mend
|
||||||
MACRO
|
MACRO
|
||||||
&LAB FD2X
|
&LAB FX2X
|
||||||
&LAB PEA $010E
|
&LAB PEA $0010
|
||||||
LDX #$090A
|
LDX #$090A
|
||||||
JSL $E10000
|
JSL $E10000
|
||||||
MEND
|
MEND
|
||||||
|
|
2
CGC.pas
2
CGC.pas
|
@ -32,7 +32,7 @@ type
|
||||||
{pcode code generation}
|
{pcode code generation}
|
||||||
{---------------------}
|
{---------------------}
|
||||||
realrec = record {used to convert from real to in-SANE}
|
realrec = record {used to convert from real to in-SANE}
|
||||||
itsReal: double;
|
itsReal: extended;
|
||||||
inSANE: packed array[1..10] of byte;
|
inSANE: packed array[1..10] of byte;
|
||||||
inCOMP: packed array[1..8] of byte;
|
inCOMP: packed array[1..8] of byte;
|
||||||
end;
|
end;
|
||||||
|
|
10
CGI.pas
10
CGI.pas
|
@ -266,7 +266,7 @@ type
|
||||||
cgReal,
|
cgReal,
|
||||||
cgDouble,
|
cgDouble,
|
||||||
cgComp,
|
cgComp,
|
||||||
cgExtended : (rval: double);
|
cgExtended : (rval: extended);
|
||||||
cgString : (str: longStringPtr);
|
cgString : (str: longStringPtr);
|
||||||
cgVoid,
|
cgVoid,
|
||||||
ccPointer : (pval: longint; pstr: longStringPtr);
|
ccPointer : (pval: longint; pstr: longStringPtr);
|
||||||
|
@ -579,7 +579,7 @@ procedure GenQ1 (fop: pcodes; qval: longlong; fp1: integer);
|
||||||
{ fp1 - integer parameter }
|
{ fp1 - integer parameter }
|
||||||
|
|
||||||
|
|
||||||
procedure GenR1t (fop: pcodes; rval: double; fp1: integer; tp: baseTypeEnum);
|
procedure GenR1t (fop: pcodes; rval: extended; fp1: integer; tp: baseTypeEnum);
|
||||||
|
|
||||||
{ generate an instruction that uses a real and an int }
|
{ generate an instruction that uses a real and an int }
|
||||||
{ }
|
{ }
|
||||||
|
@ -605,7 +605,7 @@ procedure GenLdcQuad (qval: longlong);
|
||||||
{ qval - value to load }
|
{ qval - value to load }
|
||||||
|
|
||||||
|
|
||||||
procedure GenLdcReal (rval: double);
|
procedure GenLdcReal (rval: extended);
|
||||||
|
|
||||||
{ load a real constant }
|
{ load a real constant }
|
||||||
{ }
|
{ }
|
||||||
|
@ -1247,7 +1247,7 @@ if codeGeneration then begin
|
||||||
end; {GenQ1}
|
end; {GenQ1}
|
||||||
|
|
||||||
|
|
||||||
procedure GenR1t {fop: pcodes; rval: double; fp1: integer; tp: baseTypeEnum};
|
procedure GenR1t {fop: pcodes; rval: extended; fp1: integer; tp: baseTypeEnum};
|
||||||
|
|
||||||
{ generate an instruction that uses a real and an int }
|
{ generate an instruction that uses a real and an int }
|
||||||
{ }
|
{ }
|
||||||
|
@ -1335,7 +1335,7 @@ if codeGeneration then begin
|
||||||
end; {GenTool}
|
end; {GenTool}
|
||||||
|
|
||||||
|
|
||||||
procedure GenLdcReal {rval: double};
|
procedure GenLdcReal {rval: extended};
|
||||||
|
|
||||||
{ load a real constant }
|
{ load a real constant }
|
||||||
{ }
|
{ }
|
||||||
|
|
20
DAG.pas
20
DAG.pas
|
@ -489,7 +489,7 @@ var
|
||||||
opcode: pcodes; {temp opcode}
|
opcode: pcodes; {temp opcode}
|
||||||
optype: baseTypeEnum; {temp optype}
|
optype: baseTypeEnum; {temp optype}
|
||||||
q: integer; {temp for integer calculations}
|
q: integer; {temp for integer calculations}
|
||||||
rval: double; {temp for real calculations}
|
rval: extended; {temp for real calculations}
|
||||||
|
|
||||||
fromtype, totype, firstType: record {for converting numbers to optypes}
|
fromtype, totype, firstType: record {for converting numbers to optypes}
|
||||||
case boolean of
|
case boolean of
|
||||||
|
@ -1232,14 +1232,9 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
end;
|
end;
|
||||||
cgQuad,cgUQuad: ;
|
cgQuad,cgUQuad: ;
|
||||||
cgDouble,cgExtended: begin
|
cgDouble,cgExtended: begin
|
||||||
{only convert values exactly representable in double}
|
|
||||||
rval := CnvLLX(op^.left^.qval);
|
rval := CnvLLX(op^.left^.qval);
|
||||||
if rval = CnvLLX(op^.left^.qval) then begin
|
op^.left^.qval := longlong0;
|
||||||
op^.left^.qval := longlong0;
|
op^.left^.rval := rval;
|
||||||
op^.left^.rval := rval;
|
|
||||||
end {if}
|
|
||||||
else
|
|
||||||
doit := false;
|
|
||||||
end;
|
end;
|
||||||
cgReal,cgComp:
|
cgReal,cgComp:
|
||||||
doit := false;
|
doit := false;
|
||||||
|
@ -1259,14 +1254,9 @@ case op^.opcode of {check for optimizations of this node}
|
||||||
end;
|
end;
|
||||||
cgQuad,cgUQuad: ;
|
cgQuad,cgUQuad: ;
|
||||||
cgDouble,cgExtended: begin
|
cgDouble,cgExtended: begin
|
||||||
{only convert values exactly representable in double}
|
|
||||||
rval := CnvULLX(op^.left^.qval);
|
rval := CnvULLX(op^.left^.qval);
|
||||||
if rval = CnvULLX(op^.left^.qval) then begin
|
op^.left^.qval := longlong0;
|
||||||
op^.left^.qval := longlong0;
|
op^.left^.rval := rval;
|
||||||
op^.left^.rval := rval;
|
|
||||||
end {if}
|
|
||||||
else
|
|
||||||
doit := false;
|
|
||||||
end;
|
end;
|
||||||
cgReal,cgComp:
|
cgReal,cgComp:
|
||||||
doit := false;
|
doit := false;
|
||||||
|
|
|
@ -969,9 +969,8 @@ var
|
||||||
lCodeGeneration: boolean; {local copy of codeGeneration}
|
lCodeGeneration: boolean; {local copy of codeGeneration}
|
||||||
op: tokenPtr; {work pointer}
|
op: tokenPtr; {work pointer}
|
||||||
op1,op2: longint; {for evaluating constant expressions}
|
op1,op2: longint; {for evaluating constant expressions}
|
||||||
rop1,rop2: double; {for evaluating double expressions}
|
rop1,rop2: extended; {for evaluating fp expressions}
|
||||||
llop1, llop2: longlong; {for evaluating long long expressions}
|
llop1, llop2: longlong; {for evaluating long long expressions}
|
||||||
extop1: extended; {temporary for conversions}
|
|
||||||
tp: typePtr; {cast type}
|
tp: typePtr; {cast type}
|
||||||
unsigned: boolean; {is the term unsigned?}
|
unsigned: boolean; {is the term unsigned?}
|
||||||
|
|
||||||
|
@ -1454,23 +1453,13 @@ var
|
||||||
end; {if}
|
end; {if}
|
||||||
|
|
||||||
if op^.right^.token.kind in [intconst,uintconst,longconst,ulongconst,
|
if op^.right^.token.kind in [intconst,uintconst,longconst,ulongconst,
|
||||||
longlongconst,ulonglongconst,doubleconst] then
|
longlongconst,ulonglongconst,extendedconst] then
|
||||||
if op^.left^.token.kind in [intconst,uintconst,longconst,ulongconst,
|
if op^.left^.token.kind in [intconst,uintconst,longconst,ulongconst,
|
||||||
longlongconst,ulonglongconst,doubleconst] then
|
longlongconst,ulonglongconst,extendedconst] then
|
||||||
begin
|
begin
|
||||||
ekind := doubleconst; {evaluate a constant operation}
|
ekind := extendedconst; {evaluate a constant operation}
|
||||||
extop1 := RealVal(op^.left^.token);
|
rop1 := RealVal(op^.left^.token);
|
||||||
rop1 := extop1;
|
rop2 := RealVal(op^.right^.token);
|
||||||
if op^.left^.token.kind in [longlongconst,ulonglongconst] then
|
|
||||||
if rop1 <> extop1 then
|
|
||||||
if not (op^.token.kind in [barbarop,andandop]) then
|
|
||||||
goto 1;
|
|
||||||
extop1 := RealVal(op^.right^.token);
|
|
||||||
rop2 := extop1;
|
|
||||||
if op^.right^.token.kind in [longlongconst,ulonglongconst] then
|
|
||||||
if rop2 <> extop1 then
|
|
||||||
if not (op^.token.kind in [barbarop,andandop]) then
|
|
||||||
goto 1;
|
|
||||||
dispose(op^.right);
|
dispose(op^.right);
|
||||||
op^.right := nil;
|
op^.right := nil;
|
||||||
dispose(op^.left);
|
dispose(op^.left);
|
||||||
|
@ -1522,8 +1511,8 @@ var
|
||||||
end {if}
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
op^.token.rval := rop1;
|
op^.token.rval := rop1;
|
||||||
op^.token.class := doubleConstant;
|
op^.token.class := realConstant;
|
||||||
op^.token.kind := doubleConst;
|
op^.token.kind := extendedConst;
|
||||||
end; {else}
|
end; {else}
|
||||||
end; {if}
|
end; {if}
|
||||||
1:
|
1:
|
||||||
|
@ -1574,7 +1563,7 @@ var
|
||||||
else if op^.token.kind = castoper then begin
|
else if op^.token.kind = castoper then begin
|
||||||
class := op^.left^.token.class;
|
class := op^.left^.token.class;
|
||||||
if class in [intConstant,longConstant,longlongconstant,
|
if class in [intConstant,longConstant,longlongconstant,
|
||||||
doubleConstant] then begin
|
realConstant] then begin
|
||||||
tp := op^.castType;
|
tp := op^.castType;
|
||||||
while tp^.kind = definedType do
|
while tp^.kind = definedType do
|
||||||
tp := tp^.dType;
|
tp := tp^.dType;
|
||||||
|
@ -1582,7 +1571,7 @@ var
|
||||||
baseType := tp^.baseType;
|
baseType := tp^.baseType;
|
||||||
if (baseType < cgString) or (baseType in [cgQuad,cgUQuad])
|
if (baseType < cgString) or (baseType in [cgQuad,cgUQuad])
|
||||||
then begin
|
then begin
|
||||||
if class = doubleConstant then begin
|
if class = realConstant then begin
|
||||||
rop1 := RealVal(op^.left^.token);
|
rop1 := RealVal(op^.left^.token);
|
||||||
if baseType = cgUQuad then
|
if baseType = cgUQuad then
|
||||||
CnvXULL(llop1, rop1)
|
CnvXULL(llop1, rop1)
|
||||||
|
@ -1592,13 +1581,9 @@ var
|
||||||
else begin {handle integer constants}
|
else begin {handle integer constants}
|
||||||
GetLongLongVal(llop1, op^.left^.token);
|
GetLongLongVal(llop1, op^.left^.token);
|
||||||
if op^.left^.token.kind = ulonglongconst then
|
if op^.left^.token.kind = ulonglongconst then
|
||||||
extop1 := CnvULLX(llop1)
|
rop1 := CnvULLX(llop1)
|
||||||
else
|
else
|
||||||
extop1 := CnvLLX(llop1);
|
rop1 := CnvLLX(llop1);
|
||||||
rop1 := extop1;
|
|
||||||
if baseType in [cgExtended,cgComp] then
|
|
||||||
if rop1 <> extop1 then
|
|
||||||
goto 3;
|
|
||||||
end; {else if}
|
end; {else if}
|
||||||
dispose(op^.left);
|
dispose(op^.left);
|
||||||
op^.left := nil;
|
op^.left := nil;
|
||||||
|
@ -1648,8 +1633,8 @@ var
|
||||||
op^.token.qval := llop1;
|
op^.token.qval := llop1;
|
||||||
end {else if}
|
end {else if}
|
||||||
else begin
|
else begin
|
||||||
op^.token.kind := doubleConst;
|
op^.token.kind := extendedConst;
|
||||||
op^.token.class := doubleConstant;
|
op^.token.class := realConstant;
|
||||||
op^.token.rval := rop1;
|
op^.token.rval := rop1;
|
||||||
end; {else if}
|
end; {else if}
|
||||||
end; {if}
|
end; {if}
|
||||||
|
@ -1727,15 +1712,15 @@ var
|
||||||
op^.token.ival := long(op1).lsw;
|
op^.token.ival := long(op1).lsw;
|
||||||
end; {else}
|
end; {else}
|
||||||
end {else if}
|
end {else if}
|
||||||
else if op^.left^.token.kind = doubleconst then begin
|
else if op^.left^.token.kind = extendedconst then begin
|
||||||
ekind := doubleconst; {evaluate a constant operation}
|
ekind := extendedconst; {evaluate a constant operation}
|
||||||
rop1 := RealVal(op^.left^.token);
|
rop1 := RealVal(op^.left^.token);
|
||||||
dispose(op^.left);
|
dispose(op^.left);
|
||||||
op^.left := nil;
|
op^.left := nil;
|
||||||
case op^.token.kind of
|
case op^.token.kind of
|
||||||
uminus : begin {unary -}
|
uminus : begin {unary -}
|
||||||
op^.token.class := doubleConstant;
|
op^.token.class := realConstant;
|
||||||
op^.token.kind := doubleConst;
|
op^.token.kind := extendedConst;
|
||||||
op^.token.rval := -rop1;
|
op^.token.rval := -rop1;
|
||||||
end;
|
end;
|
||||||
excch : begin {!}
|
excch : begin {!}
|
||||||
|
@ -1745,8 +1730,8 @@ var
|
||||||
end;
|
end;
|
||||||
otherwise : begin {illegal operation}
|
otherwise : begin {illegal operation}
|
||||||
Error(66);
|
Error(66);
|
||||||
op^.token.class := doubleConstant;
|
op^.token.class := realConstant;
|
||||||
op^.token.kind := doubleConst;
|
op^.token.kind := extendedConst;
|
||||||
op^.token.rval := rop1;
|
op^.token.rval := rop1;
|
||||||
end;
|
end;
|
||||||
end; {case}
|
end; {case}
|
||||||
|
@ -1812,10 +1797,10 @@ if token.kind in startExpression then begin
|
||||||
sp^.right := nil;
|
sp^.right := nil;
|
||||||
stack := sp;
|
stack := sp;
|
||||||
if kind in [preprocessorExpression,arrayExpression] then
|
if kind in [preprocessorExpression,arrayExpression] then
|
||||||
if token.kind in [stringconst,doubleconst] then begin
|
if token.kind in [stringconst,extendedconst] then begin
|
||||||
if kind = arrayExpression then begin
|
if kind = arrayExpression then begin
|
||||||
op := opStack;
|
op := opStack;
|
||||||
if token.kind = doubleconst then
|
if token.kind = extendedconst then
|
||||||
if op <> nil then
|
if op <> nil then
|
||||||
if op^.token.kind = castoper then
|
if op^.token.kind = castoper then
|
||||||
if op^.casttype^.kind = scalarType then
|
if op^.casttype^.kind = scalarType then
|
||||||
|
@ -3148,7 +3133,7 @@ var
|
||||||
or ((divisor.class = longConstant) and (divisor.lval = 0))
|
or ((divisor.class = longConstant) and (divisor.lval = 0))
|
||||||
or ((divisor.class = longlongConstant)
|
or ((divisor.class = longlongConstant)
|
||||||
and (divisor.qval.lo = 0) and (divisor.qval.hi = 0))
|
and (divisor.qval.lo = 0) and (divisor.qval.hi = 0))
|
||||||
or ((divisor.class = doubleConstant) and (divisor.rval = 0.0)) then
|
or ((divisor.class = realConstant) and (divisor.rval = 0.0)) then
|
||||||
Error(129);
|
Error(129);
|
||||||
end; {CheckDivByZero}
|
end; {CheckDivByZero}
|
||||||
|
|
||||||
|
@ -3270,10 +3255,10 @@ case tree^.token.kind of
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {case longlongConst}
|
end; {case longlongConst}
|
||||||
|
|
||||||
doubleConst: begin
|
extendedConst: begin
|
||||||
GenLdcReal(tree^.token.rval);
|
GenLdcReal(tree^.token.rval);
|
||||||
expressionType := doublePtr;
|
expressionType := doublePtr;
|
||||||
end; {case doubleConst}
|
end; {case extendedConst}
|
||||||
|
|
||||||
stringConst: begin
|
stringConst: begin
|
||||||
GenS(pc_lca, tree^.token.sval);
|
GenS(pc_lca, tree^.token.sval);
|
||||||
|
@ -4395,7 +4380,7 @@ else begin {record the expression for an initialize
|
||||||
expressionType := ulongLongPtr;
|
expressionType := ulongLongPtr;
|
||||||
isConstant := true;
|
isConstant := true;
|
||||||
end {else if}
|
end {else if}
|
||||||
else if tree^.token.kind = doubleconst then begin
|
else if tree^.token.kind = extendedconst then begin
|
||||||
realExpressionValue := tree^.token.rval;
|
realExpressionValue := tree^.token.rval;
|
||||||
expressionType := extendedPtr;
|
expressionType := extendedPtr;
|
||||||
isConstant := true;
|
isConstant := true;
|
||||||
|
@ -4450,7 +4435,7 @@ procedure InitExpression;
|
||||||
|
|
||||||
begin {InitExpression}
|
begin {InitExpression}
|
||||||
startTerm := [ident,intconst,uintconst,longconst,ulongconst,longlongconst,
|
startTerm := [ident,intconst,uintconst,longconst,ulongconst,longlongconst,
|
||||||
ulonglongconst,doubleconst,stringconst,_Genericsy];
|
ulonglongconst,extendedconst,stringconst,_Genericsy];
|
||||||
startExpression:= startTerm +
|
startExpression:= startTerm +
|
||||||
[lparench,asteriskch,andch,plusch,minusch,excch,tildech,sizeofsy,
|
[lparench,asteriskch,andch,plusch,minusch,excch,tildech,sizeofsy,
|
||||||
plusplusop,minusminusop,typedef,_Alignofsy];
|
plusplusop,minusminusop,typedef,_Alignofsy];
|
||||||
|
|
3
Gen.pas
3
Gen.pas
|
@ -5862,7 +5862,7 @@ procedure GenTree {op: icptr};
|
||||||
{ Generate code for a pc_ldc }
|
{ Generate code for a pc_ldc }
|
||||||
|
|
||||||
type
|
type
|
||||||
kind = (vint, vbyte, vreal); {kinds of equivalenced data}
|
kind = (vint, vbyte); {kinds of equivalenced data}
|
||||||
|
|
||||||
var
|
var
|
||||||
i: integer; {loop/index variable}
|
i: integer; {loop/index variable}
|
||||||
|
@ -5871,7 +5871,6 @@ procedure GenTree {op: icptr};
|
||||||
case rkind: kind of
|
case rkind: kind of
|
||||||
vint: (i: integer);
|
vint: (i: integer);
|
||||||
vbyte: (b1, b2, b3, b4, b5, b6, b7, b8: byte);
|
vbyte: (b1, b2, b3, b4, b5, b6, b7, b8: byte);
|
||||||
vreal: (r: double);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin {GenLdc}
|
begin {GenLdc}
|
||||||
|
|
42
Header.pas
42
Header.pas
|
@ -18,7 +18,7 @@ uses CCommon, MM, Scanner, Symbol, CGI;
|
||||||
{$segment 'SCANNER'}
|
{$segment 'SCANNER'}
|
||||||
|
|
||||||
const
|
const
|
||||||
symFileVersion = 10; {version number of .sym file format}
|
symFileVersion = 11; {version number of .sym file format}
|
||||||
|
|
||||||
var
|
var
|
||||||
inhibitHeader: boolean; {should .sym includes be blocked?}
|
inhibitHeader: boolean; {should .sym includes be blocked?}
|
||||||
|
@ -280,19 +280,19 @@ if numErrors <> 0 then
|
||||||
end; {CloseSymbols}
|
end; {CloseSymbols}
|
||||||
|
|
||||||
|
|
||||||
function ReadDouble: double;
|
function ReadExtended: extended;
|
||||||
|
|
||||||
{ Read a double precision real from the symbol file }
|
{ Read an extended precision real from the symbol file }
|
||||||
{ }
|
{ }
|
||||||
{ Returns: value read }
|
{ Returns: value read }
|
||||||
|
|
||||||
type
|
type
|
||||||
doubleptr = ^double;
|
extendedptr = ^extended;
|
||||||
|
|
||||||
begin {ReadDouble}
|
begin {ReadExtended}
|
||||||
ReadDouble := doubleptr(symPtr)^;
|
ReadExtended := extendedptr(symPtr)^;
|
||||||
symPtr := pointer(ord4(symPtr)+8);
|
symPtr := pointer(ord4(symPtr)+10);
|
||||||
end; {ReadDouble}
|
end; {ReadExtended}
|
||||||
|
|
||||||
|
|
||||||
function ReadLong: longint;
|
function ReadLong: longint;
|
||||||
|
@ -400,24 +400,24 @@ symPtr := pointer(ord4(symPtr) + len);
|
||||||
end; {ReadChars}
|
end; {ReadChars}
|
||||||
|
|
||||||
|
|
||||||
procedure WriteDouble (d: double);
|
procedure WriteExtended (e: extended);
|
||||||
|
|
||||||
{ Write a double constant to the symbol file }
|
{ Write an extended constant to the symbol file }
|
||||||
{ }
|
{ }
|
||||||
{ parameters: }
|
{ parameters: }
|
||||||
{ d - constant to write }
|
{ e - constant to write }
|
||||||
|
|
||||||
var
|
var
|
||||||
dPtr: ^double; {work pointer}
|
ePtr: ^extended; {work pointer}
|
||||||
|
|
||||||
begin {WriteDouble}
|
begin {WriteExtended}
|
||||||
if bufLen < 8 then
|
if bufLen < 10 then
|
||||||
Purge;
|
Purge;
|
||||||
dPtr := pointer(bufPtr);
|
ePtr := pointer(bufPtr);
|
||||||
dPtr^ := d;
|
ePtr^ := e;
|
||||||
bufPtr := pointer(ord4(bufPtr) + 8);
|
bufPtr := pointer(ord4(bufPtr) + 10);
|
||||||
bufLen := bufLen - 8;
|
bufLen := bufLen - 10;
|
||||||
end; {WriteDouble}
|
end; {WriteExtended}
|
||||||
|
|
||||||
|
|
||||||
procedure WriteLong (i: longint);
|
procedure WriteLong (i: longint);
|
||||||
|
@ -715,7 +715,7 @@ procedure EndInclude {chPtr: ptr};
|
||||||
WriteLong(token.qval.lo);
|
WriteLong(token.qval.lo);
|
||||||
WriteLong(token.qval.hi);
|
WriteLong(token.qval.hi);
|
||||||
end;
|
end;
|
||||||
doubleConstant: WriteDouble(token.rval);
|
realConstant: WriteExtended(token.rval);
|
||||||
stringConstant: begin
|
stringConstant: begin
|
||||||
WriteLongString(token.sval);
|
WriteLongString(token.sval);
|
||||||
WriteByte(ord(token.ispstring));
|
WriteByte(ord(token.ispstring));
|
||||||
|
@ -1339,7 +1339,7 @@ var
|
||||||
token.qval.lo := ReadLong;
|
token.qval.lo := ReadLong;
|
||||||
token.qval.hi := ReadLong;
|
token.qval.hi := ReadLong;
|
||||||
end;
|
end;
|
||||||
doubleConstant: token.rval := ReadDouble;
|
realConstant: token.rval := ReadExtended;
|
||||||
stringConstant: begin
|
stringConstant: begin
|
||||||
token.sval := ReadLongString;
|
token.sval := ReadLongString;
|
||||||
token.ispstring := ReadByte <> 0;
|
token.ispstring := ReadByte <> 0;
|
||||||
|
|
12
Scanner.pas
12
Scanner.pas
|
@ -752,7 +752,7 @@ case token.kind of
|
||||||
longlongConst,
|
longlongConst,
|
||||||
ulonglongConst: write('0x...'); {TODO implement}
|
ulonglongConst: write('0x...'); {TODO implement}
|
||||||
|
|
||||||
doubleConst: write(token.rval:1);
|
extendedConst: write(token.rval:1);
|
||||||
|
|
||||||
stringConst: begin
|
stringConst: begin
|
||||||
write('"');
|
write('"');
|
||||||
|
@ -2330,7 +2330,7 @@ var
|
||||||
if (tk1^.token.qval.lo <> tk2^.token.qval.lo) or
|
if (tk1^.token.qval.lo <> tk2^.token.qval.lo) or
|
||||||
(tk1^.token.qval.hi <> tk2^.token.qval.hi) then
|
(tk1^.token.qval.hi <> tk2^.token.qval.hi) then
|
||||||
goto 3;
|
goto 3;
|
||||||
doubleConstant:
|
realConstant:
|
||||||
if tk1^.token.rval <> tk2^.token.rval then
|
if tk1^.token.rval <> tk2^.token.rval then
|
||||||
goto 3;
|
goto 3;
|
||||||
stringConstant: begin
|
stringConstant: begin
|
||||||
|
@ -3356,8 +3356,8 @@ numString[0] := chr(stringIndex); {set the length of the string}
|
||||||
if doingPPExpression then
|
if doingPPExpression then
|
||||||
isLongLong := true;
|
isLongLong := true;
|
||||||
if isReal then begin {convert a real constant}
|
if isReal then begin {convert a real constant}
|
||||||
token.kind := doubleConst;
|
token.kind := extendedConst;
|
||||||
token.class := doubleConstant;
|
token.class := realConstant;
|
||||||
if stringIndex > 80 then begin
|
if stringIndex > 80 then begin
|
||||||
FlagError(131);
|
FlagError(131);
|
||||||
token.rval := 0.0;
|
token.rval := 0.0;
|
||||||
|
@ -3797,7 +3797,7 @@ lintErrors := [51,104,105,110,124,125,128,129,130,147,151,152,153,154,155];
|
||||||
spaceStr := ' '; {strings used in stringization}
|
spaceStr := ' '; {strings used in stringization}
|
||||||
quoteStr := '"';
|
quoteStr := '"';
|
||||||
{set of classes for numeric constants}
|
{set of classes for numeric constants}
|
||||||
numericConstants := [intConstant,longConstant,longlongConstant,doubleConstant];
|
numericConstants := [intConstant,longConstant,longlongConstant,realConstant];
|
||||||
|
|
||||||
new(mp); {__LINE__}
|
new(mp); {__LINE__}
|
||||||
mp^.name := @'__LINE__';
|
mp^.name := @'__LINE__';
|
||||||
|
@ -3965,7 +3965,7 @@ repeat
|
||||||
case token.class of
|
case token.class of
|
||||||
intConstant : token.ival := -token.ival;
|
intConstant : token.ival := -token.ival;
|
||||||
longConstant : token.lval := -token.lval;
|
longConstant : token.lval := -token.lval;
|
||||||
doubleConstant: token.rval := -token.rval;
|
realConstant : token.rval := -token.rval;
|
||||||
longlongConstant,otherwise: Error(108);
|
longlongConstant,otherwise: Error(108);
|
||||||
end; {case}
|
end; {case}
|
||||||
end {if}
|
end {if}
|
||||||
|
|
|
@ -285,7 +285,7 @@ charSym start single character symbols
|
||||||
enum ident,0 identifiers
|
enum ident,0 identifiers
|
||||||
! constants
|
! constants
|
||||||
enum (intconst,uintconst,longconst,ulongconst,longlongconst)
|
enum (intconst,uintconst,longconst,ulongconst,longlongconst)
|
||||||
enum (ulonglongconst,doubleconst)
|
enum (ulonglongconst,extendedconst)
|
||||||
enum stringconst
|
enum stringconst
|
||||||
! reserved words
|
! reserved words
|
||||||
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
|
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
|
||||||
|
@ -359,7 +359,7 @@ icp start in-coming priority for expression
|
||||||
dc i1'200' ulongconst
|
dc i1'200' ulongconst
|
||||||
dc i1'200' longlongconst
|
dc i1'200' longlongconst
|
||||||
dc i1'200' ulonglongconst
|
dc i1'200' ulonglongconst
|
||||||
dc i1'200' doubleconst
|
dc i1'200' extendedconst
|
||||||
dc i1'200' stringconst
|
dc i1'200' stringconst
|
||||||
dc i1'200' _Alignassy
|
dc i1'200' _Alignassy
|
||||||
dc i1'16' _Alignofsy
|
dc i1'16' _Alignofsy
|
||||||
|
@ -526,7 +526,7 @@ isp start in stack priority for expression
|
||||||
dc i1'0' ulongconst
|
dc i1'0' ulongconst
|
||||||
dc i1'0' longlongconst
|
dc i1'0' longlongconst
|
||||||
dc i1'0' ulonglongconst
|
dc i1'0' ulonglongconst
|
||||||
dc i1'0' doubleconst
|
dc i1'0' extendedconst
|
||||||
dc i1'0' stringconst
|
dc i1'0' stringconst
|
||||||
dc i1'0' _Alignassy
|
dc i1'0' _Alignassy
|
||||||
dc i1'16' _Alignofsy
|
dc i1'16' _Alignofsy
|
||||||
|
@ -899,7 +899,7 @@ wordHash start reserved word hash table
|
||||||
enum ident,0 identifiers
|
enum ident,0 identifiers
|
||||||
! constants
|
! constants
|
||||||
enum (intconst,uintconst,longconst,ulongconst,longlongconst)
|
enum (intconst,uintconst,longconst,ulongconst,longlongconst)
|
||||||
enum (ulonglongconst,doubleconst)
|
enum (ulonglongconst,extendedconst)
|
||||||
enum stringconst
|
enum stringconst
|
||||||
! reserved words
|
! reserved words
|
||||||
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
|
enum (_Alignassy,_Alignofsy,_Atomicsy,_Boolsy,_Complexsy)
|
||||||
|
|
Loading…
Reference in New Issue