expose runtime id of exported class

This commit is contained in:
dcode
2019-04-03 14:53:47 +02:00
parent 50c49e4275
commit cc1e4cd004
5 changed files with 26 additions and 1 deletions

View File

@ -605,10 +605,19 @@ export class Compiler extends DiagnosticEmitter {
}
break;
}
case ElementKind.CLASS: {
// make the class name itself represent its runtime id
if (!(<Class>element).type.isUnmanaged) {
let module = this.module;
let internalName = (<Class>element).internalName;
module.addGlobal(internalName, NativeType.I32, false, module.createI32((<Class>element).ensureId()));
module.addGlobalExport(internalName, prefix + name);
}
break;
}
// just traverse members below
case ElementKind.ENUM:
case ElementKind.CLASS:
case ElementKind.NAMESPACE:
case ElementKind.FILE:
case ElementKind.TYPEDEFINITION: break;