* ILTokenizer.cs: Handle comments first, handle whitespace in hex
[mono.git] / mcs / mcs / expression.cs
index 0a0540d93fd3d846e3151600494390ff3dd9163e..7a743fb03f80cd8aa004e172b89d30f57d69d6c7 100755 (executable)
@@ -5252,16 +5252,14 @@ namespace Mono.CSharp {
                        if (oa != null)
                                AttributeTester.Report_ObsoleteMessage (oa, TypeManager.CSharpSignature (method), loc);
 
+
                        oa = AttributeTester.GetObsoleteAttribute (method.DeclaringType);
                        if (oa != null) {
                                AttributeTester.Report_ObsoleteMessage (oa, method.DeclaringType.FullName, loc);
                        }
 
-                       //
-                       // This checks the `ConditionalAttribute' on the method
-                       //
-                        if (IsMethodExcluded (method, ec))
-                               return;                        
+                       if (IsMethodExcluded (method, ec))
+                return; 
                        
                        if (!is_static){
                                if (decl_type.IsValueType)
@@ -5586,7 +5584,8 @@ namespace Mono.CSharp {
                                return this;
                        
                        Expression ml;
-                       ml = MemberLookupFinal (ec, null, type, ".ctor",
+                       // For member-lookup, treat 'new Foo (bar)' as call to 'foo.ctor (bar)', where 'foo' is of type 'Foo'.
+                       ml = MemberLookupFinal (ec, type, type, ".ctor",
                                                MemberTypes.Constructor,
                                                AllBindingFlags | BindingFlags.DeclaredOnly, loc);
 
@@ -5735,7 +5734,7 @@ namespace Mono.CSharp {
        ///   initialization data and the other which does not need dimensions
        ///   specified but where initialization data is mandatory.
        /// </remarks>
-       public class ArrayCreation : ExpressionStatement {
+       public class ArrayCreation : Expression {
                Expression requested_base_type;
                ArrayList initializers;
 
@@ -6298,7 +6297,7 @@ namespace Mono.CSharp {
                //
                // Emits the initializers for the array
                //
-               void EmitStaticInitializers (EmitContext ec, bool is_expression)
+               void EmitStaticInitializers (EmitContext ec)
                {
                        //
                        // First, the static data
@@ -6310,8 +6309,7 @@ namespace Mono.CSharp {
 
                        fb = RootContext.MakeStaticData (data);
 
-                       if (is_expression)
-                               ig.Emit (OpCodes.Dup);
+                       ig.Emit (OpCodes.Dup);
                        ig.Emit (OpCodes.Ldtoken, fb);
                        ig.Emit (OpCodes.Call,
                                 TypeManager.void_initializearray_array_fieldhandle);
@@ -6323,7 +6321,7 @@ namespace Mono.CSharp {
                //
                // This always expect the top value on the stack to be the array
                //
-               void EmitDynamicInitializers (EmitContext ec, bool is_expression)
+               void EmitDynamicInitializers (EmitContext ec)
                {
                        ILGenerator ig = ec.ig;
                        int dims = bounds.Count;
@@ -6370,8 +6368,7 @@ namespace Mono.CSharp {
                                            num_automatic_initializers <= max_automatic_initializers) {
                                                Type etype = e.Type;
                                                
-                                               if (is_expression || i != top - 1)
-                                                       ig.Emit (OpCodes.Dup);
+                                               ig.Emit (OpCodes.Dup);
 
                                                for (int idx = 0; idx < dims; idx++) 
                                                        IntConstant.EmitInt (ig, current_pos [idx]);
@@ -6434,7 +6431,7 @@ namespace Mono.CSharp {
                        }
                }
                
-               void DoEmit (EmitContext ec, bool is_statement)
+               public override void Emit (EmitContext ec)
                {
                        ILGenerator ig = ec.ig;
                        
@@ -6458,22 +6455,12 @@ namespace Mono.CSharp {
                                // initialized. num_automatic_initializers will always be zero.  See
                                // CheckIndices.
                                if (num_automatic_initializers > max_automatic_initializers)
-                                       EmitStaticInitializers (ec, dynamic_initializers || !is_statement);
+                                       EmitStaticInitializers (ec);
                                
                                if (dynamic_initializers)
-                                       EmitDynamicInitializers (ec, !is_statement);
+                                       EmitDynamicInitializers (ec);
                        }
                }
-               
-               public override void Emit (EmitContext ec)
-               {
-                       DoEmit (ec, false);
-               }
-
-               public override void EmitStatement (EmitContext ec)
-               {
-                       DoEmit (ec, true);
-               }
 
                public object EncodeAsAttribute ()
                {
@@ -7769,7 +7756,7 @@ namespace Mono.CSharp {
                        MemberInfo [] mi = TypeManager.MemberLookup (
                                caller_type, caller_type, lookup_type, MemberTypes.Property,
                                BindingFlags.Public | BindingFlags.Instance |
-                               BindingFlags.DeclaredOnly, p_name);
+                               BindingFlags.DeclaredOnly, p_name, null);
 
                        if (mi == null || mi.Length == 0)
                                return null;