Mono.Debugger.Languages.Mono.MonoEnumType.get_fields C# (CSharp) Method

get_fields() private method

private get_fields ( ) : void
return void
        void get_fields()
        {
            if (fields != null)
                return;

            foreach (Cecil.CustomAttribute cattr in type.CustomAttributes) {
                if (cattr.Constructor.DeclaringType.FullName == "System.FlagsAttribute") {
                    is_flags = true;
                    break;
                }
            }

            int num_fields = 0, num_sfields = 0;

            foreach (Cecil.FieldDefinition field in type.Fields) {
                if (field.IsStatic)
                    num_sfields++;
                else
                    num_fields++;
            }

            fields = new MonoEnumInfo [num_fields];
            static_fields = new MonoEnumInfo [num_sfields];

            int pos = 0, spos = 0, i = 0;
            foreach (Cecil.FieldDefinition field in type.Fields) {
                TargetType ftype = File.MonoLanguage.LookupMonoType (field.FieldType);
                if (field.IsStatic) {
                    static_fields [spos] = new MonoEnumInfo (
                        this, ftype, spos, i, field);
                    spos++;
                } else {
                    if (field.Name != "value__")
                        throw new InternalError ("Mono enum type has instance field with name other than 'value__'.");
                    fields [pos] = new MonoEnumInfo (this, ftype, pos, i, field);
                    pos++;
                }

                i++;
            }
            if (pos > 1)
                throw new InternalError ("Mono enum type has more than one instance field.");
        }