From fb4c21f3b2daff7bbb2145ca968e054e4fab4066 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 5 Aug 2020 19:53:36 +0000 Subject: [PATCH] pastojs: fixed arraySetLength shrink --- compiler/utils/pas2js/dist/rtl.js | 69 +++++++++++++++++-------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/compiler/utils/pas2js/dist/rtl.js b/compiler/utils/pas2js/dist/rtl.js index cf2cfe6..0889f24 100644 --- a/compiler/utils/pas2js/dist/rtl.js +++ b/compiler/utils/pas2js/dist/rtl.js @@ -850,44 +850,51 @@ var rtl = { srclen = 0; oldlen = a.length; } - a.length = stack[depth].dim; + lastlen = stack[depth].dim; + a.length = lastlen; if (depth>0){ item.a[item.i]=a; item.i++; + if ((lastlen===0) && (item.i0){ + if (depth0) && (stack[depth-1].i>=stack[depth-1].dim)){ - depth--; - }; - if (depth===0){ - if (dimmax===0) return a; - return stack[0].a; + if (srclen>lastlen) srclen=lastlen; + if (rtl.isArray(defaultvalue)){ + // array of dyn array + for (var i=0; i0) && (stack[depth-1].i>=stack[depth-1].dim)){ + depth--; + }; + if (depth===0){ + if (dimmax===0) return a; + return stack[0].a; + } }while (true); },