dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ChangeLog cscc/csharp/cs_lookup.c cscc/csh...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog cscc/csharp/cs_lookup.c cscc/csh...
Date: Tue, 29 May 2007 05:26:07 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      07/05/29 05:26:07

Modified files:
        .              : ChangeLog 
        cscc/csharp    : cs_lookup.c cs_semvalue.h 

Log message:
        Fix the lookup for using namespace declarations so that all parent 
namespaces
        are searched for the using namespace too.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3461&r2=1.3462
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_lookup.c?cvsroot=dotgnu-pnet&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_semvalue.h?cvsroot=dotgnu-pnet&r1=1.6&r2=1.7

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3461
retrieving revision 1.3462
diff -u -b -r1.3461 -r1.3462
--- ChangeLog   28 May 2007 15:28:37 -0000      1.3461
+++ ChangeLog   29 May 2007 05:26:06 -0000      1.3462
@@ -1,3 +1,14 @@
+2007-05-29  Klaus Treichel  <address@hidden>
+
+       * cscc/csharp/cs_semvalue.h: Change the semantic value for a namespace 
so
+       that it contains the resolved namespace scope instead of the fully
+       qualified namespace name.
+
+       * cscc/csharp/cs_lookup.c: Change FindTypeInNamespace to get the ILScope
+       in which to look for the name instead of the fully qualified namespace.
+       Fix the using lookup so that all parent scopes are searched for the 
using
+       namespace too.
+
 2007-05-28  Klaus Treichel  <address@hidden>
 
        * cscc/c/c_types.c, cscc/c/c_typeout.c: Fix reading non system 
attributes

Index: cscc/csharp/cs_lookup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_lookup.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- cscc/csharp/cs_lookup.c     28 May 2007 15:28:37 -0000      1.33
+++ cscc/csharp/cs_lookup.c     29 May 2007 05:26:07 -0000      1.34
@@ -898,12 +898,13 @@
  * Restrict the resolution to types only if typesOnly is != 0.
  */
 static int FindTypeInNamespace(ILGenInfo *genInfo, const char *name,
-                                                          const char 
*namespace, ILClass *accessedFrom,
+                                                          ILScope 
*namespaceScope, ILClass *accessedFrom,
                                                           CSMemberLookupInfo 
*results, int typesOnly)
 {
        ILClass *type;
        ILScopeData *data;
        int scopeKind;
+       const char *namespace = ILScopeGetNamespaceName(namespaceScope);
        const char *fullName;
        ILNode_ClassDefn *node;
 
@@ -921,7 +922,7 @@
        }
 
        /* Look in the global scope for a declared type */
