Skip to content

Commit

Permalink
Allow access runtime class with file prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed May 30, 2024
1 parent 079f1c0 commit 74fa9c6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions hld/Eval.hx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,21 @@ class Eval {
switch( e ) {
case EIdent(i):
path.unshift(i);
var noFilePath = path.copy();
v = evalPath(path);
if( v == null ) {
// First not lower case id might be file name (removed in runtime)
for( i in 0...noFilePath.length-1 ) {
if( noFilePath[i].toLowerCase() != noFilePath[i] ) {
noFilePath.remove(noFilePath[i]);
break;
}
}
v = evalPath(noFilePath);
if( v == null )
throw "Unknown value "+path.join(".");
path = noFilePath.copy();
}
break;
case EField(e2, f):
path.unshift(f);
Expand Down Expand Up @@ -741,14 +755,13 @@ class Eval {
return getGlobalAddress([name]);
}

function evalPath( path : Array<String> ) {
function evalPath( path : Array<String> ) : Value {
var v = getVar(path[0]);
if( v != null ) {
path.shift();
return v;
}
var v = getGlobalAddress(path);
if( v == ANone ) throw "Unknown value "+path.join(".");
return fetchAddr(v);
}

Expand Down

0 comments on commit 74fa9c6

Please sign in to comment.