Fixing arrays assign code generation
Publish PHP Package / docker (push) Successful in 8s Details

This commit is contained in:
Georgiy Sadovnikov 2024-06-28 11:26:18 +03:00
parent a1d03a5bc6
commit 5e870a3973
1 changed files with 7 additions and 2 deletions

View File

@ -411,14 +411,19 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack
{{native}} = ValList.New(frm.vm);
{%~ endif -%}
var _arr_type = (ArrayTypeSymbol){{value}}.type;
{{native}}.Clear();
int _native_before_count = {{native}}.Count;
for(int i=0;i<_arr_type.ArrCount({{value}});++i)
{
var _arr_item = _arr_type.ArrGetAt({{value}}, i);
{#TODO: get rid of replace hack below#}
{{('var ' ~ _self.val2native(type.value, '_arr_item', 'tmp'))|replace({'tmp = tmp' : '', 'var var' : 'var'})}};
{{native}}.Add(tmp);
if(i < _native_before_count)
{{native}}[i] = tmp;
else
{{native}}.Add(tmp);
}
while({{native}}.Count > _arr_type.ArrCount({{value}}))
{{native}}.RemoveAt({{native}}.Count-1);
{%- endif -%}
{%- if type is instanceof('\\mtgBuiltinType') -%}