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_defs.tc cscc/csha...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnet ChangeLog cscc/csharp/cs_defs.tc cscc/csha...
Date: Tue, 23 Oct 2007 18:32:21 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnet
Changes by:     Klaus Treichel <ktreichel>      07/10/23 18:32:21

Modified files:
        .              : ChangeLog 
        cscc/csharp    : cs_defs.tc cs_gather.c cs_grammar.y 
                         cs_internal.h cs_lookup.c cs_scanner.l 
                         cs_types.tc 

Log message:
        Add some resolving of generic types.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3511&r2=1.3512
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_defs.tc?cvsroot=dotgnu-pnet&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_gather.c?cvsroot=dotgnu-pnet&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_grammar.y?cvsroot=dotgnu-pnet&r1=1.82&r2=1.83
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_internal.h?cvsroot=dotgnu-pnet&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_lookup.c?cvsroot=dotgnu-pnet&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_scanner.l?cvsroot=dotgnu-pnet&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/pnet/cscc/csharp/cs_types.tc?cvsroot=dotgnu-pnet&r1=1.11&r2=1.12

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3511
retrieving revision 1.3512
diff -u -b -r1.3511 -r1.3512
--- ChangeLog   22 Oct 2007 08:20:21 -0000      1.3511
+++ ChangeLog   23 Oct 2007 18:32:20 -0000      1.3512
@@ -1,3 +1,38 @@
+2007-10-23  Klaus Treichel  <address@hidden>
+
+       * cscc/csharp/cs_defs.c: Replace the type node with a left and an
+       identifier node to be able to handle generic methods too.
+
+       * cscc/csharp/cs_gather.c: Handle the GenericReference node in
+       GetFullAndBasicNames so that type names are built correctly.
+       Set the currentClass in the genInfo block to the current class instead
+       of the nested parent in CreateType to be able to resolve generic type
+       parameters correctly.
+
+       * cscc/csharp/cs_grammar.y: replace the right shift token ">>" with two
+       greater than tokens '>' '>' to be able to handle nested generic types
+       (ECMA 334 version 4 9.4.5).
+       Remove the GENERIC_LT token because the ECMA specs say that the
+       distinction between '<', '>' and expresssions has to be handled 
different.
+       Redo the grammar for qualified identifiers to be able to handle the 
changed
+       generic references.
+       Replace the identifier in generic methods, classes, ... with
+       GenericIdentifierStart which includes the '<' token.
+
+       * cscc/csharp/cs_internal.h: Add structures to handle member accesses
+       in the grammar.
+
+       * cscc/csharp/cs_lookup.c: Change CSGetAccessScope so that the nested
+       parent is used for the access scope if the current class is not yet
+       created.
+
+       * cscc/csharp/cs_scanner.l: Remove the right shift and the GENERIRIC_LT
+       tokens.
+
+       * cscc/csharp/cs_types.c: Add the ILNode_SemAnalysisType operation for
+       generic references for sesolving generic types. Remove the functions for
+       inserting expressions in TypeFormals and TypeActuals.
+
 2007-10-22  Radek Polak  <address@hidden>
 
        * support/socket.c: Implement recieve and send timeouts socket

Index: cscc/csharp/cs_defs.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_defs.tc,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- cscc/csharp/cs_defs.tc      23 Sep 2007 14:40:20 -0000      1.19
+++ cscc/csharp/cs_defs.tc      23 Oct 2007 18:32:20 -0000      1.20
@@ -94,7 +94,8 @@
 }
 %node ILNode_GenericReference ILNode_Dummy =
 {
-       ILNode     *type;
+       ILNode     *left;
+       ILNode     *identifier;
        ILUInt32        numArgs;
        ILNode     *typeArguments;
 }

Index: cscc/csharp/cs_gather.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_gather.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- cscc/csharp/cs_gather.c     23 Sep 2007 14:40:20 -0000      1.56
+++ cscc/csharp/cs_gather.c     23 Oct 2007 18:32:20 -0000      1.57
@@ -94,7 +94,12 @@
        }
        else if(yyisa(name, ILNode_GenericReference))
        {
-               result = ILQualIdentName(((ILNode_GenericReference 
*)name)->type, 0);
+               char buffer[261];
+
+               left = GetFullAndBasicNames(((ILNode_GenericReference 
*)name)->left, 0);
+               result = ILQualIdentName(((ILNode_GenericReference 
*)name)->identifier, 0);
+               sprintf(buffer, "%s`%i", result, ((ILNode_GenericReference 
*)name)->numArgs);
+               result = ILQualIdentAppend(left, buffer);
                basic = result;
        }
        else if(yyisa(name, ILNode_QualIdent))
