Browse Source

Improves decl lookup through scope stack.

woollybah 11 years ago
parent
commit
62acc9e3ca
1 changed files with 15 additions and 2 deletions
  1. 15 2
      decl.bmx

+ 15 - 2
decl.bmx

@@ -669,9 +669,9 @@ Type TScopeDecl Extends TDecl
 	End Method
 	
 
-	Method FindDecl:Object( ident$ )
+	Method FindDecl:Object( ident$, override:Int = False )
 	
-		If _env<>Self Return GetDecl( ident )
+		If Not override And _env<>Self Return GetDecl( ident )
 		
 		Local tscope:TScopeDecl=Self
 		While tscope
@@ -696,6 +696,19 @@ Type TScopeDecl Extends TDecl
 	
 	Method FindValDecl:TValDecl( ident$, static:Int = False )
 		Local decl:TValDecl=TValDecl( FindDecl( ident ) )
+		
+		' we found a field but we don't have access to it?
+		If TFieldDecl(decl) And static Then
+			' see if there's another decl with the same name elsewhere that we may...
+			' field's scope.scope will be a module.
+			If decl.scope And decl.scope.scope Then
+				Local vDecl:TValDecl = TValDecl( decl.scope.scope.FindDecl( ident, True ) )
+				If vDecl Then
+					decl = vDecl
+				End If
+			End If
+		End If
+		
 		If Not decl Then
 			' didn't find it? Maybe it is in module local scope?
 			' issue arises when a global initialises with a local variable in the module scope.