2010-06-07 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Mon, 7 Jun 2010 18:59:55 +0000 (18:59 -0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 7 Jun 2010 18:59:55 +0000 (18:59 -0000)
* typemanager.cs, eval.cs, iterators.cs, anonymous.cs, expression.cs
method.cs, class.cs, delegate.cs, cs-parser.jay, driver.cs, visit.cs
enum.cs: Hold location of predefined types.

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

13 files changed:
mcs/mcs/ChangeLog
mcs/mcs/anonymous.cs
mcs/mcs/class.cs
mcs/mcs/cs-parser.jay
mcs/mcs/delegate.cs
mcs/mcs/driver.cs
mcs/mcs/enum.cs
mcs/mcs/eval.cs
mcs/mcs/expression.cs
mcs/mcs/iterators.cs
mcs/mcs/method.cs
mcs/mcs/typemanager.cs
mcs/mcs/visit.cs

index 154227f24f44f89d862c8cc35e3ec87b29b73c32..51a0e44d6d15c97bee5720fb59acbb78e72f1c7f 100644 (file)
@@ -1,3 +1,9 @@
+2010-06-07  Marek Safar  <marek.safar@gmail.com>
+
+       * typemanager.cs, eval.cs, iterators.cs, anonymous.cs, expression.cs
+       method.cs, class.cs, delegate.cs, cs-parser.jay, driver.cs, visit.cs
+       enum.cs: Hold location of predefined types.
+
 2010-06-07  Marek Safar  <marek.safar@gmail.com>
 
        A fix for bug #610878
index e312e201ae924b977273bd6cdb2ed736adef0460..e5064744ba9d1f1d03c05864b4af0b242cc25bf5 100644 (file)
@@ -1713,11 +1713,11 @@ namespace Mono.CSharp {
 
                        Location loc = Location;
 
-                       Method equals = new Method (this, null, TypeManager.system_boolean_expr,
+                       Method equals = new Method (this, null, new TypeExpression (TypeManager.bool_type, loc),
                                Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Equals", loc),
                                Mono.CSharp.ParametersCompiled.CreateFullyResolved (new Parameter (null, "obj", 0, null, loc), TypeManager.object_type), null);
 
-                       Method tostring = new Method (this, null, TypeManager.system_string_expr,
+                       Method tostring = new Method (this, null, new TypeExpression (TypeManager.string_type, loc),
                                Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("ToString", loc),
                                Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);
 
@@ -1826,7 +1826,7 @@ namespace Mono.CSharp {
                        //
                        // GetHashCode () override
                        //
-                       Method hashcode = new Method (this, null, TypeManager.system_int32_expr,
+                       Method hashcode = new Method (this, null, new TypeExpression (TypeManager.int32_type, loc),
                                Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN,
                                new MemberName ("GetHashCode", loc),
                                Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);
@@ -1849,7 +1849,7 @@ namespace Mono.CSharp {
                        Block hashcode_block = new Block (hashcode_top);
                        hashcode_top.AddStatement (new Unchecked (hashcode_block));
 
-                       hashcode_block.AddVariable (TypeManager.system_int32_expr, "hash", loc);
+                       hashcode_block.AddVariable (new TypeExpression (TypeManager.int32_type, loc), "hash", loc);
                        LocalVariableReference hash_variable = new LocalVariableReference (hashcode_block, "hash", loc);
                        LocalVariableReference hash_variable_assign = new LocalVariableReference (hashcode_block, "hash", loc);
                        hashcode_block.AddStatement (new StatementExpression (
index a950801e5da0a3ea3492a169f33e905c8d58bd16..da90e2140d29cfb27ce198cc3b0a352180127857 100644 (file)
@@ -186,7 +186,8 @@ namespace Mono.CSharp {
                // This one is computed after we can distinguish interfaces
                // from classes from the arraylist `type_bases' 
                //
-               TypeExpr base_type;
+               protected TypeSpec base_type;
+               protected TypeExpr base_type_expr;
                protected TypeExpr[] iface_exprs;
 
                protected List<FullNamedExpression> type_bases;
@@ -591,7 +592,7 @@ namespace Mono.CSharp {
                        }
                }
 
-               public virtual TypeSpec BaseType {
+               public TypeSpec BaseType {
                        get {
                                return spec.BaseType;
                        }
@@ -840,7 +841,9 @@ namespace Mono.CSharp {
                                                Report.Error (1965, Location, "Class `{0}' cannot derive from the dynamic type",
                                                        GetSignatureForError ());
                                        else
-                                               base_class = fne_resolved;
+                                               base_type = fne_resolved.Type;
+
+                                       base_class = fne_resolved;
                                        continue;
                                }
 
@@ -880,7 +883,7 @@ namespace Mono.CSharp {
                        return ifaces;
                }
 
-               TypeExpr[] GetNormalPartialBases (ref TypeExpr base_class)
+               TypeExpr[] GetNormalPartialBases ()
                {
                        var ifaces = new List<TypeExpr> (0);
                        if (iface_exprs != null)
@@ -889,18 +892,15 @@ namespace Mono.CSharp {
                        foreach (TypeContainer part in partial_parts) {
                                TypeExpr new_base_class;
                                TypeExpr[] new_ifaces = part.ResolveBaseTypes (out new_base_class);
-                               if (new_base_class != TypeManager.system_object_expr) {
-                                       if (base_class == TypeManager.system_object_expr)
-                                               base_class = new_base_class;
-                                       else {
-                                               if (new_base_class != null && !TypeManager.IsEqual (new_base_class.Type, base_class.Type)) {
-                                                       Report.SymbolRelatedToPreviousError (base_class.Location, "");
-                                                       Report.Error (263, part.Location,
-                                                               "Partial declarations of `{0}' must not specify different base classes",
-                                                               part.GetSignatureForError ());
-
-                                                       return null;
-                                               }
+                               if (new_base_class != null) {
+                                       if (base_type_expr != null && new_base_class.Type != base_type) {
+                                               Report.SymbolRelatedToPreviousError (new_base_class.Location, "");
+                                               Report.Error (263, part.Location,
+                                                       "Partial declarations of `{0}' must not specify different base classes",
+                                                       part.GetSignatureForError ());
+                                       } else {
+                                               base_type_expr = new_base_class;
+                                               base_type = base_type_expr.Type;
                                        }
                                }
 
@@ -1038,9 +1038,9 @@ namespace Mono.CSharp {
 
                bool DefineBaseTypes ()
                {
-                       iface_exprs = ResolveBaseTypes (out base_type);
+                       iface_exprs = ResolveBaseTypes (out base_type_expr);
                        if (partial_parts != null) {
-                               iface_exprs = GetNormalPartialBases (ref base_type);
+                               iface_exprs = GetNormalPartialBases ();
                        }
 
                        var cycle = CheckRecursiveDefinition (this);
@@ -1113,23 +1113,11 @@ namespace Mono.CSharp {
                                return true;
                        }
 
-                       TypeSpec base_ts;
-                       if (base_type != null)
-                               base_ts = base_type.Type;
-                       else if (spec.IsStruct)
-                               base_ts = TypeManager.value_type;
-                       else if (spec.IsEnum)
-                               base_ts = TypeManager.enum_type;
-                       else if (spec.IsDelegate)
-                               base_ts = TypeManager.multicast_delegate_type;
-                       else
-                               base_ts = null;
-
-                       if (base_ts != null) {
-                               spec.BaseType = base_ts;
+                       if (base_type != null) {
+                               spec.BaseType = base_type;
 
                                // Set base type after type creation
-                               TypeBuilder.SetParent (base_ts.GetMetaInfo ());
+                               TypeBuilder.SetParent (base_type.GetMetaInfo ());
                        }
 
                        return true;
@@ -1347,10 +1335,10 @@ namespace Mono.CSharp {
 
                        InTransit = tc;
 
-                       if (base_type != null && base_type.Type != null) {
-                               var ptc = base_type.Type.MemberDefinition as TypeContainer;
+                       if (base_type_expr != null) {
+                               var ptc = base_type.MemberDefinition as TypeContainer;
                                if (ptc != null && ptc.CheckRecursiveDefinition (this) != null)
-                                       return base_type.Type;
+                                       return base_type;
                        }
 
                        if (iface_exprs != null) {
@@ -1425,16 +1413,18 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       if (base_type != null) {
-                               ObsoleteAttribute obsolete_attr = base_type.Type.GetAttributeObsolete ();
+                       if (base_type_expr != null) {
+                               ObsoleteAttribute obsolete_attr = base_type.GetAttributeObsolete ();
                                if (obsolete_attr != null && !IsObsolete)
                                        AttributeTester.Report_ObsoleteMessage (obsolete_attr, base_type.GetSignatureForError (), Location, Report);
 
-                               var ct = base_type as GenericTypeExpr;
+                               var ct = base_type_expr as GenericTypeExpr;
                                if (ct != null)
                                        ct.CheckConstraints (this);
+                       }
 
-                               var baseContainer = base_type.Type.MemberDefinition as ClassOrStruct;
+                       if (base_type != null) {
+                               var baseContainer = base_type.MemberDefinition as ClassOrStruct;
                                if (baseContainer != null) {
                                        baseContainer.Define ();
 
@@ -2341,10 +2331,8 @@ namespace Mono.CSharp {
 
                        if (base_class == null) {
                                if (spec != TypeManager.object_type)
-                                       base_class = TypeManager.system_object_expr;
+                                       base_type = TypeManager.object_type;
                        } else {
-                               var base_type = base_class.Type;
-
                                if (base_type.IsGenericParameter){
                                        Report.Error (689, base_class.Location, "`{0}': Cannot derive from type parameter `{1}'",
                                                GetSignatureForError (), base_type.GetSignatureForError ());
@@ -2356,10 +2344,13 @@ namespace Mono.CSharp {
                                        Report.SymbolRelatedToPreviousError (base_class.Type);
                                        Report.Error (709, Location, "`{0}': Cannot derive from static class `{1}'",
                                                GetSignatureForError (), base_type.GetSignatureForError ());
-                               } else if (base_type.IsSealed){
+                               } else if (base_type.IsSealed) {
                                        Report.SymbolRelatedToPreviousError (base_class.Type);
                                        Report.Error (509, Location, "`{0}': cannot derive from sealed type `{1}'",
                                                GetSignatureForError (), base_type.GetSignatureForError ());
+                               } else if (PartialContainer.IsStatic && base_class.Type != TypeManager.object_type) {
+                                       Report.Error (713, Location, "Static class `{0}' cannot derive from type `{1}'. Static classes must derive from object",
+                                               GetSignatureForError (), base_class.GetSignatureForError ());
                                }
 
                                if (base_type is PredefinedTypeSpec && !(spec is PredefinedTypeSpec) &&
@@ -2367,7 +2358,8 @@ namespace Mono.CSharp {
                                        base_type == TypeManager.delegate_type || base_type == TypeManager.array_type)) {
                                        Report.Error (644, Location, "`{0}' cannot derive from special class `{1}'",
                                                GetSignatureForError (), base_type.GetSignatureForError ());
-                                       base_class = TypeManager.system_object_expr;
+
+                                       base_type = TypeManager.object_type;
                                }
 
                                if (!IsAccessibleAs (base_type)) {
@@ -2377,18 +2369,10 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       if (PartialContainer.IsStatic) {
-                               if (base_class.Type != TypeManager.object_type) {
-                                       Report.Error (713, Location, "Static class `{0}' cannot derive from type `{1}'. Static classes must derive from object",
-                                               GetSignatureForError (), base_class.GetSignatureForError ());
-                                       return ifaces;
-                               }
-
-                               if (ifaces != null) {
-                                       foreach (TypeExpr t in ifaces)
-                                               Report.SymbolRelatedToPreviousError (t.Type);
-                                       Report.Error (714, Location, "Static class `{0}' cannot implement interfaces", GetSignatureForError ());
-                               }
+                       if (PartialContainer.IsStatic && ifaces != null) {
+                               foreach (TypeExpr t in ifaces)
+                                       Report.SymbolRelatedToPreviousError (t.Type);
+                               Report.Error (714, Location, "Static class `{0}' cannot implement interfaces", GetSignatureForError ());
                        }
 
                        return ifaces;
@@ -2590,7 +2574,7 @@ namespace Mono.CSharp {
                protected override TypeExpr[] ResolveBaseTypes (out TypeExpr base_class)
                {
                        TypeExpr[] ifaces = base.ResolveBaseTypes (out base_class);
-                       base_class = TypeManager.system_valuetype_expr;
+                       base_type = TypeManager.value_type;
                        return ifaces;
                }
 
index 20af9defc05b38a6558279ea3a7aa22c2d154743..8590224e582ab112a0d8e414b5fe9f54cafb86fb 100644 (file)
@@ -1074,7 +1074,7 @@ field_declaration
          SEMICOLON
          { 
                FullNamedExpression type = (FullNamedExpression) $3;
-               if (type == TypeManager.system_void_expr)
+               if (type.Type == TypeManager.void_type)
                        Report.Error (670, GetLocation ($3), "Fields cannot have void type");
                
                var mod = (Modifiers) $2;
@@ -1351,7 +1351,8 @@ method_header
                GenericMethod generic = null;
                if (name.TypeArguments != null) {
                        generic = new GenericMethod (current_namespace, current_class, name,
-                                                    TypeManager.system_void_expr, current_local_parameters);
+                               new TypeExpression (TypeManager.void_type, GetLocation ($4)),
+                               current_local_parameters);
 
                        generic.SetParameterInfo ((List<Constraints>) $11);
                }
@@ -1375,7 +1376,7 @@ method_header
                
                modifiers |= Modifiers.PARTIAL | Modifiers.PRIVATE;
                
-               method = new Method (current_class, generic, TypeManager.system_void_expr,
+               method = new Method (current_class, generic, new TypeExpression (TypeManager.void_type, GetLocation ($4)),
                                     modifiers, name, current_local_parameters, (Attributes) $1);
 
                if (RootContext.Documentation != null)
@@ -1392,7 +1393,7 @@ method_header
                Report.Error (1585, name.Location, 
                        "Member modifier `{0}' must precede the member type and name", ModifiersExtensions.Name ((Modifiers) $4));
 
-               Method method = new Method (current_class, null, TypeManager.system_void_expr,
+               Method method = new Method (current_class, null, (FullNamedExpression) $3,
                                            0, name, (ParametersCompiled) $7, (Attributes) $1);
 
                current_local_parameters = (ParametersCompiled) $7;
@@ -1711,7 +1712,7 @@ property_declaration
                prop = new Property (current_class, ptype, (Modifiers) $2,
                                     name, (Attributes) $1, get_block, set_block, order, current_block);
 
-               if (ptype == TypeManager.system_void_expr)
+               if (ptype.Type == TypeManager.void_type)
                        Report.Error (547, name.Location, "`{0}': property or indexer cannot have void type", prop.GetSignatureForError ());
                        
                if (accessors == null)
@@ -1967,7 +1968,7 @@ operator_type
        | VOID
          {
                Report.Error (590, GetLocation ($1), "User-defined operators cannot return void");
-               $$ = TypeManager.system_void_expr;              
+               $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1));
          }
        ;
 
@@ -2424,12 +2425,13 @@ indexer_declaration
                Accessor get_block = accessors != null ? accessors.get_or_add : null;
                Accessor set_block = accessors != null ? accessors.set_or_remove : null;
                bool order = accessors != null ? accessors.declared_in_reverse : false;
+               var fne = (FullNamedExpression) $3;
 
-               Indexer indexer = new Indexer (current_class, (FullNamedExpression) $3,
+               Indexer indexer = new Indexer (current_class, fne,
                        (MemberName)$4, (Modifiers) $2, (ParametersCompiled) $7, (Attributes) $1,
                        get_block, set_block, order);
                                       
-               if ($3 == TypeManager.system_void_expr)
+               if (fne.Type == TypeManager.void_type)
                        Report.Error (620, GetLocation ($3), "`{0}': indexer return type cannot be `void'", indexer.GetSignatureForError ());
                        
                if (accessors == null)
@@ -2471,7 +2473,7 @@ enum_declaration
                }
 
                name = MakeName (name);
-               Enum e = new Enum (current_namespace, current_class, (TypeExpr) $5, (Modifiers) $2,
+               Enum e = new Enum (current_namespace, current_class, (TypeExpression) $5, (Modifiers) $2,
                                   name, (Attributes) $1);
                
                if (RootContext.Documentation != null)
@@ -2481,7 +2483,7 @@ enum_declaration
                EnumMember em = null;
                foreach (VariableDeclaration ev in (IList<VariableDeclaration>) $7) {
                        em = new EnumMember (
-                               e, em, ev.identifier, ev.GetInitializer ((FullNamedExpression) $5),
+                               e, em, ev.identifier, ev.GetInitializer (null),
                                ev.OptAttributes, ev.Location);
 
 //                     if (RootContext.Documentation != null)
@@ -2501,25 +2503,24 @@ enum_declaration
 
 opt_enum_base
        : /* empty */
-         {
-               $$ = TypeManager.system_int32_expr;
-         }
        | COLON type
         {
-               if ($2 != TypeManager.system_int32_expr && $2 != TypeManager.system_uint32_expr &&
-                       $2 != TypeManager.system_int64_expr && $2 != TypeManager.system_uint64_expr &&
-                       $2 != TypeManager.system_int16_expr && $2 != TypeManager.system_uint16_expr &&
-                       $2 != TypeManager.system_byte_expr && $2 != TypeManager.system_sbyte_expr) {
+               var te = $2 as TypeExpression;
+               if (te == null ||
+                       (te.Type != TypeManager.int32_type && te.Type != TypeManager.uint32_type &&
+                       te.Type != TypeManager.int64_type && te.Type != TypeManager.uint64_type &&
+                       te.Type != TypeManager.short_type && te.Type != TypeManager.ushort_type &&
+                       te.Type != TypeManager.byte_type && te.Type != TypeManager.sbyte_type)) {
                        Enum.Error_1008 (GetLocation ($2), Report);
-                       $2 = TypeManager.system_int32_expr;
+                       $$ = null;
+               } else {
+                       $$ = $2;
                }
-        
-               $$ = $2;
         }
        | COLON error
         {
                Error_TypeExpected (GetLocation ($1));
-               $$ = TypeManager.system_int32_expr;
+               $$ = null;
         }
        ;
 
@@ -2837,7 +2838,7 @@ type_and_void
        : type_expression_or_array
        | VOID
          {
-               $$ = TypeManager.system_void_expr;
+               $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1));
          }
        ;
        
@@ -2856,7 +2857,7 @@ type
        | VOID
          {
                Expression.Error_VoidInvalidInTheContext (GetLocation ($1), Report);
-               $$ = TypeManager.system_void_expr;
+               $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1));
          }     
        ;
        
@@ -2865,7 +2866,7 @@ simple_type
        | VOID
          {
                Expression.Error_VoidInvalidInTheContext (GetLocation ($1), Report);
-               $$ = TypeManager.system_void_expr;
+               $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1));
          }     
        ;
        
@@ -2874,7 +2875,7 @@ parameter_type
        | VOID
          {
                Report.Error (1536, GetLocation ($1), "Invalid parameter type `void'");
-               $$ = TypeManager.system_void_expr;
+               $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1));
          }     
        ;
 
@@ -2913,11 +2914,11 @@ type_expression
                // can't perform checks during this phase - we do it during
                // semantic analysis.
                //
-               $$ = new ComposedCast ((FullNamedExpression) $1, "*", Lexer.Location);
+               $$ = new ComposedCast ((FullNamedExpression) $1, "*", GetLocation ($2));
          }
        | VOID STAR
          {
-               $$ = new ComposedCast (TypeManager.system_void_expr, "*", GetLocation ($1));
+               $$ = new ComposedCast (new TypeExpression (TypeManager.void_type, GetLocation ($1)), "*", GetLocation ($2));
          }     
        ;
 
@@ -2956,25 +2957,25 @@ base_type_name
  * simple types, but we need this to reuse it easily in variable_type
  */
 builtin_types
-       : OBJECT        { $$ = TypeManager.system_object_expr; }
-       | STRING        { $$ = TypeManager.system_string_expr; }
-       | BOOL          { $$ = TypeManager.system_boolean_expr; }
-       | DECIMAL       { $$ = TypeManager.system_decimal_expr; }
-       | FLOAT         { $$ = TypeManager.system_single_expr; }
-       | DOUBLE        { $$ = TypeManager.system_double_expr; }
+       : OBJECT        { $$ = new TypeExpression (TypeManager.object_type, GetLocation ($1)); }
+       | STRING        { $$ = new TypeExpression (TypeManager.string_type, GetLocation ($1)); }
+       | BOOL          { $$ = new TypeExpression (TypeManager.bool_type, GetLocation ($1)); }
+       | DECIMAL       { $$ = new TypeExpression (TypeManager.decimal_type, GetLocation ($1)); }
+       | FLOAT         { $$ = new TypeExpression (TypeManager.float_type, GetLocation ($1)); }
+       | DOUBLE        { $$ = new TypeExpression (TypeManager.double_type, GetLocation ($1)); }
        | integral_type
        ;
 
 integral_type
-       : SBYTE         { $$ = TypeManager.system_sbyte_expr; }
-       | BYTE          { $$ = TypeManager.system_byte_expr; }
-       | SHORT         { $$ = TypeManager.system_int16_expr; }
-       | USHORT        { $$ = TypeManager.system_uint16_expr; }
-       | INT           { $$ = TypeManager.system_int32_expr; }
-       | UINT          { $$ = TypeManager.system_uint32_expr; }
-       | LONG          { $$ = TypeManager.system_int64_expr; }
-       | ULONG         { $$ = TypeManager.system_uint64_expr; }
-       | CHAR          { $$ = TypeManager.system_char_expr; }
+       : SBYTE         { $$ = new TypeExpression (TypeManager.sbyte_type, GetLocation ($1)); }
+       | BYTE          { $$ = new TypeExpression (TypeManager.byte_type, GetLocation ($1)); }
+       | SHORT         { $$ = new TypeExpression (TypeManager.short_type, GetLocation ($1)); }
+       | USHORT        { $$ = new TypeExpression (TypeManager.ushort_type, GetLocation ($1)); }
+       | INT           { $$ = new TypeExpression (TypeManager.int32_type, GetLocation ($1)); }
+       | UINT          { $$ = new TypeExpression (TypeManager.uint32_type, GetLocation ($1)); }
+       | LONG          { $$ = new TypeExpression (TypeManager.int64_type, GetLocation ($1)); }
+       | ULONG         { $$ = new TypeExpression (TypeManager.uint64_type, GetLocation ($1)); }
+       | CHAR          { $$ = new TypeExpression (TypeManager.char_type, GetLocation ($1)); }
        ;
 
 //
@@ -3303,7 +3304,7 @@ element_access
                        $$ = new ComposedCast ((ATypeNameExpression)expr, (string) $2);
                } else {
                        Error_ExpectingTypeName (expr);
-                       $$ = TypeManager.system_object_expr;
+                       $$ = null;
                }
          }
        ;
@@ -3630,11 +3631,7 @@ typeof_expression
          open_parens_any typeof_type_expression CLOSE_PARENS
          {
                lexer.TypeOfParsing = false;
-               Expression type = (Expression)$4;
-               if (type == TypeManager.system_void_expr)
-                       $$ = new TypeOfVoid (GetLocation ($1));
-               else
-                       $$ = new TypeOf (type, GetLocation ($1));
+               $$ = new TypeOf ((FullNamedExpression) $4, GetLocation ($1));
          }
        ;
        
@@ -4623,7 +4620,7 @@ variable_type
                        }
                } else {
                        Error_ExpectingTypeName (expr);
-                       $$ = TypeManager.system_object_expr;
+                       $$ = null;
                }
          }
        | builtin_types opt_rank_specifier_or_nullable
@@ -4636,7 +4633,7 @@ variable_type
        | VOID opt_rank_specifier
          {
                Expression.Error_VoidInvalidInTheContext (GetLocation ($1), Report);
-               $$ = TypeManager.system_void_expr;
+               $$ = new TypeExpression (TypeManager.void_type, GetLocation ($1));
          }
        ;
 
@@ -4658,11 +4655,11 @@ local_variable_pointer_type
          }
        | VOID STAR
          {
-               $$ = new ComposedCast (TypeManager.system_void_expr, "*", GetLocation ($1));
+               $$ = new ComposedCast (new TypeExpression (TypeManager.void_type, GetLocation ($1)), "*", GetLocation ($2));
          }
        | local_variable_pointer_type STAR
          {
-               $$ = new ComposedCast ((FullNamedExpression) $1, "*");
+               $$ = new ComposedCast ((FullNamedExpression) $1, "*", GetLocation ($2));
          }
        ;
 
@@ -5862,14 +5859,14 @@ interactive_parsing
 
                // (ref object retval)
                Parameter [] mpar = new Parameter [1];
-               mpar [0] = new Parameter (TypeManager.system_object_expr, "$retval", Parameter.Modifier.REF, null, Location.Null);
+               mpar [0] = new Parameter (new TypeExpression (TypeManager.object_type, Location.Null), "$retval", Parameter.Modifier.REF, null, Location.Null);
 
                ParametersCompiled pars = new ParametersCompiled (compiler, mpar);
                current_local_parameters = pars;
                Method method = new Method (
                        current_class,
                        null, // generic
-                       TypeManager.system_void_expr,
+                       new TypeExpression (TypeManager.void_type, Location.Null),
                        Modifiers.PUBLIC | Modifiers.STATIC,
                        new MemberName ("Host"),
                        pars,
index 7c56de66b44b15e70558cb51893d19d36d76f7af..2729fcfe2c9c7ea99bec7a2e173904f4df71bfc0 100644 (file)
@@ -82,12 +82,6 @@ namespace Mono.CSharp {
                        }
                }
 
-               public override TypeSpec BaseType {
-                       get {
-                               return TypeManager.multicast_delegate_type;
-                       }
-               }
-
                protected override bool DoDefineMembers ()
                {
                        var ctor_parameters = ParametersCompiled.CreateFullyResolved (
@@ -293,6 +287,13 @@ namespace Mono.CSharp {
                        base.Emit ();
                }
 
+               protected override TypeExpr[] ResolveBaseTypes (out TypeExpr base_class)
+               {
+                       base_type = TypeManager.multicast_delegate_type;
+                       base_class = null;
+                       return null;
+               }
+
                protected override TypeAttributes TypeAttr {
                        get {
                                return ModifiersExtensions.TypeAttr (ModFlags, IsTopLevel) |
index 2ec21ee01647a1c28bb7747d10f5d4da2915c7bc..2d0d096ed2b75c4072fad47f9de7b4912d0a6035 100644 (file)
@@ -1651,7 +1651,6 @@ namespace Mono.CSharp
                        // TODO: Should be passed to parser as an argument
                        RootContext.ToplevelTypes = new ModuleCompiled (ctx, RootContext.Unsafe);
                        var ctypes = TypeManager.InitCoreTypes ();
-                       TypeManager.InitExpressionTypes ();
 
                        Parse ();
                        if (Report.Errors > 0)
index d323e062d02ce2db1676b70944d5eeffe79a3510..2f399c5a2926f46350ac6461af6a7632c95c79cd 100644 (file)
@@ -126,8 +126,6 @@ namespace Mono.CSharp {
        {
                public static readonly string UnderlyingValueField = "value__";
 
-               TypeExpr base_type;
-
                const Modifiers AllowedModifiers =
                        Modifiers.NEW |
                        Modifiers.PUBLIC |
@@ -135,16 +133,45 @@ namespace Mono.CSharp {
                        Modifiers.INTERNAL |
                        Modifiers.PRIVATE;
 
-               public Enum (NamespaceEntry ns, DeclSpace parent, TypeExpr type,
+               public Enum (NamespaceEntry ns, DeclSpace parent, TypeExpression type,
                             Modifiers mod_flags, MemberName name, Attributes attrs)
                        : base (ns, parent, name, attrs, MemberKind.Enum)
                {
-                       this.base_type = type;
+                       base_type_expr = type;
                        var accmods = IsTopLevel ? Modifiers.INTERNAL : Modifiers.PRIVATE;
                        ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod_flags, accmods, Location, Report);
                        spec = new EnumSpec (null, this, null, null, ModFlags);
                }
 
+               #region Properties
+
+               public override AttributeTargets AttributeTargets {
+                       get {
+                               return AttributeTargets.Enum;
+                       }
+               }
+
+               public TypeExpr BaseTypeExpression {
+                       get {
+                               return base_type_expr;
+                       }
+               }
+
+               protected override TypeAttributes TypeAttr {
+                       get {
+                               return ModifiersExtensions.TypeAttr (ModFlags, IsTopLevel) |
+                                       TypeAttributes.Class | TypeAttributes.Sealed | base.TypeAttr;
+                       }
+               }
+
+               public TypeSpec UnderlyingType {
+                       get {
+                               return ((EnumSpec) spec).UnderlyingType;
+                       }
+               }
+
+               #endregion
+
                public void AddEnumMember (EnumMember em)
                {
                        if (em.Name == UnderlyingValueField) {
@@ -158,16 +185,13 @@ namespace Mono.CSharp {
 
                public static void Error_1008 (Location loc, Report Report)
                {
-                       Report.Error (1008, loc, "Type byte, sbyte, short, ushort, " +
-                                     "int, uint, long or ulong expected");
+                       Report.Error (1008, loc,
+                               "Type byte, sbyte, short, ushort, int, uint, long or ulong expected");
                }
 
                protected override bool DefineNestedTypes ()
                {
-                       if (!base.DefineNestedTypes ())
-                               return false;
-
-                       ((EnumSpec) spec).UnderlyingType = UnderlyingType;
+                       ((EnumSpec) spec).UnderlyingType = base_type_expr == null ? TypeManager.int32_type : base_type_expr.Type;
 
                        TypeBuilder.DefineField (UnderlyingValueField, UnderlyingType.GetMetaInfo (),
                                FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName);
@@ -189,10 +213,11 @@ namespace Mono.CSharp {
                        return true;
                }
 
-               public TypeSpec UnderlyingType {
-                       get {
-                               return base_type.Type;
-                       }
+               protected override TypeExpr[] ResolveBaseTypes (out TypeExpr base_class)
+               {
+                       base_type = TypeManager.enum_type;
+                       base_class = base_type_expr;
+                       return null;
                }
 
                protected override bool VerifyClsCompliance ()
@@ -208,19 +233,6 @@ namespace Mono.CSharp {
 
                        return true;
                }       
-
-               public override AttributeTargets AttributeTargets {
-                       get {
-                               return AttributeTargets.Enum;
-                       }
-               }
-
-               protected override TypeAttributes TypeAttr {
-                       get {
-                               return ModifiersExtensions.TypeAttr (ModFlags, IsTopLevel) |
-                                       TypeAttributes.Class | TypeAttributes.Sealed | base.TypeAttr;
-                       }
-               }
        }
 
        class EnumSpec : TypeSpec
index e9758dade72d6064887ca088cf68ad751652ef87..6782d573a406830981cd1b06a90daff32eae586c 100644 (file)
@@ -128,7 +128,6 @@ namespace Mono.CSharp {
                                CompilerCallableEntryPoint.Reset ();
                                RootContext.ToplevelTypes = new ModuleCompiled (ctx, true);
                                /*var ctypes = */TypeManager.InitCoreTypes ();
-                               TypeManager.InitExpressionTypes ();
 
                                Import.Initialize ();
                                driver.LoadReferences ();
@@ -1188,7 +1187,7 @@ namespace Mono.CSharp {
                                        }
                                        
                                        Arguments args = new Arguments (1);
-                                       args.Add (new Argument (new TypeOf (source, Location)));
+                                       args.Add (new Argument (new TypeOf ((TypeExpr) clone, Location)));
                                        source = new Invocation (new SimpleName ("Describe", Location), args).Resolve (ec);
                                }
                                Evaluator.SetPrinter (old_printer);
index 9ea865f336d84d4a38e4501a2ad291547bfb6fb4..b4653b13f01e7174b0274d60b59780c513352908 100644 (file)
@@ -6721,15 +6721,30 @@ namespace Mono.CSharp {
        ///   Implements the typeof operator
        /// </summary>
        public class TypeOf : Expression {
-               Expression QueriedType;
-               protected TypeSpec typearg;
+               FullNamedExpression QueriedType;
+               TypeSpec typearg;
 
-               public TypeOf (Expression queried_type, Location l)
+               public TypeOf (FullNamedExpression queried_type, Location l)
                {
                        QueriedType = queried_type;
                        loc = l;
                }
 
+               #region Properties
+               public TypeSpec TypeArgument {
+                       get {
+                               return typearg;
+                       }
+               }
+
+               public FullNamedExpression TypeExpression {
+                       get {
+                               return QueriedType;
+                       }
+               }
+
+               #endregion
+
                public override Expression CreateExpressionTree (ResolveContext ec)
                {
                        Arguments args = new Arguments (2);
@@ -6753,7 +6768,7 @@ namespace Mono.CSharp {
                        if (tne != null && typearg.IsGeneric && !tne.HasTypeArguments)
                                typearg = typearg.GetDefinition ();
 
-                       if (typearg == TypeManager.void_type) {
+                       if (typearg == TypeManager.void_type && !(QueriedType is TypeExpression)) {
                                ec.Report.Error (673, loc, "System.Void cannot be used from C#. Use typeof (void) to get the void type object");
                        } else if (typearg.IsPointer && !ec.IsUnsafe){
                                UnsafeError (ec, loc);
@@ -6817,35 +6832,11 @@ namespace Mono.CSharp {
                        ec.Emit (OpCodes.Call, TypeManager.system_type_get_type_from_handle);
                }
 
-               public TypeSpec TypeArgument {
-                       get {
-                               return typearg;
-                       }
-               }
-
                protected override void CloneTo (CloneContext clonectx, Expression t)
                {
                        TypeOf target = (TypeOf) t;
                        if (QueriedType != null)
-                               target.QueriedType = QueriedType.Clone (clonectx);
-               }
-       }
-
-       /// <summary>
-       ///   Implements the `typeof (void)' operator
-       /// </summary>
-       public class TypeOfVoid : TypeOf {
-               public TypeOfVoid (Location l) : base (null, l)
-               {
-                       loc = l;
-               }
-
-               protected override Expression DoResolve (ResolveContext ec)
-               {
-                       type = TypeManager.type_type;
-                       typearg = TypeManager.void_type;
-
-                       return DoResolveBase ();
+                               target.QueriedType = (FullNamedExpression) QueriedType.Clone (clonectx);
                }
        }
 
index cbf983c856f35415037a809edd3143a6dcc8a7ee..11b096e208dc5edd786026a20b3cb31462922507 100644 (file)
@@ -319,7 +319,7 @@ namespace Mono.CSharp {
                        }
 
                        public DisposeMethod (IteratorStorey host)
-                               : base (host, TypeManager.system_void_expr, Modifiers.PUBLIC, new MemberName ("Dispose", host.Location))
+                               : base (host, new TypeExpression (TypeManager.void_type, host.Location), Modifiers.PUBLIC, new MemberName ("Dispose", host.Location))
                        {
                                host.AddMethod (this);
 
@@ -458,7 +458,7 @@ namespace Mono.CSharp {
 
                void DefineIteratorMembers ()
                {
-                       pc_field = AddCompilerGeneratedField ("$PC", TypeManager.system_int32_expr);
+                       pc_field = AddCompilerGeneratedField ("$PC", new TypeExpression (TypeManager.int32_type, Location));
                        current_field = AddCompilerGeneratedField ("$current", iterator_type_expr);
 
                        if (hoisted_params != null) {
@@ -529,7 +529,7 @@ namespace Mono.CSharp {
                                type = iterator_type_expr;
                        } else {
                                name = new MemberName (name, "IEnumerator");
-                               type = TypeManager.system_object_expr;
+                               type = new TypeExpression (TypeManager.object_type, Location);
                        }
 
                        name = new MemberName (name, "Current", Location);
@@ -547,7 +547,7 @@ namespace Mono.CSharp {
                void Define_Reset ()
                {
                        Method reset = new Method (
-                               this, null, TypeManager.system_void_expr,
+                               this, null, new TypeExpression (TypeManager.void_type, Location),
                                Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
                                new MemberName ("Reset", Location),
                                ParametersCompiled.EmptyReadOnlyParameters, null);
@@ -815,7 +815,7 @@ namespace Mono.CSharp {
                protected override Expression DoResolve (ResolveContext ec)
                {
                        method = new AnonymousMethodMethod (Storey,
-                               this, Storey, null, TypeManager.system_boolean_expr,
+                               this, Storey, null, new TypeExpression (TypeManager.bool_type, loc),
                                Modifiers.PUBLIC, OriginalMethod.GetSignatureForError (),
                                new MemberName ("MoveNext", Location),
                                ParametersCompiled.EmptyReadOnlyParameters);
index 2b92e4260b3140c4d1add641f97c5f5b42cd1ef1..7da5949969da8de0627c4894e49ccddca1b5cacd 100644 (file)
@@ -1001,7 +1001,7 @@ namespace Mono.CSharp {
                //
                public override bool Define ()
                {
-                       if (type_expr == TypeManager.system_void_expr && parameters.IsEmpty && Name == Destructor.MetadataName) {
+                       if (type_expr.Type == TypeManager.void_type && parameters.IsEmpty && MemberName.Arity == 0 && MemberName.Name == Destructor.MetadataName) {
                                Report.Warning (465, 1, Location, "Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?");
                        }
 
@@ -1930,7 +1930,7 @@ namespace Mono.CSharp {
                public static readonly string MetadataName = "Finalize";
 
                public Destructor (DeclSpace parent, Modifiers mod, ParametersCompiled parameters, Attributes attrs, Location l)
-                       : base (parent, null, TypeManager.system_void_expr, mod, AllowedModifiers,
+                       : base (parent, null, null, mod, AllowedModifiers,
                                new MemberName (MetadataName, l), attrs, parameters)
                {
                        ModFlags &= ~Modifiers.PRIVATE;
@@ -1949,13 +1949,14 @@ namespace Mono.CSharp {
 
                protected override bool CheckBase ()
                {
-                       // Don't check base, the destructor has special syntax
+                       // Don't check base, destructors have special syntax
+                       return true;
+               }
 
+               public override void  Emit()
+               {
                        var base_type = Parent.PartialContainer.BaseType;
-                       if (base_type == null)
-                               return true;
-
-                       if (Block != null) {
+                       if (base_type != null && Block != null) {
                                MethodGroupExpr method_expr = Expression.MethodLookup (Parent.Module.Compiler, Parent.Definition, base_type, MemberKind.Destructor, MetadataName, 0, Location);
                                if (method_expr == null)
                                        throw new NotImplementedException ();
@@ -1980,7 +1981,7 @@ namespace Mono.CSharp {
                                block = new_block;
                        }
 
-                       return true;
+                       base.Emit ();
                }
 
                public override string GetSignatureForError ()
@@ -1988,6 +1989,12 @@ namespace Mono.CSharp {
                        return Parent.GetSignatureForError () + ".~" + Parent.MemberName.Name + "()";
                }
 
+               protected override bool ResolveMemberType ()
+               {
+                       member_type = TypeManager.void_type;
+                       return true;
+               }
+
                public override string[] ValidAttributeTargets {
                        get {
                                return attribute_targets;
index a41f4d742e095353d0fe94942cece224fde4cf67..87d14482b6a8953c894f79a08e11501bc538ce28 100644 (file)
@@ -98,19 +98,6 @@ namespace Mono.CSharp {
        public static TypeExpr binder_type;
        public static TypeSpec binder_flags;
 
-       // 
-       // Expressions representing the internal types.  Used during declaration
-       // definition.
-       //
-       static public TypeExpr system_object_expr, system_string_expr; 
-       static public TypeExpr system_boolean_expr, system_decimal_expr;
-       static public TypeExpr system_single_expr, system_double_expr;
-       static public TypeExpr system_sbyte_expr, system_byte_expr;
-       static public TypeExpr system_int16_expr, system_uint16_expr;
-       static public TypeExpr system_int32_expr, system_uint32_expr;
-       static public TypeExpr system_int64_expr, system_uint64_expr;
-       static public TypeExpr system_char_expr, system_void_expr;
-       static public TypeExpr system_valuetype_expr;
        public static TypeExpr expression_type_expr;
 
 
@@ -144,31 +131,6 @@ namespace Mono.CSharp {
 
        static Dictionary<Assembly, bool> assembly_internals_vis_attrs;
 
-       //
-       // These are expressions that represent some of the internal data types, used
-       // elsewhere
-       //
-       public static void InitExpressionTypes ()
-       {
-               system_object_expr  = new TypeLookupExpression (object_type);
-               system_string_expr  = new TypeLookupExpression (string_type);
-               system_boolean_expr = new TypeLookupExpression (bool_type);
-               system_decimal_expr = new TypeLookupExpression (decimal_type);
-               system_single_expr  = new TypeLookupExpression (float_type);
-               system_double_expr  = new TypeLookupExpression (double_type);
-               system_sbyte_expr   = new TypeLookupExpression (sbyte_type);
-               system_byte_expr    = new TypeLookupExpression (byte_type);
-               system_int16_expr   = new TypeLookupExpression (short_type);
-               system_uint16_expr  = new TypeLookupExpression (ushort_type);
-               system_int32_expr   = new TypeLookupExpression (int32_type);
-               system_uint32_expr  = new TypeLookupExpression (uint32_type);
-               system_int64_expr   = new TypeLookupExpression (int64_type);
-               system_uint64_expr  = new TypeLookupExpression (uint64_type);
-               system_char_expr    = new TypeLookupExpression (char_type);
-               system_void_expr    = new TypeLookupExpression (void_type);
-               system_valuetype_expr  = new TypeLookupExpression (value_type);
-       }
-
        static TypeManager ()
        {
                Reset ();
index 532f942af7bd48d8f1ab305a9562a6aeb1315589..8fe27838c63cc28f8642f659c7624a405ee54446 100644 (file)
@@ -278,11 +278,6 @@ namespace Mono.CSharp
                        return null;
                }
 
-               public virtual object Visit (TypeLookupExpression typeLookupExpression)
-               {
-                       return null;
-               }
-
                public virtual object Visit (LocalVariableReference localVariableReference)
                {
                        return null;