Skip to content

Commit

Permalink
Revert getSymbolTypeRecursive
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Jul 12, 2023
1 parent 30e5a2a commit 8d1e679
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions src/SymbolTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ export class SymbolTable implements SymbolTypeGetter {
}
//look through any sibling maps next
for (let sibling of currentTable.siblings) {
if ((result = sibling.getSymbol(key, bitFlags))) {
result = sibling.getSymbol(key, bitFlags);
if (result) {
if (result.length > 0) {
return result;
}
Expand All @@ -177,43 +178,20 @@ export class SymbolTable implements SymbolTypeGetter {
});
}

getSymbolTypes(name: string, bitFlags: SymbolTypeFlag): BscType[] {
public getSymbolTypes(name: string, bitFlags: SymbolTypeFlag): BscType[] {
const symbolArray = this.getSymbol(name, bitFlags);
if (!symbolArray) {
return undefined;
}
return symbolArray.map(symbol => symbol.type);
}

private getSymbolTypeRecursive(name: string, options: GetSymbolTypeOptions) {
const key = name?.toLowerCase();
let symbolsResult: BscSymbol[];
let typeResult: BscType;
// look in our map first
if ((symbolsResult = this.symbolMap.get(key))) {
// eslint-disable-next-line no-bitwise
symbolsResult = symbolsResult.filter(symbol => symbol.flags & options.flags);
if (symbolsResult.length > 0) {
return getUniqueType(symbolsResult.map(symbol => symbol.type), SymbolTable.unionTypeFactory);
}
}
//look through any sibling maps next
for (let sibling of this.siblings) {
typeResult = sibling.getSymbolType(key, options);
if (typeResult) {
return typeResult;
}
}
//look at parent
return this.parent?.getSymbolType(name, options);
}

getSymbolType(name: string, options: GetSymbolTypeOptions): BscType {
let resolvedType = this.getCachedType(name, options);
const doSetCache = !resolvedType;
const originalIsReferenceType = isReferenceType(resolvedType);
if (!resolvedType || originalIsReferenceType) {
resolvedType = this.getSymbolTypeRecursive(name, options);
resolvedType = getUniqueType(this.getSymbolTypes(name, options.flags), SymbolTable.unionTypeFactory);
}
if (!resolvedType && options.fullName && options.tableProvider) {
resolvedType = SymbolTable.referenceTypeFactory(name, options.fullName, options.flags, options.tableProvider);
Expand Down

0 comments on commit 8d1e679

Please sign in to comment.