Ejemplo n.º 1
0
        private void ReadEnum(TagRepository rpa, CatalogReader catalog, BinaryReader reader)
        {
            byte underlyingTypeSymbol = reader.ReadByte();
            bool isSigned;
            uint literalSize;

            switch ((EnumUnderlyingType)underlyingTypeSymbol)
            {
                case EnumUnderlyingType.Int8:
                case EnumUnderlyingType.Int16:
                case EnumUnderlyingType.Int32:
                case EnumUnderlyingType.Int64:
                    isSigned = true;
                    break;
                case EnumUnderlyingType.UInt8:
                case EnumUnderlyingType.UInt16:
                case EnumUnderlyingType.UInt32:
                case EnumUnderlyingType.UInt64:
                    isSigned = false;
                    break;
                default:
                    throw new Exception("Unrecognized enum underlying type");
            }

            switch ((EnumUnderlyingType)underlyingTypeSymbol)
            {
                case EnumUnderlyingType.Int8:
                case EnumUnderlyingType.UInt8:
                    literalSize = 1;
                    break;
                case EnumUnderlyingType.Int16:
                case EnumUnderlyingType.UInt16:
                    literalSize = 2;
                    break;
                case EnumUnderlyingType.Int32:
                case EnumUnderlyingType.UInt32:
                    literalSize = 4;
                    break;
                case EnumUnderlyingType.Int64:
                case EnumUnderlyingType.UInt64:
                    literalSize = 8;
                    break;
                default:
                    throw new Exception();
            }

            uint numLiterals = reader.ReadUInt32();
            HighEnumLiteral[] literals = new HighEnumLiteral[numLiterals];

            for (uint i = 0; i < numLiterals; i++)
                literals[i] = HighEnumLiteral.Read(catalog, reader, literalSize, isSigned);

            m_enumLiterals = literals;
            m_underlyingType = (EnumUnderlyingType)underlyingTypeSymbol;
        }
Ejemplo n.º 2
0
 public EnumSerializationInfo(TypeReference reference, EnumUnderlyingType underlyingType)
 {
     Type           = reference;
     UnderlyingType = underlyingType;
 }
Ejemplo n.º 3
0
        public void Read(TagRepository rpa, CatalogReader catalog, BinaryReader reader)
        {
            m_semantics = (TypeSemantics)reader.ReadByte();
            switch (m_semantics)
            {
                case TypeSemantics.Class:
                case TypeSemantics.Interface:
                case TypeSemantics.Struct:
                case TypeSemantics.Enum:
                case TypeSemantics.Delegate:
                    break;
                default:
                    throw new RpaLoadException("Invalid type semantics");
            }

            m_typeName = catalog.GetTypeName(reader.ReadUInt32());

            if (m_typeName.AssemblyName != catalog.AssemblyName)
                throw new Exception("Type definition outside of assembly");

            m_numGenericParameters = m_typeName.NumGenericParameters;

            m_underlyingType = EnumUnderlyingType.NotEnum;
            if (m_semantics == TypeSemantics.Delegate)
            {
                this.ReadDelegate(rpa, catalog, reader);
            }
            else if (m_semantics == TypeSemantics.Enum)
            {
                this.ReadEnum(rpa, catalog, reader);
            }
            else
            {
                this.ReadClassDefinitions(rpa, catalog, reader);

                if (m_semantics == Clarity.Rpa.TypeSemantics.Class || m_semantics == Clarity.Rpa.TypeSemantics.Struct)
                    this.ReadClassStatics(rpa, catalog, reader);
            }
        }