codetools: added nativeint, nativeuint for pas2js

git-svn-id: branches/fixes_1_8@54660 -
This commit is contained in:
mattias 2017-04-21 17:06:25 +00:00
parent b06073799d
commit d51465d0fb
4 changed files with 49 additions and 26 deletions

View File

@ -6430,7 +6430,9 @@ begin
xtWord,
xtSmallInt,
xtShortInt,
xtByte: AddAssignment('0');
xtByte,
xtNativeInt,
xtNativeUInt: AddAssignment('0');
xtVariant: begin AddAssignment('0'); AddAssignment(''''''); end;
xtJSValue: begin AddAssignment('0'); AddAssignment(''''''); AddAssignment('nil'); AddAssignment('false'); end;
end;

View File

@ -263,6 +263,8 @@ type
xtSmallInt, // smallint
xtShortInt, // shortint
xtByte, // byte
xtNativeInt, // depends on compiler and platform
xtNativeUInt, // depends on compiler and platform
xtCompilerFunc,// SUCC, PREC, LOW, HIGH, ORD, LENGTH, COPY (1.1)
xtVariant, // variant
xtJSValue, // jsvalue only in Pas2JS, similar to variant
@ -312,6 +314,8 @@ var
'SmallInt',
'ShortInt',
'Byte',
'NativeInt',
'NativeUInt',
'CompilerFunc',
'Variant',
'JSValue',
@ -327,7 +331,7 @@ const
xtAllIdentPredefinedTypes = xtAllIdentTypes - [xtContext];
xtAllIntegerTypes = [xtInt64, xtQWord, xtConstOrdInteger, xtLongint,
xtLongWord, xtWord, xtCardinal, xtSmallInt, xtShortInt,
xtByte];
xtByte,xtNativeInt,xtNativeUInt];
xtAllBooleanTypes = [xtBoolean, xtByteBool, xtWordBool, xtLongBool,xtQWordBool];
xtAllRealTypes = [xtReal, xtConstReal, xtSingle, xtDouble,
xtExtended, xtCExtended, xtCurrency, xtComp];
@ -345,6 +349,7 @@ const
xtAllWideStringConvertibles = xtAllWideStringCompatibleTypes+[xtPChar];
xtAllBooleanConvertibles = xtAllBooleanTypes+[xtConstBoolean];
xtAllPointerConvertibles = xtAllPointerTypes+[xtPChar];
xtAllPas2JSExtraTypes = [xtJSValue,xtNativeInt,xtNativeUInt];
type
{ TExpressionType is used for compatibility check
@ -1190,7 +1195,7 @@ function RealTypesOrderList: TTypeAliasOrderList;
begin
if FRealTypesOrderList=nil then
FRealTypesOrderList:=TTypeAliasOrderList.Create([
'Extended', 'Double', 'Single']);
'Extended', 'Real', 'Double', 'Single']);
Result := FRealTypesOrderList;
end;
@ -1302,12 +1307,6 @@ begin
Result:=xtConstBoolean
else if CompareIdentifiers(Identifier,'VARIANT')=0 then
Result:=xtVariant
else if (Compiler=pcPas2js) and (CompareIdentifiers(Identifier,'JSVALUE')=0) then
Result:=xtJSValue
else if IsWordBuiltInFunc.DoItCaseInsensitive(Identifier) then
Result:=xtCompilerFunc
// the delphi compiler special types
else if CompareIdentifiers(Identifier,'CURRENCY')=0 then
Result:=xtCurrency
else if CompareIdentifiers(Identifier,'LONGINT')=0 then
@ -1326,7 +1325,25 @@ begin
Result:=xtByte
else if CompareIdentifiers(Identifier,'PCHAR')=0 then
Result:=xtPChar
else
else if IsWordBuiltInFunc.DoItCaseInsensitive(Identifier) then
Result:=xtCompilerFunc
else begin
// compiler specific
if (Compiler=pcPas2js) then begin
if CompareIdentifiers(Identifier,'JSVALUE')=0 then
exit(xtJSValue);
if CompareIdentifiers(Identifier,'NATIVEINT')=0 then
exit(xtNativeInt);
if CompareIdentifiers(Identifier,'NATIVEUINT')=0 then
exit(xtNativeUInt);
end;
if (Compiler=pcDelphi) then begin
if CompareIdentifiers(Identifier,'NATIVEINT')=0 then
exit(xtNativeInt);
if CompareIdentifiers(Identifier,'NATIVEUINT')=0 then
exit(xtNativeUInt);
end;
end;
Result:=xtNone;
end;
@ -12143,7 +12160,9 @@ begin
xtByteBool,
xtWordBool,
xtLongBool,
xtQWordBool:
xtQWordBool,
xtNativeInt,
xtNativeUInt:
Result:=ExpressionTypeDescNames[TermExprType.Desc];
xtNone,
xtWideChar,
@ -12879,7 +12898,9 @@ begin
xtWord,
xtSmallInt,
xtShortInt,
xtByte:
xtByte,
xtNativeInt,
xtNativeUInt:
Result:='P'+ExpressionTypeDescNames[ExprType.SubDesc];
else
Result:=ExpressionTypeDescNames[xtPointer];
@ -12891,9 +12912,11 @@ begin
xtLongint,
xtLongWord,
xtSmallInt,
xtWord,
xtShortInt,
xtByte,
xtWord:
xtNativeInt,
xtNativeUInt:
Result:=ExpressionTypeDescNames[ExprType.Desc];
xtBoolean,

View File

@ -1493,18 +1493,15 @@ begin
// system types
if InSystemContext then
begin
for I := Low(I) to High(I) do
begin
case I of
xtChar..xtPointer, xtLongint..xtByte, xtVariant:
AddBaseType(PChar(ExpressionTypeDescNames[I]));
xtFile, xtText:
if not (ilcfStartInStatement in CurrentIdentifierList.ContextFlags) then
AddBaseType(PChar(ExpressionTypeDescNames[I]));
end;
for I in [xtChar..xtPointer, xtLongint..xtByte, xtVariant] do
AddBaseType(PChar(ExpressionTypeDescNames[I]));
if not (ilcfStartInStatement in CurrentIdentifierList.ContextFlags) then
for I in [xtFile, xtText] do
AddBaseType(PChar(ExpressionTypeDescNames[I]));
if Scanner.PascalCompiler=pcPas2js then begin
for I in xtAllPas2JSExtraTypes do
AddBaseType(PChar(ExpressionTypeDescNames[I]));
end;
if Scanner.PascalCompiler=pcPas2js then
AddBaseType(PChar(ExpressionTypeDescNames[xtJSValue]));
AddBaseConstant('True');
AddBaseConstant('False');
//the nil constant doesn't belong to system context, therefore it is added in next step

View File

@ -1777,19 +1777,20 @@ begin
Add('BREAK' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('BYTE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('BYTEBOOL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('CARDINAL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('CHAR' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('CONTINUE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('DOUBLE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('EXIT' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('FALSE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('HIGH' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('JSINTEGER' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('JSVALUE' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LENGTH' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LONGBOOL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LONGINT' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LONGWORD' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LOW' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('NATIVEINT' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('NATIVEUINT' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('NIL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('ORD' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('PRED' ,{$ifdef FPC}@{$endif}AllwaysTrue);