@@ -419,7 +424,7 @@
        savedNamespace = info->currentNamespace;
        info->currentNamespace = defn->namespaceNode;
        savedClass = info->currentClass;
-       info->currentClass = (ILNode *)(defn->nestedParent);
+       info->currentClass = (ILNode *)defn;
 #if IL_VERSION_MAJOR > 1
        savedTypeFormals = info->currentTypeFormals;
        info->currentTypeFormals = defn->typeFormals;

Index: cscc/csharp/cs_grammar.y
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_grammar.y,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- cscc/csharp/cs_grammar.y    14 Oct 2007 19:48:15 -0000      1.82
+++ cscc/csharp/cs_grammar.y    23 Oct 2007 18:32:20 -0000      1.83
@@ -950,12 +950,8 @@
                ILUInt32                count;
                ILNode_List        *list;
        }                                       countList;
-       struct
-       {
-               ILNode             *identifier;
-               ILUInt32                numTypeArgs;
-               ILNode_List        *typeArgs;
-       }                                       memberName;
+       struct MemberName       memberName;
+       struct MemberAccess     memberAccess;
        ILNode_GenericTypeParameters *genericTypeParameters;
        struct
        {
@@ -987,13 +983,14 @@
 /*
  * simple operator precedence.
  */
+%nonassoc IDENTIFIER_OP
 %right '=' MUL_ASSIGN_OP DIV_ASSIGN_OP MOD_ASSIGN_OP ADD_ASSIGN_OP 
SUB_ASSIGN_OP LEFT_ASSIGN_OP RIGHT_ASSIGN_OP AND_ASSIGN_OP XOR_ASSIGN_OP 
OR_ASSIGN_OP
 %left OR_OP
 %left AND_OP
 %left '|'
 %left '&'
 %left EQ_OP NE_OP
-%left '<' '>' LE_OP GE_OP AS IS
+%left '<' '>' LE_OP GE_OP AS IS GT_OP
 %left LEFT_OP RIGHT_OP
 %left '+' '-'
 %left '*' '/' '%'
@@ -1113,7 +1110,6 @@
 %token INC_OP                          "`++'"
 %token DEC_OP                          "`--'"
 %token LEFT_OP                         "`<<'"
-%token RIGHT_OP                                "`>>'"
 %token LE_OP                           "`<='"
 %token GE_OP                           "`>='"
 %token EQ_OP                           "`=='"
@@ -1131,7 +1127,6 @@
 %token XOR_ASSIGN_OP           "`^='"
 %token OR_ASSIGN_OP                    "`|='"
 %token PTR_OP                          "`->'"
-%token GENERIC_LT                      "`<'"
 %token NULL_COALESCING_OP      "`??'"
 %token QUALIFIED_ALIAS_OP      "`::'"
 
@@ -1150,8 +1145,12 @@
 %type <mask>           OptModifiers Modifiers Modifier
 %type <partial>                OptPartial
 
-%type <node>           Identifier QualifiedIdentifier
-%type <memberName>     QualifiedIdentifierPart
+%type <node>           Identifier GenericIdentifierStart
+%type <node>           QualifiedIdentifier NonGenericQualifiedIdentifier
+%type <memberAccess> SimpleQualifiedIdentifier
+%type <memberAccess> GenericQualifiedIdentifierStart
+%type <memberAccess> GenericQualifiedIdentifier
+%type <node>           QualifiedIdentifierMemberAccessStart
 
 %type <node>           BuiltinType
 %type <node>           NonArrayType ArrayType
@@ -1187,7 +1186,10 @@
 %type <node>           MultiplicativeExpression MultiplicativeNonTypeExpression
 %type <node>           AdditiveExpression AdditiveNonTypeExpression
 %type <node>           ShiftExpression ShiftNonTypeExpression
+%type <node>           RightShiftExpressionStart RightShiftExpression
+%type <node>           LeftShiftExpression
 %type <node>           RelationalExpression RelationalNonTypeExpression
+%type <node>           RelationalGTExpression RelationalNonGTExpression
 %type <node>           EqualityExpression EqualityNonTypeExpression
 %type <node>           AndExpression XorExpression OrExpression
 %type <node>           LogicalAndExpression LogicalOrExpression
@@ -1275,7 +1277,7 @@
 %type <catchinfo>      CatchNameInfo
 %type <target>         AttributeTarget
 
-%expect 27
+%expect 30
 
 %start CompilationUnit
 %%
@@ -1423,6 +1425,10 @@
                        }
        ;
 
