Ejemplo n.º 1
0
 public override void ReadRest(ReaderContext ctxt, BlobReader reader)
 {
     Index = (int)reader.ReadCompressedUInt32();
 }
Ejemplo n.º 2
0
        public override void ReadRest(ReaderContext ctxt, BlobReader reader)
        {
            if (TypeArity > 0)
                TypeArity = (int)reader.ReadCompressedUInt32();

            var paramCount = (int)reader.ReadCompressedUInt32();
            ReturnType = new TypeWithCustomMods();
            ReturnType.Read(ctxt, reader);
            var sentinelIndex = -1;
            if (paramCount > 0)
            {
                var parameters = new Seq<TypeWithCustomMods>(paramCount);
                for (var i = 0; i < paramCount; i++)
                {
                    var param = new TypeWithCustomMods();
                    param.Read(ctxt, reader);
                    if (param.Type.IsSentinel)
                    {
                        if (CallingConvention == CallingConvention.ManagedVarArg ||
                            CallingConvention == CallingConvention.NativeC)
                        {
                            if (sentinelIndex > 0)
                                throw new PEException("multiple sentinels in VARARG/C signature");
                            sentinelIndex = i;
                            i--;
                        }
                        else
                            throw new PEException("unexpected sentinel in non-VARARG/C signature");
                    }
                    else
                        parameters.Add(param);
                }
                Parameters = parameters;
            }
            else
                Parameters = Constants.EmptyTypeWithCustomMods;
            VarArgs = sentinelIndex < 0 ? 0 : paramCount - sentinelIndex;
        }
Ejemplo n.º 3
0
 public override void ReadRest(ReaderContext ctxt, BlobReader reader)
 {
     Applicand = Read(ctxt, reader);
     var argCount = (int)reader.ReadCompressedUInt32();
     var arguments = new Seq<TypeSig>(argCount);
     for (var i = 0; i < argCount; i++)
         arguments.Add(Read(ctxt, reader));
     Arguments = arguments;
 }
Ejemplo n.º 4
0
 public override void ReadRest(ReaderContext ctxt, BlobReader reader)
 {
     ElementType = Read(ctxt, reader);
     Rank = (int)reader.ReadCompressedUInt32();
     var numSizes = (int)reader.ReadCompressedUInt32();
     var sizes = new Seq<uint>(numSizes);
     for (var i = 0; i < numSizes; i++)
         sizes.Add(reader.ReadCompressedUInt32());
     Sizes = sizes;
     var numLoBounds = (int)reader.ReadCompressedUInt32();
     var loBounds = new Seq<uint>(numLoBounds);
     for (var i = 0; i < numLoBounds; i++)
         loBounds.Add(reader.ReadCompressedUInt32());
     LoBounds = loBounds;
 }
Ejemplo n.º 5
0
        public static TypeSig Read(ReaderContext ctxt, BlobReader reader)
        {
            var tag = (TypeSigTag)reader.ReadCompressedUInt32();
            var res = default(TypeSig);
            switch (tag)
            {
                case TypeSigTag.END:
                    return null;
                case TypeSigTag.SENTINEL:
                    res = new SentinelPsuedoTypeSig();
                    break;
                case TypeSigTag.PINNED:
                    res = new PinnedPsuedoTypeSig();
                    break;
                case TypeSigTag.VOID:
                case TypeSigTag.BOOLEAN:
                case TypeSigTag.CHAR:
                case TypeSigTag.I1:
                case TypeSigTag.U1:
                case TypeSigTag.I2:
                case TypeSigTag.U2:
                case TypeSigTag.I4:
                case TypeSigTag.U4:
                case TypeSigTag.I8:
                case TypeSigTag.U8:
                case TypeSigTag.R4:
                case TypeSigTag.R8:
                case TypeSigTag.STRING:
                case TypeSigTag.I:
                case TypeSigTag.U:
                case TypeSigTag.OBJECT:
                case TypeSigTag.SYSTYPE_ARGUMENT: // NOTE: Not mentioned in spec...
                case TypeSigTag.TYPEDBYREF:
                    res = new PrimitiveTypeSig { PrimitiveType = PrimitiveTypeSig.FromTag(tag) };
                    break;
                case TypeSigTag.PTR:
                    res = new UnmanagedPointerTypeSig();
                    break;
                case TypeSigTag.BYREF:
                    res = new ManagedPointerTypeSig();
                    break;
                case TypeSigTag.SZARRAY:
                    res = new ArrayTypeSig();
                    break;
                case TypeSigTag.ARRAY:
                    res = new MultiDimArrayTypeSig();
                    break;
                case TypeSigTag.VALUETYPE:
                case TypeSigTag.CLASS:
                    res = new TypeDefOrRefSig { IsValueType = tag == TypeSigTag.VALUETYPE };
                    break;
                case TypeSigTag.CMOD_REQD:
                case TypeSigTag.CMOD_OPT:
                    res = new CustomModPseudoTypeSig { IsRequired = tag == TypeSigTag.CMOD_REQD };
                    break;
                case TypeSigTag.VAR:
                    res = new TypeParameterTypeSig();
                    break;
                case TypeSigTag.GENERICINST:
                    res = new ApplicationTypeSig();
                    break;
                case TypeSigTag.MVAR:
                    res = new MethodParameterTypeSig();
                    break;
                case TypeSigTag.FNPTR:
                    res = new FunctionPointerTypeSig();
                    break;
                case TypeSigTag.INTERNAL:
                case TypeSigTag.RESERVED:
                    throw new PEException("unimplemented type tag");
                case TypeSigTag.CUSTOM_ATTRIBUTE_BOXED_ARGUMENT:
                case TypeSigTag.CUSTOM_ATTRIBUTE_FIELD:
                case TypeSigTag.CUSTOM_ATTRIBUTE_PROPERTY:
                case TypeSigTag.CUSTOM_ATTRIBUTE_ENUM:
                    throw new PEException("unexpected custom attribute in type");
                default:
                    throw new PEException("unrecognised type tag");
            }

            res.ReadRest(ctxt, reader);
            return res;
        }
Ejemplo n.º 6
0
 public override void ReadRest(ReaderContext ctxt, BlobReader reader)
 {
     var variableCount = (int)reader.ReadCompressedUInt32();
     if (variableCount > 0)
     {
         var variables = new Seq<LocalVar>(variableCount);
         for (var i = 0; i < variableCount; i++)
         {
             var l = new LocalVar();
             l.Read(ctxt, reader);
             variables.Add(l);
         }
         Variables = variables;
     }
     else
         Variables = Constants.EmptyLocalVars;
 }
Ejemplo n.º 7
0
 public override void ReadRest(ReaderContext ctxt, BlobReader reader)
 {
     var paramCount = (int)reader.ReadCompressedUInt32();
     ReturnType = new TypeWithCustomMods();
     ReturnType.Read(ctxt, reader);
     if (paramCount > 0)
     {
         var parameters = new Seq<TypeSig>(paramCount);
         for (var i = 0; i < paramCount; i++)
             parameters.Add(TypeSig.Read(ctxt, reader));
         Parameters = parameters;
     }
     else
         Parameters = Constants.EmptyTypeSigs;
 }