2001-11-01 Ravi Pratap <ravi@ximian.com>
authorRavi Pratap M <ravi@mono-cvs.ximian.com>
Thu, 1 Nov 2001 07:27:12 +0000 (07:27 -0000)
committerRavi Pratap M <ravi@mono-cvs.ximian.com>
Thu, 1 Nov 2001 07:27:12 +0000 (07:27 -0000)
* tree.cs (RecordNamespace): Fix up to check for the correct key.

* cs-parser.jay (GetQualifiedIdentifier): New Helper method used in
local_variable_type to extract the string corresponding to the type.

(local_variable_type): Fixup the action to use the new helper method.

* codegen.cs : Get rid of RefOrOutParameter, it's not the right way to
go.

* expression.cs : Clean out code which uses the above.

svn path=/trunk/mcs/; revision=1239

mcs/mcs/ChangeLog
mcs/mcs/class.cs
mcs/mcs/codegen.cs
mcs/mcs/cs-parser.jay
mcs/mcs/expression.cs
mcs/mcs/tree.cs

index 650a8904039a88033b1d5f5d6982a16b2846bf8c..c72cad61028086d5e3293c81a7f93a94d3b48f2d 100755 (executable)
@@ -1,5 +1,19 @@
-2001-10-31  Ravi Pratap  <ravi@ximian.com>
+2001-11-01  Ravi Pratap  <ravi@ximian.com>
+
+       * tree.cs (RecordNamespace): Fix up to check for the correct key.
+
+       * cs-parser.jay (GetQualifiedIdentifier): New Helper method used in 
+       local_variable_type to extract the string corresponding to the type.
+
+       (local_variable_type): Fixup the action to use the new helper method.
 
+       * codegen.cs : Get rid of RefOrOutParameter, it's not the right way to 
+       go.
+
+       * expression.cs : Clean out code which uses the above.
+
+2001-10-31  Ravi Pratap  <ravi@ximian.com>
+       
        * typemanager.cs (RegisterMethod): Check if we already have an existing key
        and bale out if necessary by returning a false.
 
