コード例 #1
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			foreach (Statement s in statements)
			{
				s.Emit(member, gen);
			}
		}
コード例 #2
0
ファイル: IfNullExpression.cs プロジェクト: JohnsonYuan/n2cms
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     ArgumentsUtil.EmitLoadOwnerAndReference(reference, gen);
     var notNull = gen.DefineLabel();
     gen.Emit(OpCodes.Brtrue_S, notNull);
     ifNull.Emit(member, gen);
     gen.MarkLabel(notNull);
     ifNotNull.Emit(member, gen);
 }
コード例 #3
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			right.Emit(member, gen);

			if (fromType == target)
			{
				return;
			}

			if (fromType.IsByRef)
			{
				fromType = fromType.GetElementType();
			}

			if (target.IsByRef)
			{
				target = target.GetElementType();
			}

			if (target.IsArray())
			{
				if (fromType.IsValueType())
				{
					throw new NotImplementedException("Cannot convert between distinct value types");
				}
				else
				{
					// Unbox conversion
					// Assumes fromType is a boxed value
					// if we can, we emit a box and ldind, otherwise, we will use unbox.any
					if (LdindOpCodesDictionary.Instance[target] != LdindOpCodesDictionary.EmptyOpCode)
					{
						gen.Emit(OpCodes.Unbox, target);
						OpCodeUtil.EmitLoadIndirectOpCodeForType(gen, target);
					}
					else
					{
						gen.Emit(OpCodes.Unbox_Any, target);
					}
				}
			}
			else
			{
				if (fromType.IsValueType())
				{
					// Box conversion
					gen.Emit(OpCodes.Box, fromType);
					EmitCastIfNeeded(typeof(object), target, gen);
				}
				else
				{
					// Possible down-cast
					EmitCastIfNeeded(fromType, target, gen);
				}
			}
		}
コード例 #4
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     expression.Emit(member, gen);
     gen.Emit(OpCodes.Dup);
     var label = gen.DefineLabel();
     gen.Emit(OpCodes.Brtrue_S, label);
     gen.Emit(OpCodes.Pop);
     @default.Emit(member, gen);
     gen.MarkLabel(label);
 }
コード例 #5
0
		public override void Emit(IMemberEmitter member, ILGenerator il)
		{
			ArgumentsUtil.EmitLoadOwnerAndReference(targetArray, il);

			il.Emit(OpCodes.Ldc_I4, targetPosition);

			value.Emit(member, il);

			il.Emit(OpCodes.Stelem_Ref);
		}
コード例 #6
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			gen.Emit(OpCodes.Ldarg_0);

			foreach (var exp in args)
			{
				exp.Emit(member, gen);
			}

			gen.Emit(OpCodes.Call, cmethod);
		}
コード例 #7
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			var ci = exceptionType.GetConstructor(new[] { typeof(String) });
			var constRef = new ConstReference(errorMessage);

			var creationStmt = new NewInstanceExpression(ci, constRef.ToExpression());

			creationStmt.Emit(member, gen);

			gen.Emit(OpCodes.Throw);
		}
コード例 #8
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            Label elseTarget = gen.DefineLabel();

            _condition.Emit(member, gen);
            gen.Emit(_condition.BranchIfFalse, elseTarget);
            foreach (Statement s in _thenStatements)
            {
                s.Emit(member, gen);
            }
            gen.MarkLabel(elseTarget);
        }
コード例 #9
0
		internal void Generate(IMemberEmitter member, ILGenerator il)
		{
			foreach (var local in ilmarkers)
			{
				local.Generate(il);
			}

			foreach (var stmt in stmts)
			{
				stmt.Emit(member, il);
			}
		}
コード例 #10
0
        internal void Generate(IMemberEmitter member, ILGenerator il)
        {
            foreach (var local in ilmarkers)
            {
                local.Generate(il);
            }

            foreach (var stmt in stmts)
            {
                stmt.Emit(member, il);
            }
        }
コード例 #11
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            if (arguments != null)
            {
                foreach (var exp in arguments)
                {
                    exp.Emit(member, gen);
                }
            }

            gen.Emit(OpCodes.Newobj, constructor);
        }
コード例 #12
0
        internal void Generate(IMemberEmitter member, ILGenerator il)
        {
            foreach (var local in locals)
            {
                local.Generate(il);
            }

            foreach (var statement in statements)
            {
                statement.Emit(member, il);
            }
        }
