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

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

[Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_lvalue.tc,1.24,1.25 cs_gr


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/cscc/csharp cs_lvalue.tc,1.24,1.25 cs_grammar.y,1.34,1.35 cs_lookup.c,1.15,1.16 cs_internal.h,1.12,1.13 cs_defs.tc,1.4,1.5
Date: Fri, 15 Nov 2002 07:50:59 -0500

Update of /cvsroot/dotgnu-pnet/pnet/cscc/csharp
In directory subversions:/tmp/cvs-serv12532/cscc/csharp

Modified Files:
        cs_lvalue.tc cs_grammar.y cs_lookup.c cs_internal.h cs_defs.tc 
Log Message:
Enable use of global aliases


Index: cs_lvalue.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_lvalue.tc,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** cs_lvalue.tc        9 Nov 2002 21:24:13 -0000       1.24
--- cs_lvalue.tc        15 Nov 2002 12:50:57 -0000      1.25
***************
*** 776,779 ****
--- 776,780 ----
        ILParameterModifier paramMod;
        ILNode_SemGuard *constVar;
+       ILNode_UsingAlias *alias;
        ILType *type;
  
***************
*** 855,859 ****
        }
  
!       /* Resolve the simple name */
        value = CSResolveSimpleName(info, (ILNode *)node, node->name, 0);
  
--- 856,888 ----
        }
  
!       /* Resolve the simple name quietly so that we can check for aliases
!          if & only if this fails */
!       value = CSResolveSimpleNameQuiet(info, (ILNode *)node, node->name, 0);
! 
!       if (CSSemGetKind(value) != CS_SEMKIND_VOID)
!       {       
!               /* Convert the result into an l-value or r-value and return it 
*/
!               return SemToLRValue((ILNode *)node, info, parent, 
!                                                       value, node->name, 0, 
0);
!       }
! 
!       if(data && ILScopeDataGetKind(data) == IL_SCOPE_ALIAS)
!       {
!               alias=(ILNode_UsingAlias*)ILScopeDataGetNode(data);
!               if(alias->visited==ILVisitMode_Processing)
!               {
!                       CCErrorOnLine(yygetfilename(alias), yygetlinenum(alias),
!                         "circularity detected in 'Using' declaration");
!                       CSSemSetLValue(value, ILType_Int32);
!                       return value;
!               }
!               alias->visited=ILVisitMode_Processing;
!               *parent = (ILNode*)ILScopeDataGetData1(data);
!               value = ILNode_SemAnalysis(*parent,info,parent);
!               alias->visited=ILVisitMode_Done;
!               return value;
!       }
! 
!       /* This time around dump the errors */
        value = CSResolveSimpleName(info, (ILNode *)node, node->name, 0);
  