-       data = ILScopeLookupInNamespace(genInfo->globalScope, namespace, name);
+       data = ILScopeLookup(namespaceScope, name, 0);
        if(data)
        {
                scopeKind = ILScopeDataGetKind(data);
@@ -930,7 +931,7 @@
                        if(typesOnly == 0)
                        {
                                fullName = ILScopeDataGetNamespaceName(data);
-                               AddMember(results, (ILProgramItem *)fullName,
+                               AddMember(results, (ILProgramItem 
*)ILScopeDataGetSubScope(data),
                                                  0, CS_MEMBERKIND_NAMESPACE);
                                return CS_SEMKIND_NAMESPACE;
                        }
@@ -974,6 +975,8 @@
        /* Now check if it's an existing namespace name */
        if(typesOnly == 0)
        {
+               ILScope *scope;
+
                if(namespace && (*namespace != '\0'))
                {
                        fullName = 
ILInternStringConcat3(ILInternString(namespace, -1),
@@ -984,9 +987,10 @@
                {
                        fullName = name;
                }
-               if(ILScopeImportNamespace(genInfo->globalScope, fullName) != 0)
+               scope = ILScopeImportNamespace(genInfo->globalScope, fullName);
+               if(scope != 0)
                {
-                       AddMember(results, (ILProgramItem *)fullName,
+                       AddMember(results, (ILProgramItem *)scope,
                                          0, CS_MEMBERKIND_NAMESPACE);
                        return CS_SEMKIND_NAMESPACE;
                }
@@ -996,6 +1000,53 @@
        return CS_SEMKIND_VOID;
 }
 
+/*
+ * Find the type in the given namespace scope and all it's parents.
+ */
+static void FindTypeInUsingNamespace(ILGenInfo *genInfo,
+                                                                        
ILScope *namespaceScope,
+                                                                        const 
char *using,
+                                                                        const 
char *name,
+                                                                        
ILClass *accessedFrom,
+                                                                        
CSMemberLookupInfo *results)
+{
+       while(namespaceScope)
+       {
+               ILScope *usingScope = ILScopeFindNamespace(namespaceScope, 
using);
+
+               if(!usingScope)
+               {
+                       /* We have to check for a matching namespace in the 
import libs. */
+                       const char *namespace = 
ILScopeGetNamespaceName(namespaceScope);
+
+                       if(namespace && (*namespace != '\0'))
+                       {
+                               const char *fullName;
+
+                               fullName = 
ILInternStringConcat3(ILInternString(namespace, -1),
+                                                                               
                 ILInternString(".", 1),
+                                                                               
                 ILInternString(name, -1)).string;
+                               usingScope = 
ILScopeImportNamespace(genInfo->globalScope, fullName);
+                       }
+                       else
+                       {
+                               usingScope = 
ILScopeImportNamespace(genInfo->globalScope, using);
+                       }
+               }
+               
+               if(usingScope)
+               {
+                       if(FindTypeInNamespace(genInfo, name,
+                                                                  usingScope, 
accessedFrom,
+                                                                  results, 1) 
!= CS_SEMKIND_VOID)
+                       {
+                               return;
+                       }
+               }
+               namespaceScope = ILScopeGetParent(namespaceScope);
+       }
+}
+
 ILClass *CSGetAccessScope(ILGenInfo *genInfo, int defIsModule)
 {
        if(genInfo->currentMethod)
@@ -1316,7 +1367,7 @@
        while(namespace != 0 && !(results.num))
        {
                /* Look for the type in the current namespace */
-               result = FindTypeInNamespace(genInfo, name, namespace->name,
+               result = FindTypeInNamespace(genInfo, name, 
namespace->localScope,
                                                                         
accessedFrom, &results, 0);
                if(result != CS_SEMKIND_VOID)
                {
@@ -1371,8 +1422,12 @@
                using = namespace->using;
                while(using != 0)
                {
-                       FindTypeInNamespace(genInfo, name, using->name,
-                                                               accessedFrom, 
&results, 1);
+                       FindTypeInUsingNamespace(genInfo,
+                                                                        
namespace->localScope,
+                                                                        
using->name,
+                                                                        name,
+                                                                        
accessedFrom,
+                                                                        
&results);
                        using = using->next;
                }
 
@@ -1442,7 +1497,6 @@
 {
        CSMemberLookupInfo results;
        int result;
-       ILIntString nspace;
 
        InitMembers(&results);
 
@@ -1539,7 +1593,8 @@
                        {
                                CCErrorOnLine(yygetfilename(node), 
yygetlinenum(node),
                                                  "`%s' is not a member of the 
namespace `%s'",
-                                                 name, 
CSSemGetNamespace(value));
+                                                 name,
+                                                 
ILScopeGetNamespaceName(CSSemGetNamespace(value)));
                        }
                }
                break;

Index: cscc/csharp/cs_semvalue.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_semvalue.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- cscc/csharp/cs_semvalue.h   23 Feb 2003 02:28:19 -0000      1.6
+++ cscc/csharp/cs_semvalue.h   29 May 2007 05:26:07 -0000      1.7
@@ -386,7 +386,7 @@
 /*
  * Get the namespace associated with a semantic value.
  */
-#define        CSSemGetNamespace(value)        ((char *)((value).extra__))
+#define        CSSemGetNamespace(value)        ((ILScope *)((value).extra__))
 
 /*
  * Determine if a semantic value has the "base" flag.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]