コード例 #13
0
		internal void Generate(IMemberEmitter member, ILGenerator il)
		{
			foreach (Reference local in ilmarkers)
			{
				local.Generate(il);
			}

			foreach (Statement stmt in stmts)
			{
				stmt.Emit(member, il);
			}
		}
コード例 #14
0
ファイル: MethodTokenExpression.cs プロジェクト: elevine/Core
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			gen.Emit(OpCodes.Ldtoken, method);
			if (declaringType == null)
			{
				throw new GeneratorException("declaringType can't be null for this situation");
			}
			gen.Emit(OpCodes.Ldtoken, declaringType);

			var minfo = MethodBaseMethods.GetMethodFromHandle2;
			gen.Emit(OpCodes.Call, minfo);
			gen.Emit(OpCodes.Castclass, typeof(MethodInfo));
		}
コード例 #15
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            ArgumentsUtil.EmitLoadOwnerAndReference(reference, gen);
            var notNull = gen.DefineLabel();

            gen.Emit(OpCodes.Brtrue_S, notNull);
            ifNull.Emit(member, gen);
            gen.MarkLabel(notNull);
            if (ifNotNull != null)             // yeah, I know that reads funny :)
            {
                ifNotNull.Emit(member, gen);
            }
        }
コード例 #16
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     owner.Emit(member, gen);
     gen.Emit(OpCodes.Dup);
     if (methodToBindTo.IsFinal)
     {
         gen.Emit(OpCodes.Ldftn, methodToBindTo);
     }
     else
     {
         gen.Emit(OpCodes.Ldvirtftn, methodToBindTo);
     }
     gen.Emit(OpCodes.Newobj, delegateCtor);
 }
コード例 #17
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            gen.Emit(OpCodes.Ldtoken, method);
            if (declaringType == null)
            {
                throw new GeneratorException("declaringType can't be null for this situation");
            }
            gen.Emit(OpCodes.Ldtoken, declaringType);

            var minfo = MethodBaseMethods.GetMethodFromHandle2;

            gen.Emit(OpCodes.Call, minfo);
            gen.Emit(OpCodes.Castclass, typeof(MethodInfo));
        }
コード例 #18
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     owner.Emit(member, gen);
     gen.Emit(OpCodes.Dup);
     if (methodToBindTo.IsFinal)
     {
         gen.Emit(OpCodes.Ldftn, methodToBindTo);
     }
     else
     {
         gen.Emit(OpCodes.Ldvirtftn, methodToBindTo);
     }
     gen.Emit(OpCodes.Newobj, delegateCtor);
 }
コード例 #19
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            switch (value)
            {
            case -1:
                gen.Emit(OpCodes.Ldc_I4_M1);
                break;

            case 0:
                gen.Emit(OpCodes.Ldc_I4_0);
                break;

            case 1:
                gen.Emit(OpCodes.Ldc_I4_1);
                break;

            case 2:
                gen.Emit(OpCodes.Ldc_I4_2);
                break;

            case 3:
                gen.Emit(OpCodes.Ldc_I4_3);
                break;

            case 4:
                gen.Emit(OpCodes.Ldc_I4_4);
                break;

            case 5:
                gen.Emit(OpCodes.Ldc_I4_5);
                break;

            case 6:
                gen.Emit(OpCodes.Ldc_I4_6);
                break;

            case 7:
                gen.Emit(OpCodes.Ldc_I4_7);
                break;

            case 8:
                gen.Emit(OpCodes.Ldc_I4_8);
                break;

            default:
                gen.Emit(OpCodes.Ldc_I4, value);
                break;
            }
        }
コード例 #20
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			right.Emit(member, gen);

			if (fromType == target)
			{
				return;
			}

			if (fromType.IsByRef)
			{
				fromType = fromType.GetElementType();
			}

			if (target.IsByRef)
			{
				target = target.GetElementType();
			}

			if (target.IsValueType)
			{
				if (fromType.IsValueType)
				{
					throw new NotImplementedException("Cannot convert between distinct value types");
				}
				else
				{
					// Unbox conversion
					// Assumes fromType is a boxed value
					gen.Emit(OpCodes.Unbox, target);
					OpCodeUtil.EmitLoadIndirectOpCodeForType(gen, target);
				}
			}
			else
			{
				if (fromType.IsValueType)
				{
					// Box conversion
					gen.Emit(OpCodes.Box, fromType);
					EmitCastIfNeeded(typeof(object), target, gen);
				}
				else
				{
					// Possible down-cast
					EmitCastIfNeeded(fromType, target, gen);
				}
			}
		}
