Mono.CSharp.FieldSpec.Mutate C# (CSharp) Method

Mutate() public method

public Mutate ( Mono.CSharp.TypeParameterMutator mutator ) : FieldSpec
mutator Mono.CSharp.TypeParameterMutator
return FieldSpec
		public FieldSpec Mutate (TypeParameterMutator mutator)
		{
			var decl = DeclaringType;
			if (DeclaringType.IsGenericOrParentIsGeneric)
				decl = mutator.Mutate (decl);

			if (decl == DeclaringType)
				return this;

			var fs = (FieldSpec) MemberwiseClone ();
			fs.declaringType = decl;
			fs.state |= StateFlags.PendingMetaInflate;

			// Gets back FieldInfo in case of metaInfo was inflated
			fs.metaInfo = MemberCache.GetMember (TypeParameterMutator.GetMemberDeclaringType (DeclaringType), this).metaInfo;
			return fs;
		}

Usage Example

Example #1
0
        public void Emit(OpCode opcode, FieldSpec field)
        {
            if (IsAnonymousStoreyMutateRequired)
            {
                field = field.Mutate(CurrentAnonymousMethod.Storey.Mutator);
            }

            ig.Emit(opcode, field.GetMetaInfo());

            if (TrackStackTypes)
            {
                switch (opcode.StackBehaviourPush)
                {
                case StackBehaviour.Push0:
                    // nothing
                    break;

                case StackBehaviour.Push1:
                    SetStackType(field.MemberType);
                    break;

                case StackBehaviour.Pushi:
                    SetStackType(ReferenceContainer.MakeType(Module, field.MemberType));
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }
All Usage Examples Of Mono.CSharp.FieldSpec::Mutate