Skip to content

Commit

Permalink
Fix access with file prefix, better message
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed May 31, 2024
1 parent 761439a commit 1cfe719
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions hld/Eval.hx
Original file line number Diff line number Diff line change
Expand Up @@ -255,29 +255,28 @@ class Eval {
for( i in 0...noFilePath.length-1 ) {
if( noFilePath[i].toLowerCase() != noFilePath[i] ) {
noFilePath.remove(noFilePath[i]);
// Only evaluate if different than path
v = evalPath(noFilePath);
break;
}
}
v = evalPath(noFilePath);
if( v == null )
throw "Unknown value "+path.join(".");
path = noFilePath.copy();
}
break;
if( v == null )
throw "Unknown value "+path.join(".");
return v;
case EField(e2, f):
path.unshift(f);
e = e2;
default:
v = evalExpr(e);
break;
for( f in path ) {
var vf = readField(v, f);
if( vf == null ) throw valueStr(v)+" has no field "+f;
v = vf;
}
return v;
}
}
for( f in path ) {
var vf = readField(v, f);
if( vf == null ) throw valueStr(v)+" has no field "+f;
v = vf;
}
return v;
case EIf(econd, e1, e2), ETernary(econd, e1, e2):
if( toBool(evalExpr(econd)) )
return evalExpr(e1);
Expand Down Expand Up @@ -763,10 +762,17 @@ class Eval {
var v = getVar(path[0]);
if( v != null ) {
path.shift();
return v;
var p : String = null;
while( v != null && path.length > 0 ) {
p = path.shift();
v = readField(v, p);
}
if( v == null )
path.unshift(p);
} else {
v = fetchAddr(getGlobalAddress(path));
}
var v = getGlobalAddress(path);
return fetchAddr(v);
return v;
}

function getGlobalAddress( path : Array<String> ) : VarAddress {
Expand Down

0 comments on commit 1cfe719

Please sign in to comment.