コード例 #21
0
            public override void Emit(IMemberEmitter member, ILGenerator gen)
            {
                Label trueLabel  = gen.DefineLabel();
                Label falseLabel = gen.DefineLabel();

                _expression.Emit(member, gen);
                gen.Emit(_expression.BranchIfTrue, trueLabel);
                _expression.Emit(member, gen);
                gen.Emit(_expression.BranchIfFalse, falseLabel);
                gen.Emit(OpCodes.Ldstr, "No label selected");
                gen.Emit(OpCodes.Ret);
                gen.MarkLabel(trueLabel);
                gen.Emit(OpCodes.Ldstr, "True");
                gen.Emit(OpCodes.Ret);
                gen.MarkLabel(falseLabel);
                gen.Emit(OpCodes.Ldstr, "False");
                gen.Emit(OpCodes.Ret);
            }
コード例 #22
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            ArgumentsUtil.EmitLoadOwnerAndReference(owner, gen);

            foreach (Expression exp in args)
            {
                exp.Emit(member, gen);
            }

            if (virtualCall)
            {
                gen.Emit(OpCodes.Callvirt, method);
            }
            else
            {
                gen.Emit(OpCodes.Call, method);
            }
        }
コード例 #23
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			ArgumentsUtil.EmitLoadOwnerAndReference(owner, gen);

			foreach (var exp in args)
			{
				exp.Emit(member, gen);
			}

			if (VirtualCall)
			{
				gen.Emit(OpCodes.Callvirt, method);
			}
			else
			{
				gen.Emit(OpCodes.Call, method);
			}
		}
コード例 #24
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            foreach (Expression exp in arguments)
            {
                exp.Emit(member, gen);
            }

            if (constructor == null)
            {
                constructor = type.GetConstructor(constructorArgs);
            }

            if (constructor == null)
            {
                throw new ProxyGenerationException("Could not find constructor matching specified arguments");
            }

            gen.Emit(OpCodes.Newobj, constructor);
        }
コード例 #25
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			foreach (Expression exp in arguments)
			{
				exp.Emit(member, gen);
			}

			if (constructor == null)
			{
				constructor = type.GetConstructor(constructor_args);
			}

			if (constructor == null)
			{
				throw new ProxyGenerationException("Could not find constructor matching specified arguments");
			}

			gen.Emit(OpCodes.Newobj, constructor);
		}
コード例 #26
0
        public MutableNestedTypeCodeGeneratorFactory(
            IReflectionEmitCodeGenerator reflectionEmitCodeGenerator,
            IEmittableOperandProvider emittableOperandProvider,
            IMemberEmitter memberEmitter,
            IInitializationBuilder initializationBuilder,
            IProxySerializationEnabler proxySerializationEnabler)
        {
            ArgumentUtility.CheckNotNull("reflectionEmitCodeGenerator", reflectionEmitCodeGenerator);
            ArgumentUtility.CheckNotNull("emittableOperandProvider", emittableOperandProvider);
            ArgumentUtility.CheckNotNull("memberEmitter", memberEmitter);
            ArgumentUtility.CheckNotNull("initializationBuilder", initializationBuilder);
            ArgumentUtility.CheckNotNull("proxySerializationEnabler", proxySerializationEnabler);

            _reflectionEmitCodeGenerator = reflectionEmitCodeGenerator;
            _emittableOperandProvider    = emittableOperandProvider;
            _memberEmitter             = memberEmitter;
            _initializationBuilder     = initializationBuilder;
            _proxySerializationEnabler = proxySerializationEnabler;
        }
コード例 #27
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            LoadOwnersRecursively(_callTarget.OwnerReference, gen);

            if (_callTarget.Type.IsValueType)
            {
                _callTarget.LoadAddressOfReference(gen);
            }
            else
            {
                _callTarget.LoadReference(gen);
            }

            foreach (Expression argument in _arguments)
            {
                argument.Emit(member, gen);
            }

            EmitCall(member, gen);
        }
コード例 #28
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			gen.Emit(OpCodes.Ldtoken, method);
#if !MONO
			if (declaringType == null)
			{
				throw new GeneratorException("declaringType can't be null for this situation");
			}
			gen.Emit(OpCodes.Ldtoken, declaringType);
#endif

			MethodInfo minfo = Constants.GetMethodFromHandle1;

#if !MONO
			minfo = Constants.GetMethodFromHandle2;
#endif

			gen.Emit(OpCodes.Call, minfo);
			gen.Emit(OpCodes.Castclass, typeof(MethodInfo));
		}
