Skip to content

Commit 5d447ad

Browse files
committed
fbc: src/compiler/symb.bas clean-up
- remove extra search on UDT's namespace - if no other symbols were found, can just search the current namespace
1 parent 4033507 commit 5d447ad

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

src/compiler/symb.bas

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,8 @@ function symbLookupTypeNS _
11621162
end scope
11631163

11641164
scope
1165-
'' Search symbols in the the type's imports, but only if inherieted from
1166-
'' a parent type - don't check imports from a normal namespace
1165+
'' Search symbols in the the UDT's imports, but only if inherieted from
1166+
'' a parent UDT - don't check imports from non-UDT namespaces
11671167

11681168
'' we already know that the current namespace is a TYPE
11691169
dim as FBSYMBOL ptr ns = symbGetCurrentNamespc( )
@@ -1172,7 +1172,7 @@ function symbLookupTypeNS _
11721172
dim as FBSYMCHAIN ptr chain_ = hLookupImportList( ns, id, index )
11731173
dim as FBSYMBOL ptr sym = NULL
11741174

1175-
'' search UDT variables
1175+
'' search UDT members
11761176
while ( chain_ )
11771177
sym = chain_->sym
11781178
while( sym )
@@ -1192,8 +1192,8 @@ function symbLookupTypeNS _
11921192
end scope
11931193

11941194
scope
1195-
'' any symbol not in the global namespace or we are already in the global namespace?
1196-
'' check the whole list before we check the imports
1195+
'' it's not any local or inherited UDT member, so we can now
1196+
'' just search the current namespace for the first symbol found
11971197
hashtb = symb.hashlist.tail
11981198
do
11991199
dim as FBSYMBOL ptr sym = hashLookupEx( @hashtb->tb, id, index )
@@ -1204,23 +1204,10 @@ function symbLookupTypeNS _
12041204
loop while( hashtb <> NULL )
12051205
end scope
12061206

1207-
scope
1208-
'' search the current namespace
1209-
dim as FBSYMBOL ptr ns = symbGetCurrentNamespc( )
1210-
1211-
if( (symbGetCompExt( ns ) <> NULL) and (symbGetCompImportHead( ns ) <> NULL) ) then
1212-
dim as FBSYMCHAIN ptr chain_ = hLookupImportList( ns, id, index )
1213-
if( chain_ ) then
1214-
'' return the first one
1215-
return symbNewChainpool( chain_->sym )
1216-
end if
1217-
end if
1218-
end scope
1219-
1220-
'' search all the imports
1207+
'' still nothing? just return all the imports, which should only be from
1208+
'' using statements
12211209
dim as FBSYMCHAIN ptr imp_chain = hashLookupEx( @symb.imphashtb, id, index )
12221210

1223-
'' never found
12241211
return imp_chain
12251212

12261213
end function

0 commit comments

Comments
 (0)