Opened 4 years ago

Last modified 4 years ago

#486 new defect

wrong code for JavaScript_Typed_Array

Reported by: vadim.godunko Owned by:
Priority: major Milestone:
Component: Matreshka - a2js Version:
Keywords: Cc:


Wrong code is generated for

with Interfaces;

package P is

   type GLfloat is new Interfaces.IEEE_Float_32;
   type GLfloat_Vector_3 is array (Positive range 1 .. 3) of aliased GLfloat;

   type GLubyte is new Interfaces.Unsigned_8;
   type GLubyte_Vector_4 is array (Positive range 1 .. 4) of aliased GLubyte;

   type Vertex is record
      Coordinates : GLfloat_Vector_3;
      Color       : GLubyte_Vector_4;
   end record;

   type Vertex_Array is array (Positive range <>) of Vertex;
   pragma JavaScript_Typed_Array (Vertex_Array);

end P;

generated code:

                this._element_size = (0 + (new _ec._singleton(32)) * function(a, b) {
                    return b[0] - a[0] + 1
                }([1], [3]) + (new _ec._singleton(8)) * function(a, b) {
                    return b[0] - a[0] + 1
                }([1], [4])) / 8;

this._element_size is NaN after computation.

Change History (1)

comment:1 by Maxim Reznik, 4 years ago

Code aliased GLubyte; for A2JS means "create a wrapper object". Otherwise a2js will be unable to get 'Access to an element of the array. So result is array of object instead of array of integer/floats.

But resulting code is invalid anyway.

Note: See TracTickets for help on using tickets.