[Pas2js] Typecasting parser bug

Mattias Gaertner nc-gaertnma at netcologne.de
Tue May 15 13:59:13 CEST 2018


On Mon, 14 May 2018 09:16:04 +0700
Ryan Joseph <ryan at thealchemistguild.com> wrote:

> I have the following function which when typecast to TJSFloat32List returns the entire function body (in JS) as its value. This same code works if it’s done  outside of a function but when I add the code as a method and typecast I get the bug.
> 
> function TMat4.CopyList: TJSArray; 
> var
> 	x, y: integer;
> 	list: TJSArray;
> begin
> 	list := TJSArray.new;
> 	for x := 0 to 3 do
> 	for y := 0 to 3 do
> 		list.push(RawComponents[x,y]);
> 	result := list;
> end;
> 
> writeln(TJSFloat32List(projTransform.CopyList)); // from .js pas.System.Writeln($mod.projTransform.CopyList);

Writeln is not yet the Delphi compatible instrinsic. Instead it is a
simple function that calls console.log.
The Delphi special of assigning a procedure address without the address
operator only works when assigning to a procedure reference
variable/argument.

In short:
writeln(TJSFloat32List(@projTransform.CopyList))

Mattias


More information about the Pas2js mailing list