EmitGetHelper() private method

private EmitGetHelper ( Operand op, Type desiredType, Conversion conv, Type from = null ) : void
op Operand
desiredType IKVM.Reflection.Type
conv Conversion
from IKVM.Reflection.Type
return void
        void EmitArg(CodeGen g, int index, Operand arg)
        {
            if (_appliedSignature[index].IsByRef)
            {
                arg.EmitAddressOf(g);
                return;
            }

            g.EmitGetHelper(arg, _appliedSignature[index], _conversions[index], @from: _paramsSignature[index]);
        }
Example #2
0
 internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
 {
     if (IsReference)
     {
         g.EmitLdargHelper(_index);
         g.EmitStindHelper(GetReturnType(g.TypeMapper), value, allowExplicitConversion);
     }
     else
     {
         g.EmitGetHelper(value, GetReturnType(g.TypeMapper), allowExplicitConversion);
         g.EmitStargHelper(_index);
     }
 }
Example #3
0
 internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
 {
     if (IsReference)
     {
         g.EmitLdargHelper(index);
         g.EmitStindHelper(Type, value, allowExplicitConversion);
     }
     else
     {
         g.EmitGetHelper(value, Type, allowExplicitConversion);
         g.EmitStargHelper(index);
     }
 }
Example #4
0
 protected internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
 {
     OperandExtensions.SetLeakedState(this, false);
     if (IsReference)
     {
         g.EmitLdargHelper(_index);
         g.EmitStindHelper(GetReturnType(g.TypeMapper), value, allowExplicitConversion);
     }
     else
     {
         g.EmitGetHelper(value, GetReturnType(g.TypeMapper), allowExplicitConversion);
         g.EmitStargHelper(_index);
     }
 }
Example #5
0
            protected internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
            {
                OperandExtensions.SetLeakedState(this, false);
                CheckScope(g);

                if (_t == null)
                {
                    _t = value.GetReturnType(g.TypeMapper);
                }

                if (_var == null)
                {
                    _var = g.IL.DeclareLocal(_t);
                }

                Type nullableUnderlyingType = Helpers.GetNullableUnderlyingType(_t);

                if (ReferenceEquals(value, null))
                {
                    if (nullableUnderlyingType != null)
                    {
                        g.InitObj(this);
                        return;
                    }
                }
                else if (nullableUnderlyingType == value.GetReturnType(g.TypeMapper))
                {
                    EmitAddressOf(g);
                    g.EmitGetHelper(value, nullableUnderlyingType, false);
                    ConstructorInfo ctor = _t.GetConstructor(new [] { nullableUnderlyingType });
                    g.IL.Emit(OpCodes.Call, ctor);
                    return;
                }
                g.EmitGetHelper(value, _t, allowExplicitConversion);

                EmitSetFromStack(g);
            }
Example #6
0
        public override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
        {
            if (!IsStatic)
            {
                if (g.Context.IsStatic || g.Context.OwnerType != owner.TypeBuilder)
                {
                    throw new InvalidOperationException("The field is accessed from an invalid context");
                }

                g.IL.Emit(OpCodes.Ldarg_0);
            }

            g.EmitGetHelper(value, type, allowExplicitConversion);
            g.IL.Emit(IsStatic ? OpCodes.Stsfld : OpCodes.Stfld, fb);
        }
Example #7
0
        internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
        {
            if (!IsStatic)
            {
                if (g.Context.IsStatic || g.Context.OwnerType != owner.TypeBuilder)
                {
                    throw new InvalidOperationException(Properties.Messages.ErrInvalidFieldContext);
                }

                g.IL.Emit(OpCodes.Ldarg_0);
            }

            g.EmitGetHelper(value, type, allowExplicitConversion);
            g.IL.Emit(IsStatic ? OpCodes.Stsfld : OpCodes.Stfld, fb);
        }
Example #8
0
            internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
            {
                CheckScope(g);

                if (t == null)
                {
                    t = value.Type;
                }

                if (var == null)
                {
                    var = g.il.DeclareLocal(t);
                }

                g.EmitGetHelper(value, t, allowExplicitConversion);
                g.il.Emit(OpCodes.Stloc, var);
            }
Example #9
0
            internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
            {
                CheckScope(g);

                if (_t == null)
                {
                    _t = value.GetReturnType(g.TypeMapper);
                }

                if (_var == null)
                {
                    _var = g.IL.DeclareLocal(_t);
                }

                g.EmitGetHelper(value, _t, allowExplicitConversion);
                g.IL.Emit(OpCodes.Stloc, _var);
            }
Example #10
0
        public override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
        {
            if (setter == null)
            {
                base.EmitSet(g, value, allowExplicitConversion);
            }

            if (indexParameters.Count != 0)
            {
                throw new InvalidOperationException("Cannot access indexed property without indexes");
            }

            if (!IsStatic && (g.Context.IsStatic || g.Context.OwnerType != owner.TypeBuilder))
            {
                throw new InvalidOperationException("The property is accessed from an invalid context");
            }

            g.IL.Emit(OpCodes.Ldarg_0);
            g.EmitGetHelper(value, Type, allowExplicitConversion);
            g.EmitCallHelper(setter.GetMethodBuilder(), null);
        }
Example #11
0
        internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
        {
            if (setter == null)
            {
                base.EmitSet(g, value, allowExplicitConversion);
            }

            if (indexParameters.Count != 0)
            {
                throw new InvalidOperationException(Properties.Messages.ErrMissingPropertyIndex);
            }

            if (!IsStatic && (g.Context.IsStatic || g.Context.OwnerType != owner.TypeBuilder))
            {
                throw new InvalidOperationException(Properties.Messages.ErrInvalidPropertyContext);
            }

            g.IL.Emit(OpCodes.Ldarg_0);
            g.EmitGetHelper(value, Type, allowExplicitConversion);
            g.EmitCallHelper(setter.GetMethodBuilder(), null);
        }