コード例 #29
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            if (reference != null)
            {
                ArgumentsUtil.EmitLoadOwnerAndReference(reference, gen);
            }
            else if (expression != null)
            {
                expression.Emit(member, gen);
            }
            else
            {
                if (member.ReturnType != typeof(void))
                {
                    OpCodeUtil.EmitLoadOpCodeForDefaultValueOfType(gen, member.ReturnType);
                }
            }

            gen.Emit(OpCodes.Ret);
        }
コード例 #30
0
ファイル: ReturnStatement.cs プロジェクト: brianmatic/n2cms
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            if (reference != null)
            {
                ArgumentsUtil.EmitLoadOwnerAndReference(reference, gen);
            }
            else if (expression != null)
            {
                expression.Emit(member, gen);
            }
            else
            {
                if (member.ReturnType != typeof(void))
                {
                    OpCodeUtil.EmitLoadOpCodeForDefaultValueOfType(gen, member.ReturnType);
                }
            }

            gen.Emit(OpCodes.Ret);
        }
コード例 #31
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			var local = gen.DeclareLocal(typeof(object[]));

			gen.Emit(OpCodes.Ldc_I4, args.Length);
			gen.Emit(OpCodes.Newarr, typeof(object));
			gen.Emit(OpCodes.Stloc, local);

			for (var i = 0; i < args.Length; i++)
			{
				gen.Emit(OpCodes.Ldloc, local);
				gen.Emit(OpCodes.Ldc_I4, i);

				var reference = args[i];

				ArgumentsUtil.EmitLoadOwnerAndReference(reference, gen);

				if (reference.Type.IsByRef)
				{
					throw new NotSupportedException();
				}
				if (reference.Type.IsPointer)
				{
					gen.Emit(OpCodes.Call, ArgumentsUtil.IntPtrFromPointer());
					gen.Emit(OpCodes.Box, typeof(IntPtr));
				}
				else if (reference.Type.IsValueType)
				{
					gen.Emit(OpCodes.Box, reference.Type.UnderlyingSystemType);
				}
				else if (reference.Type.IsGenericParameter)
				{
					gen.Emit(OpCodes.Box, reference.Type);
				}

				gen.Emit(OpCodes.Stelem_Ref);
			}

			gen.Emit(OpCodes.Ldloc, local);
		}
コード例 #32
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            var local = gen.DeclareLocal(typeof(object[]));

            gen.Emit(OpCodes.Ldc_I4, args.Length);
            gen.Emit(OpCodes.Newarr, typeof(object));
            gen.Emit(OpCodes.Stloc, local);

            for (var i = 0; i < args.Length; i++)
            {
                gen.Emit(OpCodes.Ldloc, local);
                gen.Emit(OpCodes.Ldc_I4, i);

                var reference = args[i];

                ArgumentsUtil.EmitLoadOwnerAndReference(reference, gen);

                if (reference.Type.GetTypeInfo().IsByRef)
                {
                    throw new NotSupportedException();
                }
                if (reference.Type.GetTypeInfo().IsPointer)
                {
                    gen.Emit(OpCodes.Call, ArgumentsUtil.IntPtrFromPointer());
                    gen.Emit(OpCodes.Box, typeof(IntPtr));
                }
                if (reference.Type.GetTypeInfo().IsValueType)
                {
                    gen.Emit(OpCodes.Box, reference.Type);
                }
                else if (reference.Type.GetTypeInfo().IsGenericParameter)
                {
                    gen.Emit(OpCodes.Box, reference.Type);
                }

                gen.Emit(OpCodes.Stelem_Ref);
            }

            gen.Emit(OpCodes.Ldloc, local);
        }
コード例 #33
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            ArgumentUtility.CheckNotNull("member", member);
            ArgumentUtility.CheckNotNull("gen", gen);

            gen.BeginExceptionBlock();

            foreach (Statement statement in _tryStatements)
            {
                statement.Emit(member, gen);
            }

            gen.BeginFinallyBlock();

            foreach (Statement statement in _finallyStatements)
            {
                statement.Emit(member, gen);
            }

            gen.EndExceptionBlock();
            gen.Emit(OpCodes.Nop); // ensure a leave target for try block
        }
コード例 #34
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            // @mbrit - 2012-06-04 - can't do anything other than pass proper MethodInfo
            // instances down a this is all MSIL knows how to deal with...
            gen.Emit(OpCodes.Ldtoken, method.AsMethodInfo());
