Exemple #1
0
            //
            // We only need one instance per type
            //
            StructInfo(TypeSpec type, IMemberContext context)
            {
                field_type_hash.Add(type, this);

                fields = MemberCache.GetAllFieldsForDefiniteAssignment(type, context);

                struct_field_hash = new Dictionary <string, TypeInfo> ();
                field_hash        = new Dictionary <string, int> (fields.Count);

                StructFields = new TypeInfo[fields.Count];
                StructInfo[] sinfo = new StructInfo[fields.Count];

                InTransit = true;

                for (int i = 0; i < fields.Count; i++)
                {
                    var field = fields [i];

                    if (field.MemberType.IsStruct)
                    {
                        sinfo [i] = GetStructInfo(field.MemberType, context);
                    }

                    if (sinfo [i] == null)
                    {
                        field_hash.Add(field.Name, ++Length);
                    }
                    else if (sinfo [i].InTransit)
                    {
                        sinfo [i] = null;
                        return;
                    }
                }

                InTransit = false;

                TotalLength = Length + 1;
                for (int i = 0; i < fields.Count; i++)
                {
                    var field = fields [i];

                    if (sinfo [i] == null)
                    {
                        continue;
                    }

                    field_hash.Add(field.Name, TotalLength);

                    StructFields [i] = new TypeInfo(sinfo [i], TotalLength);
                    struct_field_hash.Add(field.Name, StructFields [i]);
                    TotalLength += sinfo [i].TotalLength;
                }
            }