using System;
using System.Text;
using System.Collections.Generic;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Diagnostics;
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;
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;
}
}
- 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;
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,
- "An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling default contructor",
+ "An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling the default struct contructor from a constructor initializer",
field.GetSignatureForError ());
} else {
ec.Report.Error (171, loc,
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;
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);
- }
}
}
public bool IsAssigned (ResolveContext ec)
{
return !ec.DoFlowAnalysis ||
- ec.OmitStructFlowAnalysis && TypeInfo.IsStruct ||
+ (ec.OmitStructFlowAnalysis && TypeInfo.Type.IsStruct) ||
ec.CurrentBranching.IsAssigned (this);
}