On 15.01.2012 19:26, Blaise Thorn wrote:
I have implemented the support for the Delphi-compatible non-generic closures.
OK, I have started committing into
http://svn.freepascal.org/svn/fpc/branches/blaise/closures
(Be warned, though: I have not even finished with the work I have already done
=> the branch is not yet compilable.)
For know, I am here for a different request: I reckon that small fixes,
especially those not directly related to closures, ought to be submitted
separately.
I understand I have no write access to the trunk, so I am attaching the patch
here.
Changes for consume_generic_type_parameter():
! memory leak (TFPHashList) for every non-generic routine
! type_e_generic_declaration_does_not_match was never emitted
--
βþ
Index: pdecsub.pas
===================================================================
--- pdecsub.pas (revision 20212)
+++ pdecsub.pas (working copy)
@@ -929,40 +929,35 @@
genname : tidstring;
s : shortstring;
begin
- result:=not assigned(astruct)and(m_delphi in
current_settings.modeswitches);
+ result:=not assigned(astruct)
+ and (m_delphi in current_settings.modeswitches)
+ and try_to_consume(_LT);
+
if result then
begin
{ parse all parameters first so we can check whether we have
the correct generic def available }
genparalistdecl:=TFPHashList.Create;
- if try_to_consume(_LT) then
- begin
- { start with 1, so Find can return Nil (= 0) }
- idx:=1;
- repeat
- if token=_ID then
- begin
- genparalistdecl.Add(pattern, Pointer(PtrInt(idx)));
- consume(_ID);
- inc(idx);
- end
- else
- begin
-
message2(scan_f_syn_expected,arraytokeninfo[_ID].str,arraytokeninfo[token].str);
- if token<>_COMMA then
- consume(token);
- end;
- until not try_to_consume(_COMMA);
- if not try_to_consume(_GT) then
- consume(_RSHARPBRACKET);
- end
- else
- begin
- { no generic }
- srsym:=nil;
- exit;
- end;
+ { start with 1, so Find can return Nil (= 0) }
+ idx:=1;
+ repeat
+ if token=_ID then
+ begin
+ genparalistdecl.Add(pattern, Pointer(PtrInt(idx)));
+ consume(_ID);
+ inc(idx);
+ end
+ else
+ begin
+
message2(scan_f_syn_expected,arraytokeninfo[_ID].str,arraytokeninfo[token].str);
+ if token<>_COMMA then
+ consume(token);
+ end;
+ until not try_to_consume(_COMMA);
+ if not try_to_consume(_GT) then
+ consume(_RSHARPBRACKET);
+
s:='';
str(genparalistdecl.count,s);
genname:=sp+'$'+s;
@@ -971,13 +966,12 @@
srsym:=search_object_name(genname,false);
- if not assigned(srsym) then
+ if srsym=generrorsym then
begin
{ TODO : print a nicer typename that contains the parsed
generic types }
Message1(type_e_generic_declaration_does_not_match,genname);
srsym:=nil;
- exit;
end;
end;
end;
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel