Skip to content

Commit

Permalink
Address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rdulmina committed Nov 19, 2024
1 parent 7e6125c commit a97ead4
Showing 1 changed file with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2409,10 +2409,6 @@ private BIRNonTerminator.NewStructure createNewStructureInst(BIROperand typeDesc
return new BIRNonTerminator.NewStructure(pos, toVarRef, typeDesc, fields);
}

public String getTypedescFieldName(String name) {
return "$typedesc$" + name;
}

private BIRVariableDcl getTypedescVariable(BType type, Location pos) {
Supplier<BIRVariableDcl>[] checks = new Supplier[] {
() -> findInPackageScope(type),
Expand All @@ -2437,17 +2433,15 @@ private BIRVariableDcl getTypedescVariable(BType type, Location pos) {

private BIRVariableDcl findInPackageScope(BType type) {
BTypeSymbol typeSymbol = type.tsymbol;
if (typeSymbol != null && typeSymbol.owner.tag == SymTag.PACKAGE &&
!isInSameModule(typeSymbol, env.enclPkg.packageID)) {
BPackageSymbol packageSymbol = (BPackageSymbol) typeSymbol.owner;
Scope.ScopeEntry scopeEntry =
packageSymbol.scope.lookup(new Name(getTypedescFieldName(typeSymbol.name.value)));
BSymbol symbol = scopeEntry.symbol;
if (symbol != null) {
return getVarRef(createPackageVarRef(symbol));
}
if (typeSymbol == null || typeSymbol.owner.tag != SymTag.PACKAGE ||
isInSameModule(typeSymbol, env.enclPkg.packageID)) {
return null;
}
return null;
BPackageSymbol packageSymbol = (BPackageSymbol) typeSymbol.owner;
Scope.ScopeEntry scopeEntry =
packageSymbol.scope.lookup(new Name(TYPEDESC + typeSymbol.name.value));
BSymbol symbol = scopeEntry.symbol;
return symbol != null? getVarRef(createPackageVarRef(symbol)) : null;
}

private BLangPackageVarRef createPackageVarRef(BSymbol symbol) {
Expand Down

0 comments on commit a97ead4

Please sign in to comment.