Initial code to recognize 'long long' as a type.

This commit is contained in:
Stephen Heumann 2021-01-29 20:50:21 -06:00
parent b1d4d8d668
commit 085cd7eb1b
7 changed files with 57 additions and 14 deletions

View File

@ -114,6 +114,7 @@ type
{Misc.} {Misc.}
{-----} {-----}
long = record lsw,msw: integer; end; {for extracting words from longints} long = record lsw,msw: integer; end; {for extracting words from longints}
longlong = record low32,high32: longint; end; {64-bit integer representation}
cString = packed array [1..256] of char; {null terminated string} cString = packed array [1..256] of char; {null terminated string}
cStringPtr = ^cString; cStringPtr = ^cString;
@ -146,7 +147,7 @@ type
{ the compiler. Any values whose type is cc must be resolved to one } { the compiler. Any values whose type is cc must be resolved to one }
{ of the cg types before the code generator is called. } { of the cg types before the code generator is called. }
baseTypeEnum = (cgByte,cgUByte,cgWord,cgUWord,cgLong,cgULong, baseTypeEnum = (cgByte,cgUByte,cgWord,cgUWord,cgLong,cgULong,cgQuad,cgUQuad,
cgReal,cgDouble,cgComp,cgExtended,cgString, cgReal,cgDouble,cgComp,cgExtended,cgString,
cgVoid,ccPointer); cgVoid,ccPointer);
@ -157,7 +158,7 @@ type
cTypeEnum = (ctChar, ctSChar, ctUChar, ctShort, ctUShort, ctInt, ctUInt, cTypeEnum = (ctChar, ctSChar, ctUChar, ctShort, ctUShort, ctInt, ctUInt,
ctLong, ctULong, ctFloat, ctDouble, ctLongDouble, ctComp, ctLong, ctULong, ctFloat, ctDouble, ctLongDouble, ctComp,
ctVoid, ctInt32, ctUInt32, ctBool); ctVoid, ctInt32, ctUInt32, ctBool, ctLongLong, ctULongLong);
{tokens} {tokens}
{------} {------}
@ -316,6 +317,8 @@ type
cgUWord, cgUWord,
cgLong, cgLong,
cgULong : (iVal: longint); cgULong : (iVal: longint);
cgQuad,
cgUQuad : (qVal: longlong);
cgString : (sVal: longstringPtr); cgString : (sVal: longstringPtr);
cgReal, cgReal,
cgDouble, cgDouble,

View File

@ -239,6 +239,8 @@ var
cgUWord: write('u'); cgUWord: write('u');
cgLong: write('l'); cgLong: write('l');
cgULong: write('ul'); cgULong: write('ul');
cgQuad: write('q');
cgUQuad: write('uq');
cgReal: write('r'); cgReal: write('r');
cgDouble: write('d'); cgDouble: write('d');
cgComp: write('c'); cgComp: write('c');

View File

@ -204,6 +204,7 @@ const
cgByteSize = 1; cgByteSize = 1;
cgWordSize = 2; cgWordSize = 2;
cgLongSize = 4; cgLongSize = 4;
cgQuadSize = 8;
cgPointerSize = 4; cgPointerSize = 4;
cgRealSize = 4; cgRealSize = 4;
cgDoubleSize = 8; cgDoubleSize = 8;
@ -246,6 +247,8 @@ type
cgUWord : (opnd: longint; llab,slab: integer); cgUWord : (opnd: longint; llab,slab: integer);
cgLong, cgLong,
cgULong : (lval: longint); cgULong : (lval: longint);
cgQuad,
cgUQuad : (qval: longlong);
cgReal, cgReal,
cgDouble, cgDouble,
cgComp, cgComp,
@ -1291,6 +1294,7 @@ case tp of
cgByte,cgUByte: TypeSize := cgByteSize; cgByte,cgUByte: TypeSize := cgByteSize;
cgWord,cgUWord: TypeSize := cgWordSize; cgWord,cgUWord: TypeSize := cgWordSize;
cgLong,cgULong: TypeSize := cgLongSize; cgLong,cgULong: TypeSize := cgLongSize;
cgQuad,cgUQuad: TypeSize := cgQuadSize;
cgReal: TypeSize := cgRealSize; cgReal: TypeSize := cgRealSize;
cgDouble: TypeSize := cgDoubleSize; cgDouble: TypeSize := cgDoubleSize;
cgComp: TypeSize := cgCompSize; cgComp: TypeSize := cgCompSize;

View File

@ -18,7 +18,7 @@ uses CCommon, MM, Scanner, Symbol, CGI;
{$segment 'SCANNER'} {$segment 'SCANNER'}
const const
symFileVersion = 8; {version number of .sym file format} symFileVersion = 9; {version number of .sym file format}
var var
inhibitHeader: boolean; {should .sym includes be blocked?} inhibitHeader: boolean; {should .sym includes be blocked?}

View File