Example #12
0
        protected internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
        {
            OperandExtensions.SetLeakedState(this, false);
            if (_setter == null)
            {
                base.EmitSet(g, value, allowExplicitConversion);
            }

            if (_indexParameters.Count != 0)
            {
                throw new InvalidOperationException(Properties.Messages.ErrMissingPropertyIndex);
            }

            if (!IsStatic && (g.Context.IsStatic || g.Context.OwnerType != _owner.TypeBuilder))
            {
                throw new InvalidOperationException(Properties.Messages.ErrInvalidPropertyContext);
            }

            g.IL.Emit(OpCodes.Ldarg_0);
            g.EmitGetHelper(value, GetReturnType(TypeMapper), allowExplicitConversion);
            g.EmitCallHelper(_setter.GetMethodBuilder(), null);
        }
Example #13
0
        internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
        {
            if (setter == null)
                base.EmitSet(g, value, allowExplicitConversion);

            if (indexParameters.Count != 0)
                throw new InvalidOperationException(Properties.Messages.ErrMissingPropertyIndex);

            if (!IsStatic && (g.Context.IsStatic || g.Context.OwnerType != owner.TypeBuilder))
                throw new InvalidOperationException(Properties.Messages.ErrInvalidPropertyContext);

            g.IL.Emit(OpCodes.Ldarg_0);
            g.EmitGetHelper(value, Type, allowExplicitConversion);
            g.EmitCallHelper(setter.GetMethodBuilder(), null);
        }
Example #14
0
		protected internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
		{
		    OperandExtensions.SetLeakedState(this, false);  
			if (!IsStatic)
			{
				if (g.Context.IsStatic || g.Context.OwnerType != _owner.TypeBuilder)
					throw new InvalidOperationException(Properties.Messages.ErrInvalidFieldContext);

				g.IL.Emit(OpCodes.Ldarg_0);
			}

			g.EmitGetHelper(value, _type, allowExplicitConversion);
			g.IL.Emit(IsStatic ? OpCodes.Stsfld : OpCodes.Stfld, _fb);
		}
Example #15
0
	    protected void EmitGetHelper(CodeGen g, Operand op, Type desiredType, bool allowExplicitConversion)
	    {
            g.EmitGetHelper(op, desiredType,allowExplicitConversion);
	    }
Example #16
0
 protected void EmitGetHelper(CodeGen g, Operand op, Type desiredType, bool allowExplicitConversion)
 {
     g.EmitGetHelper(op, desiredType, allowExplicitConversion);
 }
Example #17
0
		    protected internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
		    {
		        OperandExtensions.SetLeakedState(this, false); 
				if (IsReference)
				{
					g.EmitLdargHelper(_index);
					g.EmitStindHelper(GetReturnType(g.TypeMapper), value, allowExplicitConversion);
				}
				else
				{
					g.EmitGetHelper(value, GetReturnType(g.TypeMapper), allowExplicitConversion);
					g.EmitStargHelper(_index);
				}
			}
Example #18
0
			protected internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
			{
		        OperandExtensions.SetLeakedState(this, false); 
				CheckScope(g);

				if (_t == null)
					_t = value.GetReturnType(g.TypeMapper);

				if (_var == null)
					_var = g.IL.DeclareLocal(_t);

			    Type nullableUnderlyingType = Helpers.GetNullableUnderlyingType(_t);
			    if (ReferenceEquals(value, null))
			    {
			        if (nullableUnderlyingType != null)
			        {
			            g.InitObj(this);
			            return;
			        }
			    }
                else if (nullableUnderlyingType == value.GetReturnType(g.TypeMapper))
                {
                    EmitAddressOf(g);
                    g.EmitGetHelper(value, nullableUnderlyingType, false);
                    ConstructorInfo ctor = _t.GetConstructor(new [] { nullableUnderlyingType});
                    g.IL.Emit(OpCodes.Call, ctor);
                    return;
                }
                    g.EmitGetHelper(value, _t, allowExplicitConversion);

			    EmitSetFromStack(g);
			}
			internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
			{
				CheckScope(g);

				if (t == null)
					t = value.Type;

				if (var == null)
					var = g.il.DeclareLocal(t);

				g.EmitGetHelper(value, t, allowExplicitConversion);
				g.il.Emit(OpCodes.Stloc, var);
			}
			internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
			{
				if (IsReference)
				{
					g.EmitLdargHelper(index);
					g.EmitStindHelper(Type, value, allowExplicitConversion);
				}
				else
				{
					g.EmitGetHelper(value, Type, allowExplicitConversion);
					g.EmitStargHelper(index);
				}
			}
Example #21
0
		protected internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion)
		{
		    OperandExtensions.SetLeakedState(this, false);  
			if (_setter == null)
				base.EmitSet(g, value, allowExplicitConversion);

			if (_indexParameters.Count != 0)
				throw new InvalidOperationException(Properties.Messages.ErrMissingPropertyIndex);

			if (!IsStatic && (g.Context.IsStatic || g.Context.OwnerType != _owner.TypeBuilder))
				throw new InvalidOperationException(Properties.Messages.ErrInvalidPropertyContext);

			g.IL.Emit(OpCodes.Ldarg_0);
			g.EmitGetHelper(value, GetReturnType(TypeMapper), allowExplicitConversion);
			g.EmitCallHelper(_setter.GetMethodBuilder(), null);
		}