#if !MONO
            if (declaringType == null)
            {
                throw new GeneratorException("declaringType can't be null for this situation");
            }
            gen.Emit(OpCodes.Ldtoken, declaringType);
#endif

            var minfo = MethodBaseMethods.GetMethodFromHandle1;

#if !MONO
            minfo = MethodBaseMethods.GetMethodFromHandle2;
#endif

            gen.Emit(OpCodes.Call, minfo);
            gen.Emit(OpCodes.Castclass, typeof(MethodInfo));
        }
コード例 #35
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			switch (value)
			{
				case -1:
					gen.Emit(OpCodes.Ldc_I4_M1);
					break;
				case 0:
					gen.Emit(OpCodes.Ldc_I4_0);
					break;
				case 1:
					gen.Emit(OpCodes.Ldc_I4_1);
					break;
				case 2:
					gen.Emit(OpCodes.Ldc_I4_2);
					break;
				case 3:
					gen.Emit(OpCodes.Ldc_I4_3);
					break;
				case 4:
					gen.Emit(OpCodes.Ldc_I4_4);
					break;
				case 5:
					gen.Emit(OpCodes.Ldc_I4_5);
					break;
				case 6:
					gen.Emit(OpCodes.Ldc_I4_6);
					break;
				case 7:
					gen.Emit(OpCodes.Ldc_I4_7);
					break;
				case 8:
					gen.Emit(OpCodes.Ldc_I4_8);
					break;
				default:
					gen.Emit(OpCodes.Ldc_I4, value);
					break;
			}
		}
コード例 #36
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
            // @mbrit - 2012-06-04 - can't do anything other than pass proper MethodInfo
            // instances down a this is all MSIL knows how to deal with...
			gen.Emit(OpCodes.Ldtoken, method.AsMethodInfo());
#if !MONO
			if (declaringType == null)
			{
				throw new GeneratorException("declaringType can't be null for this situation");
			}
			gen.Emit(OpCodes.Ldtoken, declaringType);
#endif

			var minfo = MethodBaseMethods.GetMethodFromHandle1;

#if !MONO
			minfo = MethodBaseMethods.GetMethodFromHandle2;
#endif

			gen.Emit(OpCodes.Call, minfo);
			gen.Emit(OpCodes.Castclass, typeof(MethodInfo));
		}
コード例 #37
0
        public MutableNestedTypeCodeGenerator(
            ITypeBuilder enclosingTypeBuilder,
            MutableType mutableType,
            IMutableNestedTypeCodeGeneratorFactory nestedTypeCodeGeneratorFactory,
            IReflectionEmitCodeGenerator codeGenerator,
            IEmittableOperandProvider emittableOperandProvider,
            IMemberEmitter memberEmitter,
            IInitializationBuilder initializationBuilder,
            IProxySerializationEnabler proxySerializationEnabler)
            : base(
                mutableType,
                nestedTypeCodeGeneratorFactory,
                codeGenerator,
                emittableOperandProvider,
                memberEmitter,
                initializationBuilder,
                proxySerializationEnabler)
        {
            ArgumentUtility.CheckNotNull("enclosingTypeBuilder", enclosingTypeBuilder);

            _enclosingTypeBuilder = enclosingTypeBuilder;
        }
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            LocalBuilder local = gen.DeclareLocal(typeof(object[]));

            gen.Emit(OpCodes.Ldc_I4, args.Length);
            gen.Emit(OpCodes.Newarr, typeof(object));
            gen.Emit(OpCodes.Stloc, local);

            for (int i = 0; i < args.Length; i++)
            {
                gen.Emit(OpCodes.Ldloc, local);
                gen.Emit(OpCodes.Ldc_I4, i);

                TypeReference reference = args[i];

                ArgumentsUtil.EmitLoadOwnerAndReference(reference, gen);

                if (reference.Type.IsByRef)
                {
                    throw new NotSupportedException();
                }

                if (reference.Type.IsValueType)
                {
                    gen.Emit(OpCodes.Box, reference.Type.UnderlyingSystemType);
                }
                if (reference.Type.IsGenericParameter)
                {
                    gen.Emit(OpCodes.Box, reference.Type);
                }

                gen.Emit(OpCodes.Stelem_Ref);
            }

            gen.Emit(OpCodes.Ldloc, local);
        }
