poorna2152 / nballerina

WebAssembly Backend for the nBallerina compiler
https://ballerina.io/
Apache License 2.0
4 stars 0 forks source link

`array.length` and `array.push` implementation #23

Closed poorna2152 closed 2 years ago

poorna2152 commented 2 years ago

Length of the array is extracted using the field $len in the $Liststruct. Array push is implemented similar to the array_grow() method of nBallerina. Array is created with a minimum capacity of 4. If the capacity equals the length of the array, new array is created with a capacity of 1.5 times the previous capacity and the values in the existing array is copied to it. Then the reference of the $arr in the $List struct is changed.