@ -2602,6 +2602,8 @@ var
mySkipDeclarator: boolean; {value of skipDeclarator to generate} mySkipDeclarator: boolean; {value of skipDeclarator to generate}
myTypeSpec: typePtr; {value of typeSpec to generate} myTypeSpec: typePtr; {value of typeSpec to generate}
myDeclarationModifiers: tokenSet; {all modifiers in this declaration} myDeclarationModifiers: tokenSet; {all modifiers in this declaration}
isLongLong: boolean; {is this a "long long" type?}
procedure FieldList (tp: typePtr; kind: typeKind); procedure FieldList (tp: typePtr; kind: typeKind);
@ -2799,11 +2801,19 @@ var
else if (typeSpecifiers = [longsy]) else if (typeSpecifiers = [longsy])
or (typeSpecifiers = [signedsy,longsy]) or (typeSpecifiers = [signedsy,longsy])
or (typeSpecifiers = [longsy,intsy]) or (typeSpecifiers = [longsy,intsy])
or (typeSpecifiers = [signedsy,longsy,intsy]) then or (typeSpecifiers = [signedsy,longsy,intsy]) then begin
myTypeSpec := longPtr if isLongLong then
myTypeSpec := longLongPtr
else
myTypeSpec := longPtr;
end {else if}
else if (typeSpecifiers = [unsignedsy,longsy]) else if (typeSpecifiers = [unsignedsy,longsy])
or (typeSpecifiers = [unsignedsy,longsy,intsy]) then or (typeSpecifiers = [unsignedsy,longsy,intsy]) then begin
myTypeSpec := uLongPtr if isLongLong then
myTypeSpec := uLongLongPtr
else
myTypeSpec := uLongPtr;
end {else if}
else if typeSpecifiers = [floatsy] then else if typeSpecifiers = [floatsy] then
myTypeSpec := floatPtr myTypeSpec := floatPtr
else if typeSpecifiers = [doublesy] then else if typeSpecifiers = [doublesy] then
@ -2829,6 +2839,7 @@ myDeclarationModifiers := [];
typeSpecifiers := []; typeSpecifiers := [];
typeDone := false; typeDone := false;
isConstant := false; isConstant := false;
isLongLong := false;
while token.kind in allowedTokens do begin while token.kind in allowedTokens do begin
case token.kind of case token.kind of
{storage class specifiers} {storage class specifiers}
@ -2918,9 +2929,11 @@ while token.kind in allowedTokens do begin
if typeDone then if typeDone then
UnexpectedTokenError(expectedNext) UnexpectedTokenError(expectedNext)
else if token.kind in typeSpecifiers then begin else if token.kind in typeSpecifiers then begin
if (token.kind = longsy) if (token.kind = longsy) and
and (typeSpecifiers <= [signedsy,unsignedsy,longsy,intsy]) then ((myTypeSpec = longPtr) or (myTypeSpec = uLongPtr)) then begin
Error(134) isLongLong := true;
ResolveType;
end
else else
UnexpectedTokenError(expectedNext); UnexpectedTokenError(expectedNext);
end {if} end {if}

View File

@ -663,8 +663,8 @@ if list or (numErr <> 0) then begin
131: msg := @'numeric constant is too long'; 131: msg := @'numeric constant is too long';
132: msg := @'static assertion failed'; 132: msg := @'static assertion failed';
133: msg := @'incomplete or function types may not be used here'; 133: msg := @'incomplete or function types may not be used here';
134: msg := @'''long long'' types are not supported by ORCA/C'; {134: msg := @'''long long'' types are not supported by ORCA/C';}
135: msg := @'the type _Bool is not supported by ORCA/C'; {135: msg := @'the type _Bool is not supported by ORCA/C';}
136: msg := @'complex or imaginary types are not supported by ORCA/C'; 136: msg := @'complex or imaginary types are not supported by ORCA/C';
137: msg := @'atomic types are not supported by ORCA/C'; 137: msg := @'atomic types are not supported by ORCA/C';
138: msg := @'unsupported alignment'; 138: msg := @'unsupported alignment';

View File

@ -36,6 +36,8 @@
{ uInt32Ptr - pointer to the base type for 32-bit unsigned int } { uInt32Ptr - pointer to the base type for 32-bit unsigned int }
{ longPtr - pointer to the base type for long } { longPtr - pointer to the base type for long }
{ uLongPtr - pointer to the base type for unsigned long } { uLongPtr - pointer to the base type for unsigned long }
{ longLongPtr - pointer to the base type for long long }
{ uLongLongPtr - pointer to base type for unsigned long long }
{ floatPtr - pointer to the base type for float } { floatPtr - pointer to the base type for float }
{ doublePtr - pointer to the base type for double } { doublePtr - pointer to the base type for double }
{ compPtr - pointer to the base type for comp } { compPtr - pointer to the base type for comp }
@ -77,8 +79,9 @@ var
{base types} {base types}
charPtr,sCharPtr,uCharPtr,shortPtr,uShortPtr,intPtr,uIntPtr,int32Ptr, charPtr,sCharPtr,uCharPtr,shortPtr,uShortPtr,intPtr,uIntPtr,int32Ptr,
uInt32Ptr,longPtr,uLongPtr,floatPtr,doublePtr,compPtr,extendedPtr, uInt32Ptr,longPtr,uLongPtr,longLongPtr,uLongLongPtr,boolPtr,
boolPtr,stringTypePtr,voidPtr,voidPtrPtr,defaultStruct: typePtr; floatPtr,doublePtr,compPtr,extendedPtr,stringTypePtr,voidPtr,
voidPtrPtr,defaultStruct: typePtr;
{---------------------------------------------------------------} {---------------------------------------------------------------}
@ -1306,6 +1309,24 @@ with uLongPtr^ do begin
baseType := cgULong; baseType := cgULong;
cType := ctULong; cType := ctULong;
end; {with} end; {with}
new(longLongPtr); {long long}
with longLongPtr^ do begin
size := cgQuadSize;
saveDisp := 0;
isConstant := false;
kind := scalarType;
baseType := cgQuad;
cType := ctLongLong;
end; {with}
new(uLongLongPtr); {unsigned long}
with uLongLongPtr^ do begin
size := cgQuadSize;
saveDisp := 0;
isConstant := false;
kind := scalarType;
baseType := cgUQuad;
cType := ctULongLong;
end; {with}
new(floatPtr); {real} new(floatPtr); {real}
with floatPtr^ do begin with floatPtr^ do begin
size := cgRealSize; size := cgRealSize;