コード例 #39
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			// TODO: check if this can be simplified by using more of OpCodeUtil and other existing types
			if (IsPrimitiveOrClass(type))
			{
				OpCodeUtil.EmitLoadOpCodeForDefaultValueOfType(gen, type);
			}
			else if(type.IsValueType || type.IsGenericParameter)
			{
				// TODO: handle decimal explicitly
				var local = gen.DeclareLocal(type);
				gen.Emit(OpCodes.Ldloca_S, local);
				gen.Emit(OpCodes.Initobj, type);
				gen.Emit(OpCodes.Ldloc, local);
			}
			else if (type.IsByRef)
			{
				EmitByRef(gen);
			}
			else
			{
				throw new ProxyGenerationException("Can't emit default value for type " + type);
			}
		}
コード例 #40
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     // TODO: check if this can be simplified by using more of OpCodeUtil and other existing types
     if (IsPrimitiveOrClass(type))
     {
         OpCodeUtil.EmitLoadOpCodeForDefaultValueOfType(gen, type);
     }
     else if (type.IsValueType || type.IsGenericParameter)
     {
         // TODO: handle decimal explicitly
         var local = gen.DeclareLocal(type);
         gen.Emit(OpCodes.Ldloca_S, local);
         gen.Emit(OpCodes.Initobj, type);
         gen.Emit(OpCodes.Ldloc, local);
     }
     else if (type.IsByRef)
     {
         EmitByRef(gen);
     }
     else
     {
         throw new ProxyGenerationException("Can't emit default value for type " + type);
     }
 }
コード例 #41
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			gen.Emit(OpCodes.Ldnull);
		}
コード例 #42
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     // TODO: Should it discard any possible return value with a pop?
     expression.Emit(member, gen);
 }
コード例 #43
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     ArgumentsUtil.EmitLoadOwnerAndReference(arrayReference, gen);
     ArgumentsUtil.EmitLoadOwnerAndReference(index, gen);
     gen.Emit(OpCodes.Ldelem, returnType);
 }
コード例 #44
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			gen.BeginExceptionBlock();
		}
コード例 #45
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     gen.BeginFinallyBlock();
 }
コード例 #46
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     ArgumentsUtil.EmitLoadOwnerAndReference(reference, gen);
 }
コード例 #47
0
        public override void Emit(IMemberEmitter member, ILGenerator gen)
        {
            ArgumentsUtil.EmitLoadOwnerAndReference(reference.OwnerReference, gen);

            reference.LoadAddressOfReference(gen);
        }
コード例 #48
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     gen.EndExceptionBlock();
 }
コード例 #49
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     ArgumentsUtil.EmitLoadOwnerAndReference(arrayReference, gen);
     ArgumentsUtil.EmitLoadOwnerAndReference(index, gen);
     gen.Emit(OpCodes.Ldelem, returnType);
 }
コード例 #50
0
ファイル: Expression.cs プロジェクト: havard/strongbind
 public abstract void Emit(IMemberEmitter member, ILGenerator gen);
コード例 #51
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     gen.Emit(OpCodes.Ldnull);
 }
コード例 #52
0
ファイル: AssignStatement.cs プロジェクト: rpc-bindings/core
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     ArgumentsUtil.EmitLoadOwnerAndReference(target.OwnerReference, gen);
     expression.Emit(member, gen);
     target.StoreReference(gen);
 }
コード例 #53
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     gen.Emit(OpCodes.Ldc_I4, size);
     gen.Emit(OpCodes.Newarr, arrayType);
 }
コード例 #54
0
ファイル: Expression.cs プロジェクト: dengxuan/Fighting
 public abstract void Emit(IMemberEmitter member, ILGenerator gen);
コード例 #55
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			gen.Emit(OpCodes.Ldc_I4, size);
			gen.Emit(OpCodes.Newarr, arrayType);
		}
コード例 #56
0
ファイル: AssignStatement.cs プロジェクト: brianmatic/n2cms
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     ArgumentsUtil.EmitLoadOwnerAndReference(target.OwnerReference, gen);
     expression.Emit(member, gen);
     target.StoreReference(gen);
 }
コード例 #57
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     statements.ForEach(s => s.Emit(member, gen));
 }
コード例 #58
0
		public override void Emit(IMemberEmitter member, ILGenerator gen)
		{
			// TODO: Should it discard any possible return value with a pop?
			expression.Emit(member, gen);
		}
コード例 #59
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     gen.Emit(OpCodes.Ldtoken, type);
     gen.Emit(OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle"));
 }
コード例 #60
0
 public override void Emit(IMemberEmitter member, ILGenerator gen)
 {
     gen.Emit(OpCodes.Ldtoken, type);
     gen.Emit(OpCodes.Call, TypeMethods.GetTypeFromHandle);
 }