index 7131a6f14ac42dd0a7e27b5c348c354aca6a43d8..b7e90be570bb1339e6087091f73abbafabdbd420 100755 (executable)
@@ -613,7 +613,7 @@ namespace CIR {
 
                        error = false;
                        name = MakeFQN (ns, name);
-                       
+
                        t  = RootContext.TypeManager.LookupType (name);
                        if (t != null)
                                return t;
@@ -623,7 +623,7 @@ namespace CIR {
                        } else {
                                parent = (Struct) RootContext.Tree.Structs [name];
                        }
-                       
+
                        if (parent != null){
                                t = parent.DefineType (builder);
                                if (t == null){
@@ -657,6 +657,16 @@ namespace CIR {
                        if (t != null) 
                                return t;
 
+                       //
+                       // Attempt to do a direct unqualified lookup
+                       //
+                       t = LookupInterfaceOrClass (builder, "", name, is_class, out error);
+                       if (error)
+                               return null;
+                       
+                       if (t != null)
+                               return t;
+                       
                        //
                        // Attempt to lookup the class on any of the `using'
                        // namespaces
index a7e7cc9c4d78ce855462879031696cd8be42d192..f25d75f904ed9ab98c3a194e6b7654df32a6021e 100755 (executable)
@@ -185,10 +185,5 @@ namespace CIR {
                // 
                public bool  InLoop;
 
-               //
-               // Whether we are currently emitting code for a ref/out parameter
-               //
-               public bool  RefOrOutParameter;
-               
        }
 }
index 4d6d7fb5666542bf7fd200a2ea1922a51817a8a0..ba3c46370a0d1e663e6430e492b5ee05bf645608 100755 (executable)
@@ -2437,16 +2437,16 @@ local_variable_type
                // creeps up.  If you use qualified_identifier (which is all we need
                // really) two shift/reduces appear.
                // 
-               // So, instead we do a super trick: we just allow ($1) to be a 
-               // SimpleName Expression.
-               //
-               if (((Expression) $1) is SimpleName)
-                       $$ = ((SimpleName) $1).Name + (string) $2;
-               else {
+
+               //  So we be a little smart :-)
+               Expression expr = (Expression) $1;  
+               if (!(expr is SimpleName) && !(expr is MemberAccess)) {
                        Location l = lexer.Location;
+                       Console.WriteLine (((MemberAccess) $1).Identifier);
                        Report.Error (-1, l, "Invalid Type definition");
                        $$ = "System.Object";
                }
+               $$ = GetQualifiedIdentifier (expr) + (string) $2;
          }
        | builtin_types opt_rank_specifier
          {
@@ -3078,6 +3078,23 @@ Expression DecomposeQI (string name, Location l)
        }
 }
 
+// <summary>
+//  This method is used to get at the complete string representation of
+//  a fully-qualified type name, hiding inside a MemberAccess ;-)
+//  This is necessary because local_variable_type admits primary_expression
+//  as the type of the variable. So we do some extra checking
+// </summary>
+string GetQualifiedIdentifier (Expression expr)
+{
+       if (expr is SimpleName)
+               return ((SimpleName)expr).Name;
+       else if (expr is MemberAccess)
+               return GetQualifiedIdentifier (((MemberAccess)expr).Expr) + "." + ((MemberAccess) expr).Identifier;
+       else 
+               throw new Exception ("Expr has to be either SimpleName or MemberAccess !");
+       
+}
+
 Block declare_local_variables (string type, ArrayList variable_declarators)
 {
        Block implicit_block;
index 00ddd9428ef403c2dc2fb6b3ce7c76fbbb129e36..0544188bc4305226d7e4090d0fa703325b9a6819 100755 (executable)
@@ -3350,40 +3350,34 @@ namespace CIR {
                        ILGenerator ig = ec.ig;
                        int idx = vi.Idx;
 
-                       bool ref_parameter = ec.RefOrOutParameter;
-                       
                        vi.Used = true;
 
-                       if (!ref_parameter) {
+                       switch (idx){
+                       case 0:
+                               ig.Emit (OpCodes.Ldloc_0);
+                               break;
                                
-                               switch (idx){
-                               case 0:
-                                       ig.Emit (OpCodes.Ldloc_0);
-                                       break;
-                                       
-                               case 1:
-                                       ig.Emit (OpCodes.Ldloc_1);
-                                       break;
-                                       
-                               case 2:
-                                       ig.Emit (OpCodes.Ldloc_2);
-                                       break;
-                                       
-                               case 3:
-                                       ig.Emit (OpCodes.Ldloc_3);
-                                       break;
-                                       
-                               default:
-                                       if (idx <= 255)
-                                               ig.Emit (OpCodes.Ldloc_S, (byte) idx);
-                                       else
-                                               ig.Emit (OpCodes.Ldloc, idx);
-                                       break;
-                               }
-                       } else 
-                               AddressOf (ec);
+                       case 1:
+                               ig.Emit (OpCodes.Ldloc_1);
+                               break;
+                               
+                       case 2:
+                               ig.Emit (OpCodes.Ldloc_2);
+                               break;
+                               
+                       case 3:
+                               ig.Emit (OpCodes.Ldloc_3);
+                               break;
+                               
+                       default:
+                               if (idx <= 255)
+                                       ig.Emit (OpCodes.Ldloc_S, (byte) idx);
+                               else
+                                       ig.Emit (OpCodes.Ldloc, idx);
+                               break;
+                       }
                }
-
+               
                public static void Store (ILGenerator ig, int idx)
                {
                        switch (idx){
@@ -3564,11 +3558,7 @@ namespace CIR {
 
                public void Emit (EmitContext ec)
                {
-                       if (ArgType == AType.Ref || ArgType == AType.Out)
-                               ec.RefOrOutParameter = true;
-
                        expr.Emit (ec);
-                       ec.RefOrOutParameter = false;
                }
        }
 
index e053d4181f12e47273e68689f1748d72bd61d4d7..7e88ffaa5a935c9471ae9342a5c16fb0426cdd72 100755 (executable)
@@ -90,11 +90,12 @@ namespace CIR
                {
                        if (namespaces == null)
                                namespaces = new Hashtable ();
-
-                       if (namespaces.ContainsKey (name))
-                               return (Namespace) namespaces [name];
-                                                                            
+                                                                                                    
                        Namespace ns = new Namespace (parent, name);
+
+                       if (namespaces.Contains (ns.Name))
+                               return (Namespace) namespaces [ns.Name];
+                       
                        namespaces.Add (ns.Name, ns);
                        return ns;
                }