示例#1
0
        public ASTrait(ABCFile abc, FlashReader input)
            : this(abc)
        {
            QNameIndex = input.ReadInt30();

            byte bitContainer = input.ReadByte();
            Kind       = (TraitKind)(bitContainer & 0x0F);
            Attributes = (TraitAttributes)(bitContainer >> 4);

            Id = input.ReadInt30();
            switch (Kind)
            {
            case TraitKind.Slot:
            case TraitKind.Constant:
            {
                TypeIndex  = input.ReadInt30();
                ValueIndex = input.ReadInt30();
                if (ValueIndex != 0)
                {
                    ValueKind = (ConstantKind)input.ReadByte();
                }
                break;
            }

            case TraitKind.Method:
            case TraitKind.Getter:
            case TraitKind.Setter:
            {
                MethodIndex  = input.ReadInt30();
                Method.Trait = this;
                break;
            }

            case TraitKind.Class:
            {
                ClassIndex = input.ReadInt30();
                break;
            }

            case TraitKind.Function:
            {
                FunctionIndex = input.ReadInt30();
                break;
            }
            }

            if (Attributes.HasFlag(TraitAttributes.Metadata))
            {
                MetadataIndices.Capacity = input.ReadInt30();
                for (int i = 0; i < MetadataIndices.Capacity; i++)
                {
                    int metadatumIndex = input.ReadInt30();
                    MetadataIndices.Add(metadatumIndex);
                }
            }
        }
示例#2
0
        public ASTrait(ABCFile abc, FlashReader reader)
        {
            _abc = abc;

            NameIndex = reader.Read7BitEncodedInt();
            byte trueKind = reader.ReadByte();

            var traitType = (TraitType)(trueKind & 0xF);
            Attributes = (TraitAttributes)(trueKind >> 4);
            #region Trait Reading
            switch (traitType)
            {
                case TraitType.Slot:
                case TraitType.Constant:
                Data = new SlotConstantTrait(abc, reader, Name.ObjName, traitType);
                break;

                case TraitType.Method:
                case TraitType.Getter:
                case TraitType.Setter:
                {
                    var mgsTrait = new MethodGetterSetterTrait(abc, reader, Name.ObjName, traitType);
                    mgsTrait.Method.ObjName = Name.ObjName;

                    Data = mgsTrait;
                    break;
                }

                case TraitType.Class:
                {
                    var classTrait = new ClassTrait(abc, reader, Name.ObjName);
                    // TODO: Link trait information?
                    Data = classTrait;
                    break;
                }

                case TraitType.Function:
                {
                    var functionTrait = new FunctionTrait(abc, reader, Name.ObjName);
                    // TODO: Link trait information?
                    Data = functionTrait;
                    break;
                }

                default:
                throw new Exception("Invalid trait: " + TraitType);
            }
            #endregion

            MetadataIndices = new List<int>();
            if ((Attributes & TraitAttributes.Metadata) != 0)
                MetadataIndices.Capacity = reader.Read7BitEncodedInt();

            for (int i = 0; i < MetadataIndices.Capacity; i++)
                MetadataIndices.Add(reader.Read7BitEncodedInt());
        }
示例#3
0
 public ASTrait(ABCFile abc, int nameIndex, TraitAttributes attributes, IList<int> metadataIndices) :
     this(abc, nameIndex, attributes)
 {
     MetadataIndices.AddRange(metadataIndices);
 }
示例#4
0
 public ASTrait(ABCFile abc, int nameIndex, TraitAttributes attributes) :
     this(abc, nameIndex)
 {
     Attributes = attributes;
 }