Skip to content

Commit

Permalink
Add alias for abstract type access
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed Mar 21, 2024
1 parent fd12872 commit d3e38d9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion hld/Module.hx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,22 @@ class Module {
for( t in code.types )
switch( t ) {
case HObj(o) if( o.globalValue != null ):
addGlobal(o.name.split("."), o.globalValue);
var path = o.name.split(".");
addGlobal(path, o.globalValue);
// Add abstract type's original name as alias
var hasAlias = false;
var apath = [path[0]];
for( i in 1...path.length ) {
var n0 = apath[apath.length-1];
var n1 = path[i];
if( n0.charCodeAt(0) == "_".code && StringTools.endsWith(n1, "_Impl_") ) {
hasAlias = true;
n1 = n1.substring(0, n1.length - 6);
apath.pop();
}
apath.push(n1);
}
if( hasAlias ) addGlobal(apath, o.globalValue);
case HEnum(e) if( e.globalValue != null ):
addGlobal(e.name.split("."), e.globalValue);
default:
Expand Down

0 comments on commit d3e38d9

Please sign in to comment.