pastojs: rtti nativeint

git-svn-id: trunk@35871 -
This commit is contained in:
Mattias Gaertner 2017-04-21 09:10:05 +00:00
parent 5b98efe397
commit 10df48a129
2 changed files with 70 additions and 5 deletions

View File

@ -3792,6 +3792,16 @@ begin
MinValue:=0;
MaxValue:=$ffffffff;
end
else if RangeResolved.BaseType=btUIntDouble then
begin
MinValue:=0;
MaxValue:=HighJSNativeInt;
end
else if RangeResolved.BaseType=btIntDouble then
begin
MinValue:=LowJSNativeInt;
MaxValue:=HighJSNativeInt;
end
else if RangeResolved.BaseType in btAllJSChars then
begin
MinValue:=0;
@ -8802,7 +8812,10 @@ begin
begin
bt:=TResElDataBaseType(El.CustomData).BaseType;
case bt of
btLongint,btLongWord,btSmallInt,btWord,btShortInt,btByte,
btShortInt,btByte,
btSmallInt,btWord,
btLongint,btLongWord,
btIntDouble,btUIntDouble,
btString,btChar,
btDouble,
btBoolean,

View File

@ -255,6 +255,7 @@ type
Procedure TestSet_AnonymousEnumType;
Procedure TestSet_CharFail;
Procedure TestSet_BooleanFail;
Procedure TestSet_ConstEnum;
Procedure TestSet_ConstChar;
// statements
@ -3277,6 +3278,57 @@ begin
ConvertProgram;
end;
procedure TTestModule.TestSet_ConstEnum;
begin
StartProgram(false);
Add([
'type',
' TEnum = (red,blue,green);',
' TEnums = set of TEnum;',
'const',
' teAny = [low(TEnum)..high(TEnum)];',
' teRedBlue = [low(TEnum)..pred(high(TEnum))];',
'var',
' e: TEnum;',
' s: TEnums;',
'begin',
' if blue in teAny then;',
' if blue in teAny+[e] then;',
' if blue in teAny+teRedBlue then;',
' s:=teAny;',
' s:=teAny+[e];',
' s:=[e]+teAny;',
' s:=teAny+teRedBlue;',
' s:=teAny+teRedBlue+[e];',
'']);
ConvertProgram;
CheckSource('TestSet_ConstEnum',
LinesToStr([ // statements
'this.TEnum = {',
' "0": "red",',
' red: 0,',
' "1": "blue",',
' blue: 1,',
' "2": "green",',
' green: 2',
'};',
'this.teAny = rtl.createSet(null, $mod.TEnum.red, $mod.TEnum.green);',
'this.teRedBlue = rtl.createSet(null, $mod.TEnum.red, $mod.TEnum.green - 1);',
'this.e = 0;',
'this.s = {};',
'']),
LinesToStr([
'if ($mod.TEnum.blue in $mod.teAny) ;',
'if ($mod.TEnum.blue in rtl.unionSet($mod.teAny, rtl.createSet($mod.e))) ;',
'if ($mod.TEnum.blue in rtl.unionSet($mod.teAny, $mod.teRedBlue)) ;',
'$mod.s = rtl.refSet($mod.teAny);',
'$mod.s = rtl.unionSet($mod.teAny, rtl.createSet($mod.e));',
'$mod.s = rtl.unionSet(rtl.createSet($mod.e), $mod.teAny);',
'$mod.s = rtl.unionSet($mod.teAny, $mod.teRedBlue);',
'$mod.s = rtl.unionSet(rtl.unionSet($mod.teAny, $mod.teRedBlue), rtl.createSet($mod.e));',
'']));
end;
procedure TTestModule.TestSet_ConstChar;
begin
StartProgram(false);
@ -11461,8 +11513,8 @@ begin
Add(' TMethodB = procedure of object;');
Add(' TProcC = procedure; varargs;');
Add(' TProcD = procedure(i: longint; const j: string; var c: char; out d: double);');
Add(' TProcE = function: longint;');
Add(' TProcF = function(const p: TProcA): longint;');
Add(' TProcE = function: nativeint;');
Add(' TProcF = function(const p: TProcA): nativeuint;');
Add('var p: pointer;');
Add('begin');
Add(' p:=typeinfo(tproca);');
@ -11483,10 +11535,10 @@ begin
' procsig: rtl.newTIProcSig([["i", rtl.longint], ["j", rtl.string, 2], ["c", rtl.char, 1], ["d", rtl.double, 4]])',
'});',
'$mod.$rtti.$ProcVar("TProcE", {',
' procsig: rtl.newTIProcSig(null, rtl.longint)',
' procsig: rtl.newTIProcSig(null, rtl.nativeint)',
'});',
'$mod.$rtti.$ProcVar("TProcF", {',
' procsig: rtl.newTIProcSig([["p", $mod.$rtti["TProcA"], 2]], rtl.longint)',
' procsig: rtl.newTIProcSig([["p", $mod.$rtti["TProcA"], 2]], rtl.nativeuint)',
'});',
'this.p = null;',
'']),