Skip to content

Commit

Permalink
Fix fun.assigns when var reuse arg r0 and no captured var
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed Oct 30, 2024
1 parent e9b3b42 commit 125b567
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hld/CodeGraph.hx
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,22 @@ class CodeGraph {

// init assign args (slightly complicated, let's handle complex logic here)
args = [];
var r0used = false;
for( a in fun.assigns ) {
if( a.position >= 0 ) break;
if( a.position == -2 && args.length == 0 ) {
args[0] = { hasIndex : true, vars : [] };
r0used = true;
}
if( a.position == -1 ) {
var vname = module.strings[a.varName];
args.push({ hasIndex : false, vars : [vname] });
}
}
if( args.length == nargs - 1 )
args.unshift({ hasIndex : false, vars : ["this"] });
if( r0used )
args.unshift({ hasIndex : true, vars : [] });
else
args.unshift({ hasIndex : false, vars : ["this"] });
for( a in fun.assigns ) {
if( a.position >= -1 ) break;
var vname = module.strings[a.varName];
Expand Down

0 comments on commit 125b567

Please sign in to comment.