예제 #1
0
        public override void Collect(Prototype prototype)
        {
            base.Collect(prototype);

            // Shorty descriptor
            Collect(TypeDescriptor.Encode(prototype));
        }
예제 #2
0
        public override int GetHashCode()
        {
            if (IsFrozen && _hashCode != 0)
            {
                return(_hashCode);
            }

            var builder = new StringBuilder();

            builder.AppendLine(TypeDescriptor.Encode(ReturnType));

            foreach (Parameter parameter in Parameters)
            {
                builder.AppendLine(TypeDescriptor.Encode(parameter.Type));
            }

            var ret = builder.ToString().GetHashCode();

            if (IsFrozen)
            {
                _hashCode = ret;
            }

            return(ret);
        }
예제 #3
0
        public override int GetHashCode()
        {
            var builder = new StringBuilder();

            builder.AppendLine(TypeDescriptor.Encode(Type));

            foreach (var argument in Arguments)
            {
                builder.Append(String.Format("{0}=", argument.Name));
                if (ValueFormat.GetFormat(argument.Value) == ValueFormats.Array)
                {
                    var array = argument.Value as Array;
                    if (array == null)
                    {
                        throw new ArgumentException();
                    }

                    for (var i = 0; i < array.Length; i++)
                    {
                        if (i > 0)
                        {
                            builder.Append(",");
                        }
                        builder.Append(array.GetValue(i));
                    }
                }
                else
                {
                    builder.Append(argument.Value);
                }
                builder.AppendLine();
            }

            return(builder.ToString().GetHashCode());
        }
예제 #4
0
        public override int GetHashCode()
        {
            var builder = new StringBuilder();

            builder.AppendLine(TypeDescriptor.Encode(Type));
            builder.AppendLine(Instruction.GetHashCode().ToString(CultureInfo.InvariantCulture));

            return(builder.ToString().GetHashCode());
        }
예제 #5
0
        public override int GetHashCode()
        {
            var builder = new StringBuilder();

            builder.AppendLine(TypeDescriptor.Encode(ReturnType));

            foreach (var parameter in Parameters)
            {
                builder.AppendLine(TypeDescriptor.Encode(parameter.Type));
            }

            return(builder.ToString().GetHashCode());
        }
예제 #6
0
        /// <summary>
        /// Write type_id_item structures for each type reference used in the dex file.
        /// </summary>
        private void WriteTypeId(BinaryWriter writer)
        {
            var count = typeReferences.Count;

            if (count > 0)
            {
                headerMarkers.TypeReferencesMarker.Value = new SizeOffset((uint)count, (uint)writer.BaseStream.Position);
                map.Add(TypeCodes.TypeId, (uint)count, (uint)writer.BaseStream.Position);
            }

            foreach (var tref in typeReferences)
            {
                writer.Write(LookupStringId(TypeDescriptor.Encode(tref)));
            }
        }
예제 #7
0
        private void ReadTypesReferences(BinaryReader reader)
        {
            reader.PreserveCurrentPosition(header.TypeReferencesOffset, () =>
            {
                for (int i = 0; i < header.TypeReferencesSize; i++)
                {
                    int descriptorIndex = reader.ReadInt32();
                    string descriptor   = strings[descriptorIndex];
                    TypeDescriptor.Fill(descriptor, typeReferences[i]);

                    // freeze the references and cache the encoded value.
                    typeReferences[i].Freeze();
                    TypeDescriptor.Encode(typeReferences[i]);
                }
            });
        }
예제 #8
0
        /// <summary>
        /// Write proto_id_item structures for each prototype.
        /// </summary>
        private void WritePrototypeId(BinaryWriter writer)
        {
            var count = prototypes.Count;

            if (count > 0)
            {
                headerMarkers.PrototypesMarker.Value = new SizeOffset((uint)count, (uint)writer.BaseStream.Position);
                map.Add(TypeCodes.ProtoId, (uint)count, (uint)writer.BaseStream.Position);
            }

            foreach (var prototype in prototypes)
            {
                writer.Write(LookupStringId(TypeDescriptor.Encode(prototype)));
                writer.Write((uint)typeReferences.IndexOf(prototype.ReturnType));
                prototypeTypeListMarkers.Add(writer.MarkUInt());
            }
        }
예제 #9
0
 public override void Collect(TypeReference tref)
 {
     base.Collect(tref);
     Collect(TypeDescriptor.Encode(tref));
 }
예제 #10
0
 public int Compare(TypeReference x, TypeReference y)
 {
     return(string.CompareOrdinal(TypeDescriptor.Encode(x), TypeDescriptor.Encode(y)));
 }