***************
*** 869,881 ****
  {
        CSSemValue value;
  
        /* Resolve the simple name */
!       value = CSResolveSimpleName(info, (ILNode *)node, node->name, 1);
  
!       if (CSSemGetKind(value) != CS_SEMKIND_TYPE)
!       {
!               return CSSemValueDefault;
!       }
!       else
        {
                /* Convert the result into an l-value or r-value and return it 
*/
--- 898,908 ----
  {
        CSSemValue value;
+       ILNode_UsingAlias *alias;
+       ILScopeData *data;
  
        /* Resolve the simple name */
!       value = CSResolveSimpleNameQuiet(info, (ILNode *)node, node->name, 1);
  
!       if (CSSemGetKind(value) == CS_SEMKIND_TYPE)
        {
                /* Convert the result into an l-value or r-value and return it 
*/
***************
*** 883,886 ****
--- 910,937 ----
                                                        value, node->name, 0, 
0);
        }
+ 
+       data = ILScopeLookup(info->currentScope, node->name, 1);
+       
+       if(data && ILScopeDataGetKind(data) == IL_SCOPE_ALIAS)
+       {
+               alias=(ILNode_UsingAlias*)ILScopeDataGetNode(data);
+               if(alias->visited==ILVisitMode_Processing)
+               {
+                       CCErrorOnLine(yygetfilename(alias), yygetlinenum(alias),
+                         "circularity detected in 'Using' declaration");
+                       CSSemSetLValue(value, ILType_Int32);
+                       return value;
+               }
+               alias->visited=ILVisitMode_Processing;
+               *parent = (ILNode*)ILScopeDataGetData1(data);
+               value = ILNode_SemAnalysis(*parent,info,parent);
+               alias->visited=ILVisitMode_Done;
+               return value;
+       }
+ 
+       /* This time around dump the errors */
+       value = CSResolveSimpleName(info, (ILNode *)node, node->name, 0);
+ 
+       return CSSemValueDefault;
  }
  

Index: cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -r1.34 -r1.35
*** cs_grammar.y        13 Nov 2002 08:29:56 -0000      1.34
--- cs_grammar.y        15 Nov 2002 12:50:57 -0000      1.35
***************
*** 1110,1129 ****
  
  UsingDirective
!       : USING IDENTIFIER '=' NamespaceIdentifier ';'  {
                                ILScope *globalScope = GlobalScope();
!                               ILNode_UsingAlias *alias;
                                if(ILScopeLookup(globalScope, $2, 1))
                                {
                                        CCError("`%s' is already declared", $2);
                                }
!                               else if(!ILScopeUsing(globalScope, $4.string, 
$2))
!                               {
!                                       CCError("`%s' is not a namespace", 
$4.string);
!                               }
!                               alias = (ILNode_UsingAlias *)
!                                       ILNode_UsingAlias_create($2, $4.string);
!                               InitGlobalNamespace();
!                               alias->next = CurrNamespaceNode->aliases;
!                               CurrNamespaceNode->aliases = alias;
                        }
        | USING NamespaceIdentifier ';'         {
--- 1110,1124 ----
  
  UsingDirective
!       : USING IDENTIFIER '=' QualifiedIdentifier ';'  {
                                ILScope *globalScope = GlobalScope();
!                               ILNode *alias;
                                if(ILScopeLookup(globalScope, $2, 1))
                                {
                                        CCError("`%s' is already declared", $2);
                                }
!                               alias = ILNode_UsingAlias_create($2, 
ILQualIdentName($4,0));
!                               ILScopeDeclareAlias(globalScope, $2,alias,$4);
!                               /* NOTE: CSSemGuard is not needed as 
ILNode_UsingAlias is
!                                        never Semanalyzed */
                        }
        | USING NamespaceIdentifier ';'         {

Index: cs_lookup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_lookup.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** cs_lookup.c 9 Nov 2002 21:24:13 -0000       1.15
--- cs_lookup.c 15 Nov 2002 12:50:57 -0000      1.16
***************
*** 968,974 ****
        CSMemberLookupInfo results;
        ILNode_Namespace *namespace;
-       ILNode_UsingAlias *alias;
        ILNode_UsingNamespace *using;
-       CSSemValue value;
        int result;
        ILNode_ClassDefn *nestedParent;
--- 968,972 ----
***************
*** 1029,1052 ****
                        break;
                }
  
!               /* Look for an alias directive for the name */
!               alias = namespace->aliases;
!               while(alias != 0)
                {
!                       if(!strcmp(alias->name, name))
                        {
!                               if(alias->classInfo)
!                               {
!                                       CSSemSetType(value, 
ILClassToType(alias->classInfo));
!                               }
!                               else
!                               {
!                                       CSSemSetNamespace(value, alias->ref);
!                               }
                                return value;
                        }
!                       alias = alias->next;
                }
  
                /* Find the types in all using namespaces */
                using = namespace->using;
--- 1027,1150 ----
                        break;
                }
+       
+               /* Find the types in all using namespaces */
+               using = namespace->using;
+               while(using != 0)
+               {
+                       FindTypeInNamespace(genInfo, name, using->name,
+                                                               accessedFrom, 
&results);
+                       using = using->next;
+               }
+ 
+               /* Move up to the enclosing namespace */
+               namespace = namespace->enclosing;
+       }
+ 
+       /* We should have 0, 1, or many types at this point */
+       if(results.num > 1)
+       {
+               /* The result is ambiguous */
+               AmbiguousError(node, name, &results);
+       }
+       if(results.num != 0)
+       {
+               /* Return the first type in the results list */
+               if(results.members->kind == CS_MEMBERKIND_TYPE)
+               {
+                       return LookupToSem(node, name, &results, 
CS_SEMKIND_TYPE);
+               }
+               else if(results.members->kind == CS_MEMBERKIND_TYPE_NODE)
+               {
+                       return LookupToSem(node, name, &results, 
CS_SEMKIND_TYPE_NODE);
+               }
+               else
+               {
+                       return LookupToSem(node, name, &results, 
CS_SEMKIND_NAMESPACE);
+               }
+       }
+       FreeMembers(&results);
+ 
+       /* Could not resolve the name */
+       CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
+                                 "`%s' is not declared in the current scope", 
name);
+ 
+       if (literalType)
+       {
+               /* Resolve it cleanly if a type was not found */
+               return CSResolveSimpleName(genInfo, node, name, 0);
+       }
+       else
+       {
+               return CSSemValueDefault;
+       }
+ }
+ 
+ CSSemValue CSResolveSimpleNameQuiet(ILGenInfo *genInfo, ILNode *node,
+                                                                               
const char *name, int literalType)
+ {
+       ILClass *startType;
+       ILClass *accessedFrom;
+       CSMemberLookupInfo results;
+       ILNode_Namespace *namespace;
+       ILNode_UsingNamespace *using;
+       int result;
+       ILNode_ClassDefn *nestedParent;
+       ILNode *child;
  
!       /* If we are within type gathering, then search the nesting
!          parents for a nested type that matches our requirements */
!       if(genInfo->typeGather)
!       {
!               nestedParent = (ILNode_ClassDefn *)(genInfo->currentClass);
!               while(nestedParent != 0)
                {
!                       child = FindNestedClass(0, nestedParent, name);
!                       if(child)
                        {
!                               CSSemValue value;
!                               CSSemSetTypeNode(value, child);
                                return value;
                        }
!                       nestedParent = nestedParent->nestedParent;
                }
+       }
+ 
+       /* Find the type to start looking at and the scope to use for accesses 
*/
+       startType = CSGetAccessScope(genInfo, 0);
+       accessedFrom = ILClassResolve(CSGetAccessScope(genInfo, 1));
+ 
+       /* Scan the start type and its nested parents */
+       while(startType != 0)
+       {
+               /* Resolve cross-image references */
+               startType = ILClassResolve(startType);
  
+               /* Look for members */
+               result = MemberLookup(genInfo, startType, name,
+                                                         accessedFrom, 
&results, 1, 0, literalType);
+               if(result != CS_SEMKIND_VOID)
+               {
+                       return LookupToSem(node, name, &results, result);
+               }
+ 
+               /* Move up to the nested parent */
+               startType = ILClass_NestedParent(startType);
+       }
+ 
+       /* Clear the results buffer */
+       InitMembers(&results);
+ 
+       /* Scan all namespaces that enclose the current context */
+       namespace = (ILNode_Namespace *)(genInfo->currentNamespace);
+       while(namespace != 0 && !(results.num))
+       {
+               /* Look for the type in the current namespace */
+               result = FindTypeInNamespace(genInfo, name, namespace->name,
+                                                                        
accessedFrom, &results);
+               if(result != CS_SEMKIND_VOID)
+               {
+                       break;
+               }
+       
                /* Find the types in all using namespaces */
                using = namespace->using;
***************
*** 1086,1097 ****
        FreeMembers(&results);
  
-       /* Could not resolve the name */
-       CCErrorOnLine(yygetfilename(node), yygetlinenum(node),
-                                 "`%s' is not declared in the current scope", 
name);
- 
        if (literalType)
        {
                /* Resolve it cleanly if a type was not found */
!               return CSResolveSimpleName(genInfo, node, name, 0);
        }
        else
--- 1184,1191 ----
        FreeMembers(&results);
  
        if (literalType)
        {
                /* Resolve it cleanly if a type was not found */
!               return CSResolveSimpleNameQuiet(genInfo, node, name, 0);
        }
        else
***************
*** 1100,1104 ****
        }
  }
