pastojs: fixed concat(a) calling arrayRef

git-svn-id: trunk@46745 -
This commit is contained in:
Mattias Gaertner 2020-09-01 22:01:52 +00:00
parent 34cd1212ea
commit 6a0ea119e9
3 changed files with 8 additions and 6 deletions

View File

@ -13312,7 +13312,7 @@ begin
{$IFDEF VerbosePas2JS} {$IFDEF VerbosePas2JS}
writeln('TPasToJSConverter.ConvertBuiltInConcatArray Count=',length(El.Params)); writeln('TPasToJSConverter.ConvertBuiltInConcatArray Count=',length(El.Params));
{$ENDIF} {$ENDIF}
Result:=ConvertExpression(Param0,AContext); Result:=CreateArrayRef(El,ConvertExpression(Param0,AContext));
end end
else else
begin begin
@ -17431,6 +17431,8 @@ function TPasToJSConverter.CreateArrayRef(El: TPasElement; ArrayExpr: TJSElement
var var
Call: TJSCallExpression; Call: TJSCallExpression;
begin begin
if ArrayExpr is TJSArrayLiteral then
exit(ArrayExpr);
Call:=CreateCallExpression(El); Call:=CreateCallExpression(El);
Call.Expr:=CreateMemberExpression([GetBIName(pbivnRTL),GetBIName(pbifnArray_Reference)]); Call.Expr:=CreateMemberExpression([GetBIName(pbivnRTL),GetBIName(pbifnArray_Reference)]);
Call.AddArg(ArrayExpr); Call.AddArg(ArrayExpr);

View File

@ -9855,16 +9855,16 @@ begin
'this.ArrJSValue = [];', 'this.ArrJSValue = [];',
'']), '']),
LinesToStr([ // $mod.$main LinesToStr([ // $mod.$main
'$mod.ArrInt = $mod.ArrInt;', '$mod.ArrInt = rtl.arrayRef($mod.ArrInt);',
'$mod.ArrInt = rtl.arrayConcatN($mod.ArrInt, $mod.ArrInt);', '$mod.ArrInt = rtl.arrayConcatN($mod.ArrInt, $mod.ArrInt);',
'$mod.ArrInt = rtl.arrayConcatN($mod.ArrInt, $mod.ArrInt, $mod.ArrInt);', '$mod.ArrInt = rtl.arrayConcatN($mod.ArrInt, $mod.ArrInt, $mod.ArrInt);',
'$mod.ArrRec = $mod.ArrRec;', '$mod.ArrRec = rtl.arrayRef($mod.ArrRec);',
'$mod.ArrRec = rtl.arrayConcat($mod.TRec, $mod.ArrRec, $mod.ArrRec);', '$mod.ArrRec = rtl.arrayConcat($mod.TRec, $mod.ArrRec, $mod.ArrRec);',
'$mod.ArrRec = rtl.arrayConcat($mod.TRec, $mod.ArrRec, $mod.ArrRec, $mod.ArrRec);', '$mod.ArrRec = rtl.arrayConcat($mod.TRec, $mod.ArrRec, $mod.ArrRec, $mod.ArrRec);',
'$mod.ArrSet = $mod.ArrSet;', '$mod.ArrSet = rtl.arrayRef($mod.ArrSet);',
'$mod.ArrSet = rtl.arrayConcat("refSet", $mod.ArrSet, $mod.ArrSet);', '$mod.ArrSet = rtl.arrayConcat("refSet", $mod.ArrSet, $mod.ArrSet);',
'$mod.ArrSet = rtl.arrayConcat("refSet", $mod.ArrSet, $mod.ArrSet, $mod.ArrSet);', '$mod.ArrSet = rtl.arrayConcat("refSet", $mod.ArrSet, $mod.ArrSet, $mod.ArrSet);',
'$mod.ArrJSValue = $mod.ArrJSValue;', '$mod.ArrJSValue = rtl.arrayRef($mod.ArrJSValue);',
'$mod.ArrJSValue = rtl.arrayConcatN($mod.ArrJSValue, $mod.ArrJSValue);', '$mod.ArrJSValue = rtl.arrayConcatN($mod.ArrJSValue, $mod.ArrJSValue);',
'$mod.ArrJSValue = rtl.arrayConcatN($mod.ArrJSValue, $mod.ArrJSValue, $mod.ArrJSValue);', '$mod.ArrJSValue = rtl.arrayConcatN($mod.ArrJSValue, $mod.ArrJSValue, $mod.ArrJSValue);',
'$mod.ArrInt = rtl.arrayConcatN([1], $mod.ArrInt);', '$mod.ArrInt = rtl.arrayConcatN([1], $mod.ArrInt);',

View File

@ -1003,7 +1003,7 @@ var rtl = {
var src = arguments[i]; var src = arguments[i];
if (src === null) continue; if (src === null) continue;
if (a===null){ if (a===null){
a=src; // Note: concat(a) does not clone a=rtl.arrayRef(src); // Note: concat(a) does not clone
} else { } else {
a=a.concat(src); a=a.concat(src);
} }