+GenericIdentifierStart
+       : Identifier '<'                { $$ = $1; }
+       ;
+
 IDENTIFIER
        : IDENTIFIER_LEXICAL    { $$ = ILInternString($1, strlen($1)).string; }
        | GET                                   { $$ = ILInternString("get", 
3).string; }
@@ -1435,52 +1441,71 @@
        ;
 
 QualifiedIdentifier
-       : QualifiedIdentifierPart                                               
        { 
-                               if($1.numTypeArgs > 0)
-                               {
-                                       MakeTernary(GenericReference,
-                                                               $1.identifier,
-                                                               $1.numTypeArgs,
-                                                               (ILNode 
*)$1.typeArgs);
-                               }
-                               else
-                               {
-                                       $$ = $1.identifier;
+       : NonGenericQualifiedIdentifier         { $$ = $1; }
+       | GenericQualifiedIdentifier                    {
+                               MakeQuaternary(GenericReference,
+                                                          $1.parent,
+                                                          
$1.memberName.identifier,
+                                                          
$1.memberName.numTypeArgs,
+                                                          (ILNode 
*)($1.memberName.typeArgs));
                                }
+       ;
+
+/*
+ * A qualified identifier without a generic reference at the last part
+ */
+SimpleQualifiedIdentifier
+       : QualifiedIdentifierMemberAccessStart Identifier       {
+                               $$.parent = $1;
+                               $$.memberName.identifier = $2;
+                               $$.memberName.numTypeArgs = 0;
+                               $$.memberName.typeArgs = 0;
                         }
-       | QualifiedIdentifier '.' QualifiedIdentifierPart       {
-                               if($3.numTypeArgs > 0)
-                               {
-                                       ILNode *node;
+       ;
 
-                                       node = ILNode_QualIdent_create($1, 
$3.identifier);
-                                       MakeTernary(GenericReference,
-                                                               node,
-                                                               $3.numTypeArgs,
-                                                               (ILNode 
*)$3.typeArgs);
+GenericQualifiedIdentifier
+       : GenericQualifiedIdentifierStart TypeActuals '>'       {
+                               $$.parent = $1.parent;
+                               $$.memberName.identifier = 
$1.memberName.identifier;
+                               $$.memberName.numTypeArgs = $2.count;
+                               $$.memberName.typeArgs = $2.list;
                                }
-                               else
-                               {
-                                       MakeBinary(QualIdent, $1, 
$3.identifier);
+       ;
+
+GenericQualifiedIdentifierStart
+       : GenericIdentifierStart                        {
+                               $$.parent = 0;
+                               $$.memberName.identifier = $1;
+                               $$.memberName.numTypeArgs = 0;
+                               $$.memberName.typeArgs = 0;
                                }
+       | SimpleQualifiedIdentifier '<'         {
+                               $$.parent = $1.parent;
+                               $$.memberName.identifier = 
$1.memberName.identifier;
+                               $$.memberName.numTypeArgs = 
$1.memberName.numTypeArgs;
+                               $$.memberName.typeArgs = $1.memberName.typeArgs;
                        }
        ;
 
-QualifiedIdentifierPart
-       : Identifier                                                    { 
-                               $$.identifier = $1;
-                               $$.numTypeArgs = 0;
-                               $$.typeArgs = 0;
-                        }
-       | IDENTIFIER '<' TypeActuals '>'                {
-                               $$.identifier = ILQualIdentSimple($1);;
-                               $$.numTypeArgs = $3.count;
-                               $$.typeArgs = $3.list;
-                       }
-       | IDENTIFIER GENERIC_LT TypeActuals '>' {
-                               $$.identifier = ILQualIdentSimple($1);;
-                               $$.numTypeArgs = $3.count;
-                               $$.typeArgs = $3.list;
+NonGenericQualifiedIdentifier
+       : Identifier                                            { $$ = $1; } 
%prec IDENTIFIER_OP
+       | SimpleQualifiedIdentifier                     {
+                               MakeBinary(QualIdent,
+                                                  $1.parent,
+                                                  $1.memberName.identifier);
+                       } %prec IDENTIFIER_OP
+       ;
+
+QualifiedIdentifierMemberAccessStart
+       : NonGenericQualifiedIdentifier '.'     {
+                                $$ = $1;
+                       }
+       | GenericQualifiedIdentifier '.'        {
+                               MakeQuaternary(GenericReference,
+                                                          $1.parent,
+                                                          
$1.memberName.identifier,
+                                                          
$1.memberName.numTypeArgs,
+                                                          (ILNode 
*)($1.memberName.typeArgs));
                        }
        ;
 
@@ -1679,8 +1704,8 @@
        ;
 
 Type
-       : NonArrayType                          { $$ = $1; }
-       | ArrayType                                     { $$ = $1; }
+       : NonArrayType                          { $$ = $1; } %prec 
IDENTIFIER_OP 
+       | ArrayType                                     { $$ = $1; } %prec 
IDENTIFIER_OP
        ;
 
 RankSpecifiers
@@ -2191,12 +2216,31 @@
 
 ShiftNonTypeExpression
        : AdditiveNonTypeExpression             { $$ = $1; }
-       | ShiftExpression LEFT_OP AdditiveExpression    {
+       | LeftShiftExpression                   { $$ = $1; }
+       | RightShiftExpression                  { $$ = $1; }
+       ;
+
+LeftShiftExpression
+       : ShiftExpression LEFT_OP AdditiveExpression    {
                                MakeBinary(Shl, $1, $3);
                        }
-       | ShiftExpression RIGHT_OP AdditiveExpression   {
+       ;
+
+RightShiftExpression
+       : RightShiftExpressionStart '>' AdditiveExpression      {
                                MakeBinary(Shr, $1, $3);
-                       }
+                       } %prec RIGHT_OP
+       ;
+
+RightShiftExpressionStart
+       : PrimaryTypeExpression '>'             { $$ = $1; }
+       | AdditiveNonTypeExpression '>' { $$ = $1; }
+       | LeftShiftExpression '>'               { $$ = $1; }
+       | RightShiftExpression '>'              { $$ = $1; }
+       ;
+
+RightShift
+       : '>' '>'
        ;
 
 /*
@@ -2222,12 +2266,14 @@
 
 RelationalNonTypeExpression
        : ShiftNonTypeExpression                { $$ = $1; }
-       | RelationalExpression '<' ShiftExpression              {
+       | RelationalNonGTExpression             { $$ = $1; }
+       | RelationalGTExpression                { $$ = $1; }
+       ;
+
+RelationalNonGTExpression
+       : RelationalExpression '<' ShiftExpression              {
                                MakeBinary(Lt, $1, $3);
                        }
-       | RelationalExpression '>' ShiftExpression              {
-                               MakeBinary(Gt, $1, $3);
-                       }
        | RelationalExpression LE_OP ShiftExpression    {
                                MakeBinary(Le, $1, $3);
                        }
@@ -2242,6 +2288,18 @@
                        }
        ;
 
+RelationalGTExpression
+       : RightShiftExpressionStart ShiftExpression     {
+                               MakeBinary(Gt, $1, $2);
+                       } %prec GT_OP
+       | RelationalGTExpression '>' ShiftExpression    {
+                               MakeBinary(Gt, $1, $3);
+                       } %prec GT_OP
+       | RelationalNonGTExpression '>' ShiftExpression {
+                               MakeBinary(Gt, $1, $3);
+                       } %prec GT_OP
+       ; 
+
 EqualityExpression
        : EqualityNonTypeExpression             { $$ = $1; }
        | PrimaryTypeExpression                 { $$ = $1; }
@@ -3132,8 +3190,8 @@
                                $$.classBase = $6;
                                $$.typeFormals = 0;
                        }
-       | OptAttributes OptModifiers OptPartial CLASS Identifier TypeFormals
-                       ClassBase TypeParameterConstraintsClauses {
+       | OptAttributes OptModifiers OptPartial CLASS GenericIdentifierStart
+                       TypeFormals ClassBase TypeParameterConstraintsClauses {
 #if IL_VERSION_MAJOR > 1
                                $$.attributes = $1;
                                $$.modifiers = $2;
@@ -3252,13 +3310,9 @@
        ;
 
 TypeFormals
-       : '<' TypeFormalList '>'                        { 
+       : TypeFormalList '>'                    { 
                                $$ = (ILNode_GenericTypeParameters *)
-                                               
ILNode_GenericTypeParameters_create($2.count, $2.list);
-                       }
-       | GENERIC_LT TypeFormalList '>'         {
-                               $$ = (ILNode_GenericTypeParameters *)
-                                               
ILNode_GenericTypeParameters_create($2.count, $2.list);
+                                               
ILNode_GenericTypeParameters_create($1.count, $1.list);
                        }
        ;
 
@@ -3532,47 +3586,29 @@
  * Methods.
  */
 MethodHeader
-       : OptAttributes OptModifiers Type QualifiedIdentifier
-                       '(' OptFormalParameterList ')' 
TypeParameterConstraintsClauses {
+       : OptAttributes OptModifiers Type NonGenericQualifiedIdentifier
+                       '(' OptFormalParameterList ')'  {
                                $$.attributes = $1;
                                $$.modifiers = $2;
                                $$.type = $3;
                                $$.args = (ILNode_List *)$6;
-#if IL_VERSION_MAJOR > 1
-                               if(yyisa($4, ILNode_Identifier))
-                               {
                                        $$.identifier = $4;
                                        $$.typeFormals = 0;
-                                       if($8 != 0)
-                                       {
-                                               
CCErrorOnLine(yygetfilename($8), yygetlinenum($8),
-                                                                 "constraints 
are not allowed without generic parameters");
                                        }
-                               }
-                               else if(yyisa($4, ILNode_GenericReference))
-                               {
-                                       $$.identifier = 
((ILNode_GenericReference *)$4)->type;
-
-                                       $$.typeFormals = 
TypeActualsToTypeFormals(((ILNode_GenericReference *)$4)->typeArguments);
-
-                                       if($$.typeFormals != 0)
-                                       {
-                                               
MergeGenericConstraints($$.typeFormals, $8);
-                                       }
-                               }
-                               else
-                               {
+       | OptAttributes OptModifiers Type NonGenericQualifiedIdentifier '<' 
TypeFormals
+                       '(' OptFormalParameterList ')' 
TypeParameterConstraintsClauses {
+                               $$.attributes = $1;
+                               $$.modifiers = $2;
+                               $$.type = $3;
+                               $$.args = (ILNode_List *)$8;
                                        $$.identifier = $4;
-                                       $$.typeFormals = 0;
-                               }
+#if IL_VERSION_MAJOR > 1
+                               $$.typeFormals = $6;
+                               MergeGenericConstraints($6, $10);
 #else  /* IL_VERSION_MAJOR == 1 */
-                               $$.identifier = $4;
                                $$.typeFormals = 0;
-                               if($8 != 0)
-                               {
-                                       CCErrorOnLine(yygetfilename($8), 
yygetlinenum($8),
+                               CCErrorOnLine(yygetfilename($4), 
yygetlinenum($4),
                                                                  "generics are 
not supported in this version");
-                               }
 #endif /* IL_VERSION_MAJOR == 1 */
                        }
 
@@ -3901,10 +3937,10 @@
                                $$.ident = ILQualIdentSimple(NULL);
                                $$.params = $3;
                        }
-       | Type QualifiedIdentifier '.' THIS FormalIndexParameters       {
+       | Type QualifiedIdentifierMemberAccessStart THIS FormalIndexParameters  
{
                                $$.type = $1;
                                $$.ident = $2;
-                               $$.params = $5;
+                               $$.params = $4;
                        }
        ;
 
@@ -4039,7 +4075,7 @@
        | '|'           { $$.binary = "op_BitwiseOr"; $$.unary = 0; }
        | '^'           { $$.binary = "op_ExclusiveOr"; $$.unary = 0; }
        | LEFT_OP       { $$.binary = "op_LeftShift"; $$.unary = 0; }
-       | RIGHT_OP      { $$.binary = "op_RightShift"; $$.unary = 0; }
+       | RightShift{ $$.binary = "op_RightShift"; $$.unary = 0; }
        | EQ_OP         { $$.binary = "op_Equality"; $$.unary = 0; }
        | NE_OP         { $$.binary = "op_Inequality"; $$.unary = 0; }
        | '>'           { $$.binary = "op_GreaterThan"; $$.unary = 0; }
@@ -4129,12 +4165,6 @@
                                        ClassNameCtorDefined();
                                }
                                ctorName = $3;
-                               if(yyisa(ctorName, ILNode_GenericReference))
-                               {
-                                       CCErrorOnLine(yygetfilename($3), 
yygetlinenum($3),
-                                               "constructors cannot have type 
parameters");
-                                       ctorName = ((ILNode_GenericReference 
*)ctorName)->type;
-                               }
                                if(!ClassNameSame(ctorName))
                                {
                                        CCErrorOnLine(yygetfilename($3), 
yygetlinenum($3),
@@ -4216,14 +4246,7 @@
                                }
                        #endif  /* IL_VERSION_MAJOR > 1 */
 
-                               /* Destructors cannot have type parameters */
                                dtorName = $4;
-                               if(yyisa(dtorName, ILNode_GenericReference))
-                               {
-                                       CCErrorOnLine(yygetfilename($4), 
yygetlinenum($4),
-                                               "destructors cannot have type 
parameters");
-                                       dtorName = ((ILNode_GenericReference 
*)dtorName)->type;
-                               }
 
                                /* Validate the destructor name */
                                if(!ClassNameSame(dtorName))
@@ -4272,8 +4295,8 @@
                                $$.classBase = $6;
                                $$.typeFormals = 0;
                        }
-       | OptAttributes OptModifiers OptPartial STRUCT Identifier TypeFormals
-                       StructInterfaces TypeParameterConstraintsClauses {
+       | OptAttributes OptModifiers OptPartial STRUCT GenericIdentifierStart
+                       TypeFormals StructInterfaces 
TypeParameterConstraintsClauses {
 #if IL_VERSION_MAJOR > 1
                                $$.attributes = $1;
                                $$.modifiers = $2;
@@ -4376,8 +4399,8 @@
                                $$.classBase = $6;
                                $$.typeFormals = 0;
                        }
-       | OptAttributes OptModifiers OptPartial INTERFACE Identifier TypeFormals
-                       InterfaceBase TypeParameterConstraintsClauses {
+       | OptAttributes OptModifiers OptPartial INTERFACE GenericIdentifierStart
+                       TypeFormals InterfaceBase 
TypeParameterConstraintsClauses {
 #if IL_VERSION_MAJOR > 1
                                $$.attributes = $1;
                                $$.modifiers = $2;
@@ -4490,7 +4513,7 @@
                                $$.args = (ILNode_List *)$6;
                                $$.typeFormals = 0;
                        }
-       | OptAttributes OptNew Type Identifier  TypeFormals 
+       | OptAttributes OptNew Type GenericIdentifierStart TypeFormals
                        '(' OptFormalParameterList ')' 
TypeParameterConstraintsClauses {
 #if IL_VERSION_MAJOR > 1
                                $$.attributes = $1;
@@ -4759,7 +4782,7 @@
                                $$.args = (ILNode_List *)$7;
                                $$.typeFormals = 0;
                        }
-       | OptAttributes OptModifiers DELEGATE Type Identifier TypeFormals
+       | OptAttributes OptModifiers DELEGATE Type GenericIdentifierStart 
TypeFormals
                                '(' OptFormalParameterList ')' 
TypeParameterConstraintsClauses {
 #if IL_VERSION_MAJOR > 1
                                $$.attributes = $1;

Index: cscc/csharp/cs_internal.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_internal.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- cscc/csharp/cs_internal.h   14 Oct 2007 19:48:15 -0000      1.25
+++ cscc/csharp/cs_internal.h   23 Oct 2007 18:32:21 -0000      1.26
@@ -49,6 +49,22 @@
 };
 
 /*
+ * Structure for member accesses.
+ */
+struct MemberName
+{
+       ILNode             *identifier;
+       ILUInt32                numTypeArgs;
+       ILNode_List        *typeArgs;
+};
+
+struct MemberAccess
+{
+       ILNode                     *parent;
+       struct MemberName       memberName;
+};
+
+/*
  * Modifier mask bits.
  */
 #define        CS_MODIFIER_PUBLIC                      (1<<0)
@@ -289,24 +305,6 @@
 void CSAddDefaultMemberAttr(ILGenInfo *info, ILClass *classInfo,
                                                        const char *name);
 
-/*
- * Insert generic type actuals into an expression node at
- * the right-most position.
- */
-ILNode *CSInsertGenericReference(ILNode *mainNode, ILUInt32 numActuals,
-                                                                ILNode 
*actuals);
-
-/*
- * Insert a type at the beginning of a type actuals list.
- */
-ILNode *CSInsertTypeActuals(ILNode *type, ILNode *actuals);
-
-/*
- * Insert a method invocation into an expression node at the
- * right-most position, just after a generic type reference.
- */
-ILNode *CSInsertMethodInvocation(ILNode *mainNode, ILNode *parameters);
-
 #ifdef __cplusplus
 };
 #endif

Index: cscc/csharp/cs_lookup.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_lookup.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- cscc/csharp/cs_lookup.c     20 Sep 2007 20:04:16 -0000      1.37
+++ cscc/csharp/cs_lookup.c     23 Oct 2007 18:32:21 -0000      1.38
@@ -897,9 +897,20 @@
        if(genInfo->currentClass &&
                ((ILNode_ClassDefn *)(genInfo->currentClass))->classInfo)
        {
-               return ((ILNode_ClassDefn *)(genInfo->currentClass))->classInfo;
+               ILNode_ClassDefn *currentClass;
+
+               currentClass = (ILNode_ClassDefn *)(genInfo->currentClass);
+               while(currentClass)
+               {
+                       if((currentClass->classInfo != (ILClass *)1) &&
+                          (currentClass->classInfo != (ILClass *)2))
+                       {
+                               return currentClass->classInfo;
+                       }
+                       currentClass = currentClass->nestedParent;
+               }
        }
-       else if(defIsModule)
+       if(defIsModule)
        {
                return ILClassLookup(ILClassGlobalScope(genInfo->image),
                                                         "<Module>", (const 
char *)0);

Index: cscc/csharp/cs_scanner.l
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_scanner.l,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- cscc/csharp/cs_scanner.l    17 Mar 2007 16:10:14 -0000      1.16
+++ cscc/csharp/cs_scanner.l    23 Oct 2007 18:32:21 -0000      1.17
@@ -976,7 +976,6 @@
 "++"                                   { RETURNTOK(INC_OP); }
 "--"                                   { RETURNTOK(DEC_OP); }
 "<<"                                   { RETURNTOK(LEFT_OP); }
-">>"                                   { RETURNTOK(RIGHT_OP); }
 "<="                                   { RETURNTOK(LE_OP); }
 ">="                                   { RETURNTOK(GE_OP); }
 "=="                                   { RETURNTOK(EQ_OP); }
@@ -1124,21 +1123,6 @@
 "///"[^\n]*\n          { yylval.string = ILInternString(yytext + 3, -1);
                                          RETURNTOK(DOC_COMMENT); }
 
-"<"/{GENERICPREFIX}    {
-                       /* This looks like it may be a generic type reference
-                          rather than a less than sign within an expression.
-                          We return a different token code so that the parser
-                          can properly distinguish generic types in 
expressions */
-                       if(CSNoGenerics)
-                       {
-                               return '<';
-                       }
-                       else
-                       {
-                               return GENERIC_LT;
-                       }
-               }
-
 .                                      { RETURNTOK(((int)(yytext[0])) & 0xFF); 
}
 
 %%

Index: cscc/csharp/cs_types.tc
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/cscc/csharp/cs_types.tc,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- cscc/csharp/cs_types.tc     20 Sep 2007 20:04:17 -0000      1.11
+++ cscc/csharp/cs_types.tc     23 Oct 2007 18:32:21 -0000      1.12
@@ -319,17 +319,16 @@
 static void SemWithType(ILGenInfo *info, ILType *withType,
                                            ILNode *actuals, ILNode **parent)
 {
-       CSSemValue value;
-       if(yyisa(actuals, ILNode_TypeActuals))
-       {
-               SemWithType(info, withType, ((ILNode_TypeActuals 
*)actuals)->left,
-                                       &(((ILNode_TypeActuals 
*)actuals)->left));
-               SemWithType(info, withType, ((ILNode_TypeActuals 
*)actuals)->right,
-                                       &(((ILNode_TypeActuals 
*)actuals)->right));
-       }
-       else
+       ILNode_ListIter iter;
+       ILNode *child;
+
+       ILNode_ListIter_Init(&iter, actuals);
+       while((child = ILNode_ListIter_Next(&iter)) != 0)
        {
-               value = ILNode_SemAnalysisType(actuals, info, parent);
+               CSSemValue value;
+
+               value = ILNode_SemAnalysisType(child, info, &child);
+
                if(!CSSemIsType(value))
                {
                        CCErrorOnLine(yygetfilename(actuals), 
yygetlinenum(actuals),
@@ -346,6 +345,72 @@
 %}
 
 /*
+ *  Perform semantic analysis  for a generic type or method reference
+ *  with a bias to returning Type objects.
+ */
+ILNode_SemAnalysisType(ILNode_GenericReference)
+{
+       CSSemValue value;
+       const char *name;
+       int savedState=info->inSemType;
+       char buffer[261];
+
+       /* Get the type name with the generic arity appended */
+       sprintf(buffer, "%s`%i",
+                       ILQualIdentName(node->identifier, 0),
+                       node->numArgs);
+       name = buffer;
+
+       info->inSemType = -1;
+
+       /* Perform semantic analysis on the main part of the type */
+       if(node->left)
+       {
+               CSSemValue value2;
+
+               /* Get the semantic value for the left part of the identifier */
+               value2 = ILNode_SemAnalysisType(node->left, info, 
&(node->left));
+
+               /* Resolve the member */
+               value = CSResolveMemberName(info, (ILNode *)node, value2, name, 
1);
+       }
+       else
+       {
+               value = CSResolveSimpleNameQuiet(info, (ILNode *)node, name, 1);
+       }
+       info->inSemType = savedState;
+       
+       if(CSSemGetKind(value) == CS_SEMKIND_TYPE)
+       {
+               ILType *withType;
+               /* TODO: perform the analysis for the TypeActuals. */
+
+               /* Build the "with" type and return it */
+               withType = ILTypeCreateWith(info->context, CSSemGetType(value));
+               if(!withType)
+               {
+                       CCOutOfMemory();
+               }
+               SemWithType(info, withType, node->typeArguments, 
&(node->typeArguments));
+               CSSemSetType(value, withType);
+
+               /* Convert the result into an l-value or r-value and return it 
*/
+               return SemToLRValue((ILNode *)node, info, parent, value,
+                                                       name, node->left, 
&value);
+       }
+       else if(CSSemGetKind(value) == CS_SEMKIND_TYPE_NODE)
+       {
+               /* TODO: perform the analysis for the TypeActuals. */
+
+               /* Convert the result into an l-value or r-value and return it 
*/
+               return SemToLRValue((ILNode *)node, info, parent, value,
+                                                       name, node->left, 
&value);
+
+       }
+       return CSSemValueDefault;
+}
+
+/*
  * Perform semantic analysis for a generic type or method reference.
  */
 ILNode_SemAnalysis(ILNode_GenericReference)
@@ -354,12 +419,32 @@
        ILClass *classInfo;
        ILUInt32 numFormals;
        ILType *withType;
+       const char *name;
+       char buffer[261];
 
-       /* Perform semantic analysis on the main part of the type */
-       value = ILNode_SemAnalysisType(node->type, info, &(node->type));
+       /* Get the type name with the generic arity appended */
+       sprintf(buffer, "%s`%i",
+                       ILQualIdentName(node->identifier, 0),
+                       node->numArgs);
+       name = buffer;
+
+       if(node->left)
+       {
+               CSSemValue value2;
+
+               /* Get the semantic value for the left part of the identifier */
+               value2 = ILNode_SemAnalysisType(node->left, info, 
&(node->left));
+
+               /* Resolve the member */
+               value = CSResolveMemberName(info, (ILNode *)node, value2, name, 
1);
+       }
+       else
+       {
+               value = CSResolveSimpleNameQuiet(info, (ILNode *)node, name, 1);
+       }
        if(!CSSemIsType(value))
        {
-               CCErrorOnLine(yygetfilename(node->type), 
yygetlinenum(node->type),
+               CCErrorOnLine(yygetfilename(node->identifier), 
yygetlinenum(node->identifier),
                                          "type name expected in generic type 
reference");
                return value;
        }
@@ -392,55 +477,5 @@
 
 %end %{
 
-/*
- * Find the position to insert a generic type reference,
- * to re-arrange an expression that was parsed by the
- * "GenericReference" production in the grammar.
- */
-static ILNode **FindGenericInsertPosition(ILNode *node, ILNode **parent)
-{
-       if(yyisa(node, ILNode_BinaryExpression))
-       {
-               ILNode_BinaryExpression *binary = (ILNode_BinaryExpression 
*)node;
-               return FindGenericInsertPosition(binary->expr2, 
&(binary->expr2));
-       }
-       else if(yyisa(node, ILNode_UnaryExpression))
-       {
-               ILNode_UnaryExpression *unary = (ILNode_UnaryExpression *)node;
-               return FindGenericInsertPosition(unary->expr, &(unary->expr));
-       }
-       else
-       {
-               return parent;
-       }
-}
-
-ILNode *CSInsertGenericReference(ILNode *mainNode, ILUInt32 numActuals, ILNode 
*actuals)
-{
-       ILNode **parent = FindGenericInsertPosition(mainNode, &mainNode);
-       *parent = ILNode_GenericReference_create(*parent, numActuals, actuals);
-       return mainNode;
-}
-
-ILNode *CSInsertTypeActuals(ILNode *type, ILNode *actuals)
-{
-       if(yyisa(actuals, ILNode_TypeActuals))
-       {
-               ((ILNode_TypeActuals *)actuals)->left =
-                       CSInsertTypeActuals(type, ((ILNode_TypeActuals 
*)actuals)->left);
-               return actuals;
-       }
-       else
-       {
-               return ILNode_TypeActuals_create(type, actuals);
-       }
-}
-
-ILNode *CSInsertMethodInvocation(ILNode *mainNode, ILNode *parameters)
-{
-       ILNode **parent = FindGenericInsertPosition(mainNode, &mainNode);
-       *parent = ILNode_InvocationExpression_create(*parent, parameters);
-       return mainNode;
-}
 
 %}




reply via email to

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