mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-11 18:08:15 +02:00
* make generic basics working again
git-svn-id: trunk@2458 -
This commit is contained in:
parent
05bac3dceb
commit
a59690b147
@ -393,6 +393,7 @@ implementation
|
||||
defpos,storetokenpos : tfileposinfo;
|
||||
old_block_type : tblock_type;
|
||||
ch : tclassheader;
|
||||
isgeneric,
|
||||
isunique,
|
||||
istyperenaming : boolean;
|
||||
generictypelist : tsinglelist;
|
||||
@ -408,32 +409,26 @@ implementation
|
||||
generictypelist:=nil;
|
||||
generictokenbuf:=nil;
|
||||
|
||||
{ generic declaration? }
|
||||
isgeneric:=try_to_consume(_GENERIC);
|
||||
|
||||
typename:=pattern;
|
||||
orgtypename:=orgpattern;
|
||||
consume(_ID);
|
||||
|
||||
{$ifdef GENERICSHARPBRACKET}
|
||||
{ Generic type declaration? }
|
||||
if try_to_consume(_LSHARPBRACKET) then
|
||||
if isgeneric then
|
||||
begin
|
||||
consume(_LSHARPBRACKET);
|
||||
generictypelist:=parse_generic_parameters;
|
||||
consume(_RSHARPBRACKET);
|
||||
end;
|
||||
{$endif GENERICSHARPBRACKET}
|
||||
|
||||
consume(_EQUAL);
|
||||
|
||||
{ support 'ttype=type word' syntax }
|
||||
isunique:=try_to_consume(_TYPE);
|
||||
|
||||
{ Generic type declaration? }
|
||||
if try_to_consume(_GENERIC) then
|
||||
begin
|
||||
consume(_LKLAMMER);
|
||||
generictypelist:=parse_generic_parameters;
|
||||
consume(_RKLAMMER);
|
||||
end;
|
||||
|
||||
{ MacPas object model is more like Delphi's than like TP's, but }
|
||||
{ uses the object keyword instead of class }
|
||||
if (m_mac in aktmodeswitches) and
|
||||
|
@ -90,24 +90,16 @@ implementation
|
||||
Comment(V_Error,'Specialization is only supported for generic types');
|
||||
pt1.resulttype:=generrortype;
|
||||
{ recover }
|
||||
{$ifdef GENERICSHARPBRACKET}
|
||||
consume(_LSHARPBRACKET);
|
||||
{$endif GENERICSHARPBRACKET}
|
||||
consume(_LKLAMMER);
|
||||
repeat
|
||||
pt2:=factor(false);
|
||||
pt2.free;
|
||||
until not try_to_consume(_COMMA);
|
||||
{$ifdef GENERICSHARPBRACKET}
|
||||
consume(_RSHARPBRACKET);
|
||||
{$endif GENERICSHARPBRACKET}
|
||||
consume(_RKLAMMER);
|
||||
exit;
|
||||
end;
|
||||
{$ifdef GENERICSHARPBRACKET}
|
||||
consume(_LSHARPBRACKET);
|
||||
{$endif GENERICSHARPBRACKET}
|
||||
consume(_LKLAMMER);
|
||||
block_type:=bt_specialize;
|
||||
{ Parse generic parameters, for each undefineddef in the symtable of
|
||||
the genericdef we need to have a new def }
|
||||
err:=false;
|
||||
@ -159,10 +151,7 @@ implementation
|
||||
try_to_consume(_SEMICOLON);
|
||||
end;
|
||||
generictypelist.free;
|
||||
{$ifdef GENERICSHARPBRACKET}
|
||||
consume(_RSHARPBRACKET);
|
||||
{$endif GENERICSHARPBRACKET}
|
||||
consume(_RKLAMMER);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -3583,7 +3583,7 @@ In case not, the value returned can be arbitrary.
|
||||
'>' :
|
||||
begin
|
||||
readchar;
|
||||
if (block_type=bt_type) then
|
||||
if (block_type in [bt_type,bt_specialize]) then
|
||||
token:=_RSHARPBRACKET
|
||||
else
|
||||
begin
|
||||
@ -3615,7 +3615,7 @@ In case not, the value returned can be arbitrary.
|
||||
'<' :
|
||||
begin
|
||||
readchar;
|
||||
if (block_type=bt_type) then
|
||||
if (block_type in [bt_type,bt_specialize]) then
|
||||
token:=_LSHARPBRACKET
|
||||
else
|
||||
begin
|
||||
|
@ -1,7 +1,7 @@
|
||||
{$mode objfpc}
|
||||
|
||||
type
|
||||
TList=generic(_T) class(TObject)
|
||||
generic TList<_T>=class(TObject)
|
||||
data : _T;
|
||||
procedure Add(item: _T);
|
||||
end;
|
||||
@ -12,8 +12,8 @@ begin
|
||||
end;
|
||||
|
||||
type
|
||||
TMyIntList = specialize TList(integer);
|
||||
TMyStringList = specialize TList(string);
|
||||
TMyIntList = specialize TList<integer>;
|
||||
TMyStringList = specialize TList<string>;
|
||||
|
||||
var
|
||||
ilist : TMyIntList;
|
||||
|
@ -3,7 +3,7 @@
|
||||
{$mode objfpc}
|
||||
|
||||
type
|
||||
TList=generic(_T) class(TObject)
|
||||
generic TList<_T>=class(TObject)
|
||||
data : _T;
|
||||
procedure Add(item: _T);
|
||||
end;
|
||||
@ -18,7 +18,7 @@ begin
|
||||
end;
|
||||
|
||||
type
|
||||
TMyStringList = specialize TList(string);
|
||||
TMyStringList = specialize TList<string>;
|
||||
|
||||
var
|
||||
slist : TMyStringList;
|
||||
|
@ -1,7 +1,7 @@
|
||||
uses ugeneric3;
|
||||
|
||||
type
|
||||
TMyStringList = specialize TList(string);
|
||||
TMyStringList = specialize TList<string>;
|
||||
|
||||
var
|
||||
slist : TMyStringList;
|
||||
|
@ -6,7 +6,7 @@ begin
|
||||
end;
|
||||
|
||||
type
|
||||
TMyStringList = specialize TList(string);
|
||||
TMyStringList = specialize TList<string>;
|
||||
|
||||
var
|
||||
slist : TMyStringList;
|
||||
|
@ -4,7 +4,7 @@ uses
|
||||
typinfo;
|
||||
|
||||
type
|
||||
TList=generic(_T) class(TObject)
|
||||
generic TList<_T>=class(TObject)
|
||||
data : _T;
|
||||
procedure Add(item: _T);
|
||||
end;
|
||||
@ -33,7 +33,7 @@ begin
|
||||
end;
|
||||
|
||||
type
|
||||
TMyIntList = specialize TList(integer);
|
||||
TMyIntList = specialize TList<integer>;
|
||||
|
||||
var
|
||||
ilist : TMyIntList;
|
||||
|
@ -5,7 +5,7 @@ interface
|
||||
{$mode objfpc}
|
||||
|
||||
type
|
||||
TList=generic(_T) class(TObject)
|
||||
generic TList<_T>=class(TObject)
|
||||
data : _T;
|
||||
procedure Add(item: _T);
|
||||
end;
|
||||
|
@ -5,7 +5,7 @@ interface
|
||||
{$mode objfpc}
|
||||
|
||||
type
|
||||
TList=generic(_T) class(TObject)
|
||||
generic TList<_T>=class(TObject)
|
||||
data : _T;
|
||||
procedure Fill;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user