mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-02 07:02:38 +02:00

procvar in the local state of the block, and then call it insde the generated invoke routine. We can't call it directly there, because due to visibility reasons it may not be accessible from a regular procedure (e.g. if it is a strict private method) git-svn-id: branches/blocks@28234 -
52 lines
756 B
ObjectPascal
52 lines
756 B
ObjectPascal
{ %target=darwin,iphonesim}
|
|
|
|
{$mode delphi}
|
|
{$modeswitch blocks}
|
|
|
|
type
|
|
tblock = reference to procedure(j: longint); cdecl;
|
|
|
|
tc = class
|
|
i: longint;
|
|
procedure callme(j: longint);
|
|
end;
|
|
|
|
var
|
|
b: tblock;
|
|
p: procedure(j: longint) of object;
|
|
c: tc;
|
|
|
|
procedure tc.callme(j: longint);
|
|
const
|
|
invocationcount: longint = 0;
|
|
begin
|
|
writeln('self: ',hexstr(pointer(self)),', i: ',i,', j: ',j);
|
|
if self<>c then
|
|
halt(1);
|
|
if i<>12345 then
|
|
halt(2);
|
|
if invocationcount=0 then
|
|
begin
|
|
if j<>1 then
|
|
halt(3)
|
|
end
|
|
else if j<>2 then
|
|
halt(4);
|
|
inc(invocationcount);
|
|
end;
|
|
|
|
procedure test(b: tblock);
|
|
begin
|
|
b(2);
|
|
end;
|
|
|
|
begin
|
|
c:=tc.create;
|
|
c.i:=12345;
|
|
b:=c.callme;
|
|
b(1);
|
|
test(c.callme);
|
|
test(b);
|
|
end.
|
|
|