Don't emit reaonly. prefix for reference loads
[mono.git] / mcs / mcs / flowanalysis.cs
index e37738069ddb29e22706da4ad3bc6eebc02dc755..d864dc875e9ae6eadda6cf6eec676bf65b5483d1 100644 (file)
@@ -12,9 +12,6 @@
 using System;
 using System.Text;
 using System.Collections.Generic;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Diagnostics;
 
 namespace Mono.CSharp
 {
@@ -639,8 +636,9 @@ namespace Mono.CSharp
 
        public class FlowBranchingIterator : FlowBranchingBlock
        {
-               Iterator iterator;
-               public FlowBranchingIterator (FlowBranching parent, Iterator iterator)
+               readonly StateMachineInitializer iterator;
+
+               public FlowBranchingIterator (FlowBranching parent, StateMachineInitializer iterator)
                        : base (parent, BranchingType.Iterator, SiblingType.Block, iterator.Block, iterator.Location)
                {
                        this.iterator = iterator;
@@ -1069,17 +1067,6 @@ namespace Mono.CSharp
                        return info;
                }
 
-               public static TypeInfo GetTypeInfo (TypeContainer tc)
-               {
-                       TypeInfo info;
-                       if (type_hash.TryGetValue (tc.Definition, out info))
-                               return info;
-
-                       info = new TypeInfo (tc);
-                       type_hash.Add (tc.Definition, info);
-                       return info;
-               }
-
                private TypeInfo (TypeSpec type)
                {
                        this.Type = type;
@@ -1097,23 +1084,6 @@ namespace Mono.CSharp
                        }
                }
 
-               private TypeInfo (TypeContainer tc)
-               {
-                       this.Type = tc.Definition;
-
-                       struct_info = StructInfo.GetStructInfo (tc);
-                       if (struct_info != null) {
-                               Length = struct_info.Length;
-                               TotalLength = struct_info.TotalLength;
-                               SubStructInfo = struct_info.StructFields;
-                               IsStruct = true;
-                       } else {
-                               Length = 0;
-                               TotalLength = 1;
-                               IsStruct = false;
-                       }
-               }
-
                TypeInfo (StructInfo struct_info, int offset)
                {
                        this.struct_info = struct_info;
@@ -1155,6 +1125,10 @@ namespace Mono.CSharp
                        for (int i = 0; i < struct_info.Count; i++) {
                                var field = struct_info.Fields [i];
 
+                               // Fixed size buffers are not subject to definite assignment checking
+                               if (field is FixedFieldSpec)
+                                       continue;
+
                                if (!branching.IsFieldAssigned (vi, field.Name)) {
                                        if (field.MemberDefinition is Property.BackingField) {
                                                ec.Report.Error (843, loc,
@@ -1291,11 +1265,7 @@ namespace Mono.CSharp
 
                        public static StructInfo GetStructInfo (TypeSpec type)
                        {
-                               if (!TypeManager.IsValueType (type) || TypeManager.IsEnumType (type) ||
-                                   TypeManager.IsBuiltinType (type))
-                                       return null;
-
-                               if (TypeManager.IsGenericParameter (type))
+                               if (!type.IsStruct || type.BuiltinType > 0)
                                        return null;
 
                                StructInfo info;
@@ -1304,15 +1274,6 @@ namespace Mono.CSharp
 
                                return new StructInfo (type);
                        }
-
-                       public static StructInfo GetStructInfo (TypeContainer tc)
-                       {
-                               StructInfo info;
-                               if (field_type_hash.TryGetValue (tc.Definition, out info))
-                                       return info;
-
-                               return new StructInfo (tc.Definition);
-                       }
                }
        }
 
@@ -1407,7 +1368,7 @@ namespace Mono.CSharp
                public bool IsAssigned (ResolveContext ec)
                {
                        return !ec.DoFlowAnalysis ||
-                               ec.OmitStructFlowAnalysis && TypeInfo.IsStruct ||
+                               (ec.OmitStructFlowAnalysis && TypeInfo.Type.IsStruct) ||
                                ec.CurrentBranching.IsAssigned (this);
                }