static StackObject *GetOptionalCustomModifiers_21(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Reflection.FieldInfo instance_of_this_method = (System.Reflection.FieldInfo) typeof(System.Reflection.FieldInfo).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.GetOptionalCustomModifiers(); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
[System.Security.SecurityCritical] // auto-generated private FieldToken GetFieldTokenNoLock(FieldInfo field) { if (field == null) { throw new ArgumentNullException("con"); } Contract.EndContractBlock(); int tr; int mr = 0; FieldBuilder fdBuilder = null; RuntimeFieldInfo rtField = null; FieldOnTypeBuilderInstantiation fOnTB = null; if ((fdBuilder = field as FieldBuilder) != null) { if (field.DeclaringType != null && field.DeclaringType.IsGenericType) { int length; byte[] sig = SignatureHelper.GetTypeSigToken(this, field.DeclaringType).InternalGetSignature(out length); tr = GetTokenFromTypeSpec(sig, length); mr = GetMemberRef(this, tr, fdBuilder.GetToken().Token); } else if (fdBuilder.Module.Equals(this)) { // field is defined in the same module return fdBuilder.GetToken(); } else { // field is defined in a different module if (field.DeclaringType == null) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); } tr = GetTypeTokenInternal(field.DeclaringType).Token; mr = GetMemberRef(field.ReflectedType.Module, tr, fdBuilder.GetToken().Token); } } else if ( (rtField = field as RuntimeFieldInfo) != null) { // FieldInfo is not an dynamic field // We need to get the TypeRef tokens if (field.DeclaringType == null) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); } if (field.DeclaringType != null && field.DeclaringType.IsGenericType) { int length; byte[] sig = SignatureHelper.GetTypeSigToken(this, field.DeclaringType).InternalGetSignature(out length); tr = GetTokenFromTypeSpec(sig, length); mr = GetMemberRefOfFieldInfo(tr, field.DeclaringType.GetTypeHandleInternal(), rtField); } else { tr = GetTypeTokenInternal(field.DeclaringType).Token; mr = GetMemberRefOfFieldInfo(tr, field.DeclaringType.GetTypeHandleInternal(), rtField); } } else if ( (fOnTB = field as FieldOnTypeBuilderInstantiation) != null) { FieldInfo fb = fOnTB.FieldInfo; int length; byte[] sig = SignatureHelper.GetTypeSigToken(this, field.DeclaringType).InternalGetSignature(out length); tr = GetTokenFromTypeSpec(sig, length); mr = GetMemberRef(fb.ReflectedType.Module, tr, fOnTB.MetadataTokenInternal); } else { // user defined FieldInfo tr = GetTypeTokenInternal(field.ReflectedType).Token; SignatureHelper sigHelp = SignatureHelper.GetFieldSigHelper(this); sigHelp.AddArgument(field.FieldType, field.GetRequiredCustomModifiers(), field.GetOptionalCustomModifiers()); int length; byte[] sigBytes = sigHelp.InternalGetSignature(out length); mr = GetMemberRefFromSignature(tr, field.Name, sigBytes, length); } return new FieldToken(mr, field.GetType()); }
static private void AppendFieldInfo(FieldInfo field, StringBuilder sb) { sb.Append(".field "); foreach (var attribute in field.GetCustomAttributesData()) { AppendCustomAttributeData(attribute, sb); sb.Append(" "); } foreach (var modreq in field.GetRequiredCustomModifiers()) { sb.Append("modreq("); AppendType(modreq, sb); sb.Append(") "); } foreach (var modopt in field.GetOptionalCustomModifiers()) { sb.Append("modopt("); AppendType(modopt, sb); sb.Append(") "); } if (field.IsPrivate) sb.Append("private "); if (field.IsPublic) sb.Append("public "); if (field.IsFamily) sb.Append("family "); if (field.IsAssembly) sb.Append("assembly "); if (field.IsFamilyOrAssembly) sb.Append("famorassem "); if (field.IsFamilyAndAssembly) sb.Append("famandassem "); if (field.IsInitOnly) sb.Append("initonly "); if (field.IsLiteral) sb.Append("literal "); if (field.IsNotSerialized) sb.Append("notserialized "); if (field.Attributes.HasFlag(FieldAttributes.SpecialName)) sb.Append("specialname "); if (field.Attributes.HasFlag(FieldAttributes.RTSpecialName)) sb.Append("rtspecialname "); if (field.IsPinvokeImpl) sb.Append("pinvokeimpl "); sb.Append(field.IsStatic ? "static " : "instance "); AppendType(field.FieldType, sb); sb.Append(" "); sb.Append(field.Name); if (field.IsLiteral) { AppendValue(field.GetRawConstantValue(), sb); } }
private void TraceField( FieldInfo field ) { // <instr_field> <type> <typeSpec> :: <id> Contract.Assert( field != null ); WriteType( this._trace, field.FieldType ); this._trace.Write( " " ); // TODO: NLiblet #if !SILVERLIGHT var asFieldBuilder = field as FieldBuilder; if ( asFieldBuilder == null ) { var modreqs = field.GetRequiredCustomModifiers(); if ( 0 < modreqs.Length ) { this._trace.Write( "modreq(" ); foreach ( var modreq in modreqs ) { WriteType( this._trace, modreq ); } this._trace.Write( ") " ); } var modopts = field.GetOptionalCustomModifiers(); if ( 0 < modopts.Length ) { this._trace.Write( "modopt(" ); foreach ( var modopt in modopts ) { WriteType( this._trace, modopt ); } this._trace.Write( ") " ); } } #endif #if !SILVERLIGHT if ( this._isInDynamicMethod || asFieldBuilder == null ) // declaring type of the field should be omitted for same type. #endif { WriteType( this._trace, field.DeclaringType ); } this._trace.Write( "::" ); this._trace.Write( field.Name ); }
private FieldToken GetFieldTokenNoLock(FieldInfo field) { int tokenFromTypeSpec; if (field == null) { throw new ArgumentNullException("con"); } int num2 = 0; FieldBuilder builder = null; FieldOnTypeBuilderInstantiation instantiation = null; builder = field as FieldBuilder; if (builder != null) { if ((field.DeclaringType != null) && field.DeclaringType.IsGenericType) { int num3; byte[] signature = SignatureHelper.GetTypeSigToken(this, field.DeclaringType).InternalGetSignature(out num3); tokenFromTypeSpec = this.GetTokenFromTypeSpec(signature, num3); num2 = this.GetMemberRef(this, tokenFromTypeSpec, builder.GetToken().Token); } else { if (builder.Module.Equals(this)) { return builder.GetToken(); } if (field.DeclaringType == null) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); } tokenFromTypeSpec = this.GetTypeTokenInternal(field.DeclaringType).Token; num2 = this.GetMemberRef(field.ReflectedType.Module, tokenFromTypeSpec, builder.GetToken().Token); } } else if (field is RuntimeFieldInfo) { if (field.DeclaringType == null) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); } int metadataToken = field.MetadataToken; if ((field.DeclaringType != null) && field.DeclaringType.IsGenericType) { int num5; byte[] buffer2 = SignatureHelper.GetTypeSigToken(this, field.DeclaringType).InternalGetSignature(out num5); tokenFromTypeSpec = this.GetTokenFromTypeSpec(buffer2, num5); num2 = this.GetMemberRefOfFieldInfo(tokenFromTypeSpec, field.DeclaringType.GetTypeHandleInternal(), metadataToken); } else { tokenFromTypeSpec = this.GetTypeTokenInternal(field.DeclaringType).Token; num2 = this.GetMemberRefOfFieldInfo(tokenFromTypeSpec, field.DeclaringType.GetTypeHandleInternal(), metadataToken); } } else { instantiation = field as FieldOnTypeBuilderInstantiation; if (instantiation != null) { int num6; FieldInfo fieldInfo = instantiation.FieldInfo; byte[] buffer3 = SignatureHelper.GetTypeSigToken(this, field.DeclaringType).InternalGetSignature(out num6); tokenFromTypeSpec = this.GetTokenFromTypeSpec(buffer3, num6); num2 = this.GetMemberRef(fieldInfo.ReflectedType.Module, tokenFromTypeSpec, instantiation.MetadataTokenInternal); } else { int num7; tokenFromTypeSpec = this.GetTypeTokenInternal(field.ReflectedType).Token; SignatureHelper fieldSigHelper = SignatureHelper.GetFieldSigHelper(this); fieldSigHelper.AddArgument(field.FieldType, field.GetRequiredCustomModifiers(), field.GetOptionalCustomModifiers()); byte[] buffer4 = fieldSigHelper.InternalGetSignature(out num7); num2 = this.GetMemberRefFromSignature(tokenFromTypeSpec, field.Name, buffer4, num7); } } return new FieldToken(num2, field.GetType()); }