**** Merged r56802 from MCS ****
authorMarek Safar <marek.safar@gmail.com>
Wed, 22 Mar 2006 20:38:04 +0000 (20:38 -0000)
committerMarek Safar <marek.safar@gmail.com>
Wed, 22 Mar 2006 20:38:04 +0000 (20:38 -0000)
svn path=/trunk/mcs/; revision=58319

mcs/gmcs/ChangeLog
mcs/gmcs/class.cs
mcs/gmcs/const.cs
mcs/gmcs/decl.cs
mcs/gmcs/delegate.cs
mcs/gmcs/expression.cs
mcs/gmcs/generic.cs
mcs/gmcs/iterators.cs
mcs/gmcs/tree.cs

index ddbdb26d11a2a631c9b6ad59ece095457e9c7f59..6a0c13e513c8886bcf3115671c1e1cce0fb88f71 100644 (file)
        (ConstraintChecker.CheckConstraints): If a type parameter has the
        `struct' constraint, the type must be a non-nullable valuetype.
 
+2006-02-11  Marek Safar  <marek.safar@seznam.cz>
+
+       First of prerequisites for new partial classs implemention.
+       
+       * attribute.cs (Attributable): Extended by ResolveContext;
+       Attributes finally have correct context for resolving in all cases.
+       (AttachTo): Attribute owner is assigned here.
+
+       * codegen.cs (IResolveContext): Introduce new interface to hold
+       all information needed in resolving phase.
+       (EmitContext): Implements IResolveContext; more clean-up needed here.
+       
+       * decl.cs (MemberCore): Implemented IResolveContext.
+
+       * anonymous.cs, attribute.cs, class.cs, codegen.cs, const.cs,
+       decl.cs, ecore.cs, enum.cs, expression.cs, iterators.cs, namespace.cs,
+       parameter.cs, statement.cs, tree.cs, typemanager.cs:
+       Refactored to use new IResolveContext instead of EmitContext; cleanup
+
 2006-02-10  Martin Baulig  <martin@ximian.com>
 
        * typemanager.cs
index 09a3eb1c71feda2cd33f4ff9410bdb46fa85d210..e59ab5c3c7328ebfe55c62559787c95f21d03b6f 100644 (file)
@@ -1233,21 +1233,9 @@ namespace Mono.CSharp {
                        TypeManager.AddUserType (this);
 
                        if (Parts != null) {
-                               ec = null;
                                foreach (ClassPart part in Parts) {
                                        part.TypeBuilder = TypeBuilder;
-                                       part.ec = new EmitContext (this, part, Mono.CSharp.Location.Null, null, null, ModFlags);
-                                       part.ec.ContainerType = TypeBuilder;
                                }
-                       } else {
-                               //
-                               // Normally, we create the EmitContext here.
-                               // The only exception is if we're an Iterator - in this case,
-                               // we already have the `ec', so we don't want to create a new one.
-                               //
-                               if (ec == null)
-                                       ec = new EmitContext (this, this, Mono.CSharp.Location.Null, null, null, ModFlags);
-                               ec.ContainerType = TypeBuilder;
                        }
 
                        if (IsGeneric) {
@@ -1394,7 +1382,7 @@ namespace Mono.CSharp {
                                }
 
                                foreach (TypeParameter type_param in TypeParameters) {
-                                       if (!type_param.DefineType (ec)) {
+                                       if (!type_param.DefineType (this)) {
                                                error = true;
                                                return false;
                                        }
@@ -1405,19 +1393,19 @@ namespace Mono.CSharp {
                        }
 
                        foreach (TypeParameter type_param in TypeParameters)
-                               if (!type_param.CheckDependencies (ec)) {
+                               if (!type_param.CheckDependencies ()) {
                                        error = true;
                                        return false;
                                }
 
                        if (current_type != null) {
-                               current_type = current_type.ResolveAsTypeTerminal (ec, false);
+                               current_type = current_type.ResolveAsTypeTerminal (this, false);
                                if (current_type == null) {
                                        error = true;
                                        return false;
                                }
 
-                               CurrentType = current_type.ResolveType (ec);
+                               CurrentType = current_type.ResolveType (this);
                        }
 
                        return true;
@@ -1521,14 +1509,14 @@ namespace Mono.CSharp {
                        if (iface_exprs != null) {
                                foreach (TypeExpr iface in iface_exprs) {
                                        ConstructedType ct = iface as ConstructedType;
-                                       if ((ct != null) && !ct.CheckConstraints (ec))
+                                       if ((ct != null) && !ct.CheckConstraints (this))
                                                return false;
                                }
                        }
 
                        if (base_type != null) {
                                ConstructedType ct = base_type as ConstructedType;
-                               if ((ct != null) && !ct.CheckConstraints (ec))
+                               if ((ct != null) && !ct.CheckConstraints (this))
                                        return false;
                        }
 
@@ -1601,8 +1589,6 @@ namespace Mono.CSharp {
 
                        if (CurrentType != null) {
                                GenericType = CurrentType;
-
-                               ec.ContainerType = GenericType;
                        }
 
 
@@ -2415,7 +2401,6 @@ namespace Mono.CSharp {
                        indexers = null;
                        operators = null;
                        iterators = null;
-                       ec = null;
                        default_constructor = null;
                        default_static_constructor = null;
                        type_bases = null;
@@ -2942,7 +2927,7 @@ namespace Mono.CSharp {
                                if (new_constraints == null)
                                        continue;
 
-                               if (!current_params [i].UpdateConstraints (ec, new_constraints)) {
+                               if (!current_params [i].UpdateConstraints (this, new_constraints)) {
                                        Report.Error (265, Location, "Partial declarations of `{0}' have " +
                                                      "inconsistent constraints for type parameter `{1}'.",
                                                      MemberName.GetTypeName (), current_params [i].Name);
@@ -2956,7 +2941,7 @@ namespace Mono.CSharp {
                        }
 
                        foreach (TypeParameter type_param in PartialContainer.TypeParameters) {
-                               if (!type_param.DefineType (ec))
+                               if (!type_param.DefineType (this))
                                        return false;
                        }
 
index 7bff36905e80a31ceccbc4cbbab5faf39d181389..5f90e75170debe3e622a6726083324db477172e6 100644 (file)
@@ -135,6 +135,7 @@ namespace Mono.CSharp {
                        }
 
                        in_transit = true;
+                       // TODO: IResolveContext here
                        EmitContext ec = new EmitContext (this, Parent, Location, null, MemberType, ModFlags);
                        value = initializer.ResolveAsConstant (ec, this);
                        in_transit = false;
index 5dc819eb952896725d516c4361c0007c0531f3ce..4a047de8ad442b427a0ca9cc634c0936f06e9d71 100644 (file)
@@ -674,9 +674,6 @@ namespace Mono.CSharp {
                readonly int count_type_params;
                readonly int count_current_type_params;
 
-               // The emit context for toplevel objects.
-               protected EmitContext ec;
-               
                //
                // Whether we are Generic
                //
index 1eb4ff8b3193dceb249ca3c9602f23b780aeaf27..284b1da98d7cb49e608ed8639e4bbc6ed6d775f5 100644 (file)
@@ -78,8 +78,6 @@ namespace Mono.CSharp {
                        if (TypeBuilder != null)
                                return TypeBuilder;
 
-                       ec = new EmitContext (this, this, this, Location, null, null, ModFlags, false);
-
                        if (IsGeneric) {
                                foreach (TypeParameter type_param in TypeParameters)
                                        if (!type_param.Resolve (this))
@@ -89,7 +87,7 @@ namespace Mono.CSharp {
                        if (TypeManager.multicast_delegate_type == null && !RootContext.StdLib) {
                                Namespace system = RootNamespace.Global.GetNamespace ("System", true);
                                TypeExpr expr = system.Lookup (this, "MulticastDelegate", Location) as TypeExpr;
-                               TypeManager.multicast_delegate_type = expr.ResolveType (ec);
+                               TypeManager.multicast_delegate_type = expr.ResolveType (this);
                        }
 
                        if (TypeManager.multicast_delegate_type == null)
@@ -135,7 +133,7 @@ namespace Mono.CSharp {
 
                                Expression current = new SimpleName (
                                        MemberName.Basename, TypeParameters, Location);
-                               current = current.ResolveAsTypeTerminal (ec, false);
+                               current = current.ResolveAsTypeTerminal (this, false);
                                if (current == null)
                                        return null;
 
@@ -152,12 +150,9 @@ namespace Mono.CSharp {
 
                        if (IsGeneric) {
                                foreach (TypeParameter type_param in TypeParameters)
-                                       type_param.DefineType (ec);
+                                       type_param.DefineType (this);
                        }
 
-                       if (ec == null)
-                               throw new InternalErrorException ("Define called before DefineType?");
-
                        // FIXME: POSSIBLY make this static, as it is always constant
                        //
                        Type [] const_arg_types = new Type [2];
@@ -195,7 +190,7 @@ namespace Mono.CSharp {
                        // First, call the `out of band' special method for
                        // defining recursively any types we need:
                        
-                       if (!Parameters.Resolve (ec))
+                       if (!Parameters.Resolve (this))
                                return false;
 
                        //
@@ -213,7 +208,7 @@ namespace Mono.CSharp {
                                }
                        }
                        
-                       ReturnType = ReturnType.ResolveAsTypeTerminal (ec, false);
+                       ReturnType = ReturnType.ResolveAsTypeTerminal (this, false);
                        if (ReturnType == null)
                                return false;
                         
@@ -302,7 +297,7 @@ namespace Mono.CSharp {
                                                                   Parameter.Modifier.NONE, null, Location);
 
                        Parameters async_parameters = new Parameters (async_params);
-                       async_parameters.Resolve (ec);
+                       async_parameters.Resolve (this);
                        async_parameters.ApplyAttributes (BeginInvokeBuilder);
 
                        TypeManager.RegisterMethod (BeginInvokeBuilder, async_parameters);
@@ -345,7 +340,7 @@ namespace Mono.CSharp {
                        }
 
                        Parameters end_parameters = new Parameters (end_params);
-                       end_parameters.Resolve (ec);
+                       end_parameters.Resolve (this);
 
                        TypeManager.RegisterMethod (EndInvokeBuilder, end_parameters);
 
index d8e82d247fd39c1c920f4507d0b6d17400ff9d0c..3a510c725d0c2c9ef9d8fe32356ea63ffbde1967 100644 (file)
@@ -7460,9 +7460,9 @@ namespace Mono.CSharp {
                        return ResolveNamespaceOrType (ec, silent);
                }
 
-               public FullNamedExpression ResolveNamespaceOrType (IResolveContext ec, bool silent)
+               public FullNamedExpression ResolveNamespaceOrType (IResolveContext rc, bool silent)
                {
-                       FullNamedExpression new_expr = expr.ResolveAsTypeStep (ec, silent);
+                       FullNamedExpression new_expr = expr.ResolveAsTypeStep (rc, silent);
 
                        if (new_expr == null)
                                return null;
@@ -7471,20 +7471,20 @@ namespace Mono.CSharp {
 
                        if (new_expr is Namespace) {
                                Namespace ns = (Namespace) new_expr;
-                               FullNamedExpression retval = ns.Lookup (ec.DeclContainer, lookup_id, loc);
+                               FullNamedExpression retval = ns.Lookup (rc.DeclContainer, lookup_id, loc);
                                if ((retval != null) && (args != null))
-                                       retval = new ConstructedType (retval, args, loc).ResolveAsTypeStep (ec, false);
+                                       retval = new ConstructedType (retval, args, loc).ResolveAsTypeStep (rc, false);
                                if (!silent && retval == null)
                                        Report.Error (234, loc, "The type or namespace name `{0}' does not exist in the namespace `{1}'. Are you missing an assembly reference?",
                                                Identifier, ns.FullName);
                                return retval;
                        }
 
-                       TypeExpr tnew_expr = new_expr.ResolveAsTypeTerminal (ec, false);
+                       TypeExpr tnew_expr = new_expr.ResolveAsTypeTerminal (rc, false);
                        if (tnew_expr == null)
                                return null;
 
-                       Type expr_type = tnew_expr.ResolveType (ec);
+                       Type expr_type = tnew_expr.ResolveType (rc);
 
                        if (expr_type.IsPointer){
                                Error (23, "The `.' operator can not be applied to pointer operands (" +
@@ -7493,11 +7493,11 @@ namespace Mono.CSharp {
                        }
 
                        Expression member_lookup = MemberLookup (
-                               ec.DeclContainer.TypeBuilder, expr_type, expr_type, lookup_id,
+                               rc.DeclContainer.TypeBuilder, expr_type, expr_type, lookup_id,
                                MemberTypes.NestedType, BindingFlags.Public | BindingFlags.NonPublic, loc);
                        if (member_lookup == null) {
                                int errors = Report.Errors;
-                               MemberLookupFailed (ec.DeclContainer.TypeBuilder, expr_type, expr_type, lookup_id, null, false, loc);
+                               MemberLookupFailed (rc.DeclContainer.TypeBuilder, expr_type, expr_type, lookup_id, null, false, loc);
 
                                if (!silent && errors == Report.Errors) {
                                        Report.Error (426, loc, "The nested type `{0}' does not exist in the type `{1}'",
@@ -7507,11 +7507,11 @@ namespace Mono.CSharp {
                        }
 
                        if (!(member_lookup is TypeExpr)) {
-                               new_expr.Error_UnexpectedKind (ec.DeclContainer, "type", loc);
+                               new_expr.Error_UnexpectedKind (rc.DeclContainer, "type", loc);
                                return null;
                        }
 
-                       TypeExpr texpr = member_lookup.ResolveAsTypeTerminal (ec, false);
+                       TypeExpr texpr = member_lookup.ResolveAsTypeTerminal (rc, false);
                        if (texpr == null)
                                return null;
 
@@ -7531,7 +7531,7 @@ namespace Mono.CSharp {
 
                        if (the_args != null) {
                                ConstructedType ctype = new ConstructedType (texpr.Type, the_args, loc);
-                               return ctype.ResolveAsTypeStep (ec, false);
+                               return ctype.ResolveAsTypeStep (rc, false);
                        }
 
                        return texpr;
index 9b53ff9c90d51275a78ecc141f7f59f71f4f678d..0e18f4b4b0867e0a1a608c03ee1cfae8caf4a138 100644 (file)
@@ -368,7 +368,7 @@ namespace Mono.CSharp {
                /// <summary>
                ///   Resolve the constraints into actual types.
                /// </summary>
-               public bool ResolveTypes (EmitContext ec)
+               public bool ResolveTypes (IResolveContext ec)
                {
                        if (resolved_types)
                                return true;
@@ -412,17 +412,17 @@ namespace Mono.CSharp {
                ///      where T : class
                ///      where U : T, struct
                /// </summary>
-               public bool CheckDependencies (EmitContext ec)
+               public bool CheckDependencies ()
                {
                        foreach (TypeParameterExpr expr in type_param_constraints) {
-                               if (!CheckDependencies (expr.TypeParameter, ec))
+                               if (!CheckDependencies (expr.TypeParameter))
                                        return false;
                        }
 
                        return true;
                }
 
-               bool CheckDependencies (TypeParameter tparam, EmitContext ec)
+               bool CheckDependencies (TypeParameter tparam)
                {
                        Constraints constraints = tparam.Constraints;
                        if (constraints == null)
@@ -456,7 +456,7 @@ namespace Mono.CSharp {
                                return true;
 
                        foreach (TypeParameterExpr expr in constraints.type_param_constraints) {
-                               if (!CheckDependencies (expr.TypeParameter, ec))
+                               if (!CheckDependencies (expr.TypeParameter))
                                        return false;
                        }
 
@@ -507,7 +507,7 @@ namespace Mono.CSharp {
                ///   method.  To do that, we're called on each of the implementing method's
                ///   type parameters.
                /// </summary>
-               public bool CheckInterfaceMethod (EmitContext ec, GenericConstraints gc)
+               public bool CheckInterfaceMethod (GenericConstraints gc)
                {
                        if (gc.Attributes != attrs)
                                return false;
@@ -649,7 +649,7 @@ namespace Mono.CSharp {
                ///   Note that we may have circular dependencies on type parameters - this
                ///   is why Resolve() and ResolveType() are separate.
                /// </summary>
-               public bool ResolveType (EmitContext ec)
+               public bool ResolveType (IResolveContext ec)
                {
                        if (constraints != null) {
                                if (!constraints.ResolveTypes (ec)) {
@@ -666,7 +666,7 @@ namespace Mono.CSharp {
                ///   process.  We're called after everything is fully resolved and actually
                ///   register the constraints with SRE and the TypeManager.
                /// </summary>
-               public bool DefineType (EmitContext ec)
+               public bool DefineType (IResolveContext ec)
                {
                        return DefineType (ec, null, null, false);
                }
@@ -679,7 +679,7 @@ namespace Mono.CSharp {
                ///   The `builder', `implementing' and `is_override' arguments are only
                ///   applicable to method type parameters.
                /// </summary>
-               public bool DefineType (EmitContext ec, MethodBuilder builder,
+               public bool DefineType (IResolveContext ec, MethodBuilder builder,
                                        MethodInfo implementing, bool is_override)
                {
                        if (!ResolveType (ec))
@@ -710,7 +710,7 @@ namespace Mono.CSharp {
                                if (constraints != null) {
                                        if (temp_gc == null)
                                                ok = false;
-                                       else if (!constraints.CheckInterfaceMethod (ec, gc))
+                                       else if (!constraints.CheckInterfaceMethod (gc))
                                                ok = false;
                                } else {
                                        if (!is_override && (temp_gc != null))
@@ -764,10 +764,10 @@ namespace Mono.CSharp {
                ///      where T : class
                ///      where U : T, struct
                /// </summary>
-               public bool CheckDependencies (EmitContext ec)
+               public bool CheckDependencies ()
                {
                        if (constraints != null)
-                               return constraints.CheckDependencies (ec);
+                               return constraints.CheckDependencies ();
 
                        return true;
                }
@@ -780,7 +780,7 @@ namespace Mono.CSharp {
                ///   check that they're the same.
                ///   con
                /// </summary>
-               public bool UpdateConstraints (EmitContext ec, Constraints new_constraints)
+               public bool UpdateConstraints (IResolveContext ec, Constraints new_constraints)
                {
                        if (type == null)
                                throw new InvalidOperationException ();
@@ -796,7 +796,7 @@ namespace Mono.CSharp {
                        if (!new_constraints.ResolveTypes (ec))
                                return false;
 
-                       return constraints.CheckInterfaceMethod (ec, new_constraints);
+                       return constraints.CheckInterfaceMethod (new_constraints);
                }
 
                public void EmitAttributes ()
@@ -1750,8 +1750,6 @@ namespace Mono.CSharp {
 
                public override bool Define ()
                {
-                       ec = new EmitContext (this, this, this, Location, null, null, ModFlags, false);
-
                        for (int i = 0; i < TypeParameters.Length; i++)
                                if (!TypeParameters [i].Resolve (this))
                                        return false;
@@ -1778,7 +1776,7 @@ namespace Mono.CSharp {
                                return false;
 
                        for (int i = 0; i < TypeParameters.Length; i++) {
-                               if (!TypeParameters [i].ResolveType (ec))
+                               if (!TypeParameters [i].ResolveType (this))
                                        return false;
                        }
 
index 729017a3bc280e1067ddf700c842976f17a5d73f..4e19463512ec2d0e39789a38d6f765c9a67720f5 100644 (file)
@@ -156,6 +156,7 @@ namespace Mono.CSharp {
                Expression generic_enumerator_type;
                Expression generic_enumerable_type;
                TypeArguments generic_args;
+               EmitContext ec;
 
                protected enum State {
                        Uninitialized   = -2,
index c66f17a9979bfd2e2e462d4df4bacd9c7d1c6f3c..cb2ab7f61de9de3af2bd462e4cc41d757cc53a9c 100644 (file)
@@ -76,7 +76,6 @@ namespace Mono.CSharp
                public RootTypes ()
                        : base (null, null, MemberName.Null, null, Kind.Root)
                {
-                       ec = new EmitContext (this, null, this, Location.Null, null, null, 0, false);
                }
 
                public override PendingImplementation GetPendingImplementations ()