- 
  /*
   * Filter a member lookup results list to include only static entries.
--- 1194,1197 ----

Index: cs_internal.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_internal.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** cs_internal.h       9 Nov 2002 21:24:13 -0000       1.12
--- cs_internal.h       15 Nov 2002 12:50:57 -0000      1.13
***************
*** 151,154 ****
--- 151,159 ----
                                                           const char *name, 
int literalType);
  
+ /* 
+  * Resolve a simple name to a semantic value ignoring errors if any.
+  */
+ CSSemValue CSResolveSimpleNameQuiet(ILGenInfo *genInfo, ILNode *node,
+                                                                               
const char *name, int literalType);
  /*
   * Resolve a namespace member name

Index: cs_defs.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_defs.tc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** cs_defs.tc  3 Sep 2002 06:13:20 -0000       1.4
--- cs_defs.tc  15 Nov 2002 12:50:57 -0000      1.5
***************
*** 155,159 ****
        char *name;
        ILNode_Namespace *enclosing;
-       %nocreate ILNode_UsingAlias *aliases = {0};
        %nocreate ILNode_UsingNamespace *using = {0};
  }
--- 155,158 ----
***************
*** 162,167 ****
        char *name;
        char *ref;
!       %nocreate ILClass *classInfo = {0};
!       %nocreate ILNode_UsingAlias *next = {0};
  }
  %node ILNode_UsingNamespace ILNode_DummySem =
--- 161,165 ----
        char *name;
        char *ref;
!       %nocreate ILVisitMode visited = {ILVisitMode_NotVisited};
  }
  %node ILNode_UsingNamespace ILNode_DummySem =





reply via email to

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