Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2021-12

Assigning class methods, accessed via a class reference type, to procvars

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author
1) The attached metaclass_meth_to_procvar-1.patch fixes the internal error reported for:
[ICE] Assigning class methods, accessed via a class reference type, to incompatible procvars
-------8<-------
type C = class
	class procedure NonStatic;
	class procedure Static; static;
end;
class procedure C.NonStatic; begin end;
class procedure C.Static; begin end;
type CC = class of C;
var IncompatWNonStatic: procedure;
var IncompatWStatic: procedure of object;
begin
	IncompatWNonStatic := CC.NonStatic; // ICE 200301042
	IncompatWStatic := CC.Static // ICE 200301042
end.
-------8<-------

2) The attached metaclass_meth_to_procvar-2.patch fixes the invalid codegen produced for: [BadCG] Assigning class non-static methods, accessed via a class reference type, to method pointers -------8<-------
type C = class

	class procedure Foo;

end;
class procedure C.Foo; begin end;

type CC = class of C;
var Z: procedure of object;
begin
	Z := CC.Foo;
	writeln( TMethod(Z).Code = @C.Foo ); // "FALSE"
	writeln( TMethod(Z).Data = Pointer(C) ); // "FALSE"
end.
-------8<-------
βþ

Reply by email

Ryan Joseph
to Unknown author

Thank you for continuing work on this, we all really appreciate your efforts.

On Dec 23, 2021, at 1:16 AM, Blaise--- via fpc-devel wrote: 1) The attached metaclass_meth_to_procvar-1.patch fixes the internal error reported for:

Regards,
Ryan Joseph

Reply by email

Unknown author
to Unknown author: 1) The attached metaclass_meth_to_procvar-1.patch fixes the internal error reported for:…
Blaise wrote
1) The attached metaclass_meth_to_procvar-1.patch fixes the internal error reported for: [ICE] Assigning class methods, accessed via a class reference type, to incompatible procvars

Also fixes:

1B) [ICE] Assigning class static methods, accessed via an object type, to incompatible procvars
-------8<-------
type O = object
	class procedure Static; static;
end;
class procedure O.Static; begin end;
var IncompatWStatic: procedure of object;
begin
	IncompatWStatic := O.Static // ICE 200301042
end.
-------8<-------
1C) [ICE] Assigning class methods, accessed via a helper type, to incompatible procvars
-------8<-------
type C = class end;
type H = class helper for C
	class procedure NonStatic;
	class procedure Static; static;
end;
class procedure H.NonStatic; begin end;
class procedure H.Static; begin end;
var IncompatWNonStatic: procedure;
var IncompatWStatic: procedure of object;
begin
	IncompatWNonStatic := H.NonStatic; // ICE 200301042
	IncompatWStatic := H.Static // ICE 200301042
end.
-------8<-------
See https://lists.freepascal.org/pipermail/fpc-devel/2021-December/044251.html for the discussion on rejecting such qualification.
βþ

Reply by email

Ozz Nixon
to Ryan Joseph: Thank you for continuing work on this, we all really appreciate your efforts. Ryan Joseph

As some of you who know me, know I wrote all kinds of interpreter and pcode compilers. Last night I decided to compile my latest engine in delphi. I ran a script that does over 18 million double = double + 0.5

Fpc build takes 1m 26.8s
Delphi takes over 15min... I have up and walked away, when I came back after it had been 30min it had finished.

Good work guys!! Delphi exe was about 100k smaller, but fpc smacked delphi around like a Lil B!!!

On Thu, Dec 23, 2021, 6:16 AM Ryan Joseph via fpc-devel <

Show quoted text 18 lines
wrote: Thank you for continuing work on this, we all really appreciate your efforts. > On Dec 23, 2021, at 1:16 AM, Blaise--- via fpc-devel < > wrote: > > 1) The attached metaclass_meth_to_procvar-1.patch fixes the internal error reported for: Regards, Ryan Joseph _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Sven Barth
to Unknown author: 1) The attached metaclass_meth_to_procvar-1.patch fixes the internal error reported for:…
Blaise--- wrote 42 lines
1) The attached metaclass_meth_to_procvar-1.patch fixes the internal error reported for: [ICE] Assigning class methods, accessed via a class reference type, to incompatible procvars -------8<------- type C = class     class procedure NonStatic;     class procedure Static; static; end; class procedure C.NonStatic; begin end; class procedure C.Static; begin end; type CC = class of C; var IncompatWNonStatic: procedure; var IncompatWStatic: procedure of object; begin     IncompatWNonStatic := CC.NonStatic; // ICE 200301042     IncompatWStatic := CC.Static // ICE 200301042 end. -------8<------- 2) The attached metaclass_meth_to_procvar-2.patch fixes the invalid codegen produced for: [BadCG] Assigning class non-static methods, accessed via a class reference type, to method pointers -------8<------- type C = class     class procedure Foo; end; class procedure C.Foo; begin end; type CC = class of C; var Z: procedure of object; begin     Z := CC.Foo;     writeln( TMethod(Z).Code = @C.Foo ); // "FALSE"     writeln( TMethod(Z).Data = Pointer(C) ); // "FALSE" end. -------8<-------

Both accepted.

Regards,
Sven

Reply by email