Skip to content

Commit

Permalink
CodeGraph LocalsRaw add some cache
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed Apr 3, 2024
1 parent bc0e2d0 commit a03ec1f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion hld/CodeGraph.hx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class CodeGraph {
var nargs : Int;
var currentTag : Int = 0;

var localsRawCache : Array<String> = [];
var localsRawCachePos : Int = -1;

public function new(md, f) {
this.module = md;
this.fun = f;
Expand Down Expand Up @@ -166,6 +169,8 @@ class CodeGraph {
}

public function getLocalsRaw( pos : Int ) : Array<String> {
if( pos == localsRawCachePos )
return localsRawCache;
var arr = [];
for( a in fun.assigns ) {
if( a.position > pos ) break;
Expand All @@ -174,7 +179,9 @@ class CodeGraph {
if( getLocal(module.strings[a.varName],pos) == null ) continue; // not written
arr.push(a.varName);
}
return [for( a in arr ) module.strings[a]];
localsRawCachePos = pos;
localsRawCache = [for( a in arr ) module.strings[a]];
return localsRawCache;
}

public function getReturnReg( pos : Int ) : Null<HLType> {
Expand Down

0 comments on commit a03ec1f

Please sign in to comment.