当前位置: 首页>>代码示例>>C#>>正文


C# ILGenerator.DeclareLocal方法代码示例

本文整理汇总了C#中System.Reflection.Emit.ILGenerator.DeclareLocal方法的典型用法代码示例。如果您正苦于以下问题:C# ILGenerator.DeclareLocal方法的具体用法?C# ILGenerator.DeclareLocal怎么用?C# ILGenerator.DeclareLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.Emit.ILGenerator的用法示例。


在下文中一共展示了ILGenerator.DeclareLocal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmitMethodBody

        public void EmitMethodBody(ILGenerator IL, MethodInfo method, FieldInfo field)
        {
            bool isStatic = false;

            ParameterInfo[] parameters = method.GetParameters();
            IL.DeclareLocal(typeof (object[]));
            IL.DeclareLocal(typeof (InvocationInfo));
            IL.DeclareLocal(typeof (Type[]));

            IL.Emit(OpCodes.Ldarg_0);
            IL.Emit(OpCodes.Callvirt, getInterceptor);

            // if (interceptor == null)
            // 		throw new NullReferenceException();

            Label skipThrow = IL.DefineLabel();

            IL.Emit(OpCodes.Dup);
            IL.Emit(OpCodes.Ldnull);
            IL.Emit(OpCodes.Bne_Un, skipThrow);

            IL.Emit(OpCodes.Newobj, notImplementedConstructor);
            IL.Emit(OpCodes.Throw);

            IL.MarkLabel(skipThrow);
            // Push the 'this' pointer onto the stack
            IL.Emit(OpCodes.Ldarg_0);

            // Push the MethodInfo onto the stack            
            Type declaringType = method.DeclaringType;
            
            IL.Emit(OpCodes.Ldtoken, method);
            if (declaringType.IsGenericType)
            {
                IL.Emit(OpCodes.Ldtoken, declaringType);
                IL.Emit(OpCodes.Call, getGenericMethodFromHandle);
            }
            else
            {
                IL.Emit(OpCodes.Call, getMethodFromHandle);
            }

            IL.Emit(OpCodes.Castclass, typeof (MethodInfo));

            PushStackTrace(IL);
            PushGenericArguments(method, IL);
            _argumentHandler.PushArguments(parameters, IL, isStatic);

            // InvocationInfo info = new InvocationInfo(...);

            IL.Emit(OpCodes.Newobj, infoConstructor);
            IL.Emit(OpCodes.Stloc_1);
            IL.Emit(OpCodes.Ldloc_1);
            IL.Emit(OpCodes.Callvirt, handlerMethod);

            SaveRefArguments(IL, parameters);
            PackageReturnType(method, IL);

            IL.Emit(OpCodes.Ret);
        }
开发者ID:Vernathic,项目名称:ic-AutoTest.NET4CTDD,代码行数:60,代码来源:DefaultMethodEmitter.cs

示例2: BuildArguments

        public override LocalBuilder BuildArguments(ILGenerator ilGenerator)
        {
            LocalBuilder propertyLocalBuilder = null;
            FieldBuilder contractFieldBuilder = null;
            LocalBuilder aspectArgLocalBuilder = null;
            ConstructorInfo ctorInterceptionArgs = null;
            AbstractAspectPropertyArgsWeaver methodWeaver = null;

            propertyLocalBuilder = LocalBuilderRepository.Declare(() => {
                return ilGenerator.DeclareLocal(typeof(PropertyInfo));
            });

            ctorInterceptionArgs = ArgumentType.GetConstructors()[0];
            aspectArgLocalBuilder = ilGenerator.DeclareLocal(ArgumentType);
            contractFieldBuilder = WeavingSettings.TypeDefinition.GetFieldBuilder(WeavingSettings.ContractType);
            methodWeaver = new AspectArgsGetPropertyWeaver(Member, propertyLocalBuilder, aspectWeavingSettings);
            methodWeaver.Weave(ilGenerator);
            ilGenerator.EmitLoadArg(0);
            ilGenerator.Emit(OpCodes.Ldfld, contractFieldBuilder);
            ilGenerator.EmitLoadLocal(propertyLocalBuilder);
            ilGenerator.Emit(OpCodes.Ldsfld, BindingsDependency);
            ilGenerator.Emit(OpCodes.Newobj, ctorInterceptionArgs);
            ilGenerator.EmitStoreLocal(aspectArgLocalBuilder);

            return aspectArgLocalBuilder;
        }
开发者ID:sagifogel,项目名称:NCop,代码行数:26,代码来源:TopGetPropertyInterceptionArgumentsWeaver.cs

示例3: FillEntity

        public static void FillEntity(ILGenerator generator, Type entityType, LocalBuilder entity)
        {
            //Dictionary<string, int> fields = DataPortal.FindFields(data);
            LocalBuilder fields = generator.DeclareLocal(typeof(Dictionary<string, int>));
            generator.Emit(OpCodes.Ldarg_0);
            generator.Emit(OpCodes.Call, typeof(DataPortal).GetMethod("FindFields", new Type[]{typeof(IDataRecord)}));
            generator.Emit(OpCodes.Stloc, fields);

            foreach(PropertyInfo property in entityType.GetProperties())
            {
                DbFieldAttribute fieldInfo = ReflectionHelper.GetAttribute<DbFieldAttribute>(property);
                if(fieldInfo == null)
                {
                    continue;
                }

                //int fieldIndex = DataPortal.FindField(fields, propInfo.Name);
                LocalBuilder fieldIndex = generator.DeclareLocal(typeof(Int32));
                generator.Emit(OpCodes.Ldloc, fields);
                generator.Emit(OpCodes.Ldstr, fieldInfo.FieldName);
                generator.Emit(OpCodes.Call, typeof(DataPortal).GetMethod("FindField", new Type[] { typeof(Dictionary<string, int>), typeof(string) }));
                generator.Emit(OpCodes.Stloc, fieldIndex);
                //if(fieldIndex >= 0)
                Label notFieldExists = generator.DefineLabel();
                generator.Emit(OpCodes.Ldloc, fieldIndex);
                generator.Emit(OpCodes.Ldc_I4_0);
                generator.Emit(OpCodes.Clt);
                generator.Emit(OpCodes.Brtrue_S, notFieldExists);
                {
                    FillProperty(generator, entityType, entity, property, fieldIndex);
                    generator.Emit(OpCodes.Nop);
                }
                generator.MarkLabel(notFieldExists);
            }
        }
开发者ID:ritacc,项目名称:RitaccTest,代码行数:35,代码来源:DataEntityBuilder.cs

示例4: LocalVariableCollection

 public LocalVariableCollection(ILGenerator il, bool decode)
 {
     this.il = il;
     variables = new Dictionary<string, LocalBuilder>();
     dataPointer = il.DeclareLocal(typeof(byte*));
     remainingBytes = decode ? il.DeclareLocal(typeof(int)) : null;
 }
开发者ID:Eisenstein,项目名称:SharpRPC,代码行数:7,代码来源:LocalVariableCollection.cs

示例5: EmitCalculateSize

        public void EmitCalculateSize(ILGenerator il, Action<ILGenerator> emitLoad)
        {
            var valueIsNullOrEmptyLabel = il.DefineLabel();
            var valueHasElementsLabel = il.DefineLabel();
            var loopStartLabel = il.DefineLabel();
            var loopConditionLabel = il.DefineLabel();
            var endOfMethodLabel = il.DefineLabel();

            var iVar = il.DeclareLocal(typeof(int));          // int i
            var sumVar = il.DeclareLocal(typeof(int));        // int sum
            var elemVar = il.DeclareLocal(type);              // T elem

            emitLoad(il);                                     // if (!value)
            il.Emit(OpCodes.Brfalse, valueIsNullOrEmptyLabel);//     goto valueIsNullOrEmptyLabel

            emitLoad(il);                                     // if ((int)value.Length)
            il.Emit(OpCodes.Ldlen);                           //     goto valueHasElementsLabel
            il.Emit(OpCodes.Conv_I4);
            il.Emit(OpCodes.Brtrue, valueHasElementsLabel);

            il.MarkLabel(valueIsNullOrEmptyLabel);            // label valueIsNullOrEmptyLabel
            il.Emit_Ldc_I4(sizeof(int));                      // stack_0 = sizeof(int)
            il.Emit(OpCodes.Br, endOfMethodLabel);            // goto endOfMethodLabel

            il.MarkLabel(valueHasElementsLabel);              // label valueHasElementsLabel
            il.Emit_Ldc_I4(0);                                // i = 0
            il.Emit(OpCodes.Stloc, iVar);
            il.Emit_Ldc_I4(sizeof(int));                      // sum = sizeof(int)
            il.Emit(OpCodes.Stloc, sumVar);
            il.Emit(OpCodes.Br, loopConditionLabel);          // goto loopConditionLabel

            il.MarkLabel(loopStartLabel);                     // label loopStartLabel
            il.Emit(OpCodes.Ldloc, sumVar);                   // stack_0 = sum
            emitLoad(il);                                     // elem = value[i]
            il.Emit(OpCodes.Ldloc, iVar);
            EmitLdelem(il);
            il.Emit(OpCodes.Stloc, elemVar);
            elementCodec.EmitCalculateSize(il, elemVar);      // stack_1 = CalculateSize(elem)
            il.Emit(OpCodes.Add);                             // sum = stack_0 + stack_1
            il.Emit(OpCodes.Stloc, sumVar);
            il.Emit(OpCodes.Ldloc, iVar);                     // i++
            il.Emit_Ldc_I4(1);
            il.Emit(OpCodes.Add);
            il.Emit(OpCodes.Stloc, iVar);

            il.MarkLabel(loopConditionLabel);                 // label loopConditionLabel
            il.Emit(OpCodes.Ldloc, iVar);                     // if (i < (int)value.Length)
            emitLoad(il);                                     //     goto loopStartLabel
            il.Emit(OpCodes.Ldlen);
            il.Emit(OpCodes.Conv_I4);
            il.Emit(OpCodes.Blt, loopStartLabel);

            il.Emit(OpCodes.Ldloc, sumVar);                   // stack_0 = sum
            il.MarkLabel(endOfMethodLabel);                   // label endOfMethodLabel
        }
开发者ID:Eisenstein,项目名称:SharpRPC,代码行数:55,代码来源:ReferenceArrayCodec.cs

示例6: GetLocalBuilder

		private LocalBuilder GetLocalBuilder(ILGenerator ilg) {
			if (localBuilder == null) {
				if (Type == Typ.Number) {
					this.localBuilder = ilg.DeclareLocal(typeof (double));
				}
				else {
					this.localBuilder = ilg.DeclareLocal(Value.type);
				}
			}
			return localBuilder;
		}
开发者ID:josiahdj,项目名称:SDFCalc,代码行数:11,代码来源:LocalVariable.cs

示例7: GenerateMethodBody

        private void GenerateMethodBody(ILGenerator generator, Jace.Execution.ParameterInfo[] parameters,
            Func<Dictionary<string, double>, double> function)
        {
            Type dictionaryType = typeof(Dictionary<string, double>);
            ConstructorInfo dictionaryConstructorInfo = dictionaryType.GetConstructor(Type.EmptyTypes);

            FieldInfo functionField = typeof(FuncAdapterArguments).GetField("function",
                BindingFlags.NonPublic | BindingFlags.Instance);

            generator.DeclareLocal(dictionaryType);
            generator.DeclareLocal(typeof(double));

            generator.Emit(OpCodes.Newobj, dictionaryConstructorInfo);
            generator.Emit(OpCodes.Stloc_0);

            for (int i = 0; i < parameters.Length; i++)
            {
                Jace.Execution.ParameterInfo parameter = parameters[i];

                generator.Emit(OpCodes.Ldloc_0);
                generator.Emit(OpCodes.Ldstr, parameter.Name);

                switch (i)
                {
                    case 0:
                        generator.Emit(OpCodes.Ldarg_1);
                        break;
                    case 1:
                        generator.Emit(OpCodes.Ldarg_2);
                        break;
                    case 2:
                        generator.Emit(OpCodes.Ldarg_3);
                        break;
                    default:
                        generator.Emit(OpCodes.Ldarg, i + 1);
                        break;
                }

                if (parameter.DataType != DataType.FloatingPoint)
                    generator.Emit(OpCodes.Conv_R8);

                generator.Emit(OpCodes.Callvirt, dictionaryType.GetMethod("Add", new Type[] { typeof(string), typeof(double) }));
            }

            generator.Emit(OpCodes.Ldarg_0);
            generator.Emit(OpCodes.Ldfld, functionField);
            generator.Emit(OpCodes.Ldloc_0);
            generator.Emit(OpCodes.Callvirt, function.GetType().GetMethod("Invoke"));

            generator.Emit(OpCodes.Ret);
        }
开发者ID:plurby,项目名称:Jace,代码行数:51,代码来源:FuncAdapter.cs

示例8: Weave

        public void Weave(ILGenerator ilGenerator)
        {
            var typeofType = typeof(Type);
            var typeofObject = typeof(object);
            FieldBuilder contractFieldBuilder = null;
            LocalBuilder typesArrayLocalBuilder = null;
            LocalBuilder tempTypesArrayLocalBuilder = null;
            var typeofArrayOfTypes = typeofType.MakeArrayType();
            var weavingSettings = aspectWeavingSettings.WeavingSettings;
            var getTypeFromHandleMethodInfo = typeofType.GetMethod("GetTypeFromHandle");
            var localBuilderRepository = aspectWeavingSettings.LocalBuilderRepository;

            typesArrayLocalBuilder = localBuilderRepository.Declare(() => {
                return ilGenerator.DeclareLocal(typeofArrayOfTypes);
            });

            tempTypesArrayLocalBuilder = ilGenerator.DeclareLocal(typeofArrayOfTypes);
            ilGenerator.EmitPushInteger(parameters.Length);
            ilGenerator.Emit(OpCodes.Newarr, typeofType);
            ilGenerator.EmitStoreLocal(tempTypesArrayLocalBuilder);

            parameters.ForEach((parameter, i) => {
                var isByRef = parameter.IsByRef;

                if (isByRef) {
                    parameter = parameter.GetElementType();
                }

                ilGenerator.EmitLoadLocal(tempTypesArrayLocalBuilder);
                ilGenerator.EmitPushInteger(i);
                ilGenerator.Emit(OpCodes.Ldtoken, parameter);
                ilGenerator.Emit(OpCodes.Call, getTypeFromHandleMethodInfo);

                if (isByRef) {
                    ilGenerator.Emit(OpCodes.Callvirt, typeofType.GetMethod("MakeByRefType"));
                }

                ilGenerator.Emit(OpCodes.Stelem_Ref);
            });

            ilGenerator.EmitLoadLocal(tempTypesArrayLocalBuilder);
            ilGenerator.EmitStoreLocal(typesArrayLocalBuilder);
            ilGenerator.EmitLoadArg(0);
            contractFieldBuilder = weavingSettings.TypeDefinition.GetFieldBuilder(weavingSettings.ContractType);
            ilGenerator.Emit(OpCodes.Ldfld, contractFieldBuilder);
            ilGenerator.Emit(OpCodes.Callvirt, typeofObject.GetMethod("GetType"));
            ilGenerator.Emit(OpCodes.Ldstr, method.Name);
            ilGenerator.EmitLoadLocal(typesArrayLocalBuilder);
            ilGenerator.Emit(OpCodes.Callvirt, typeofType.GetMethod("GetMethod", new[] { typeof(string), typeof(Type[]) }));
            ilGenerator.EmitStoreLocal(methodLocalBuilder);
        }
开发者ID:sagifogel,项目名称:NCop,代码行数:51,代码来源:AspectArgsMethodWeaver.cs

示例9: WriteDeserializerArray

        static void WriteDeserializerArray(TypeBuilder typeBuilder, ILGenerator il, Type type, int tag, MethodInfo setMethod,
            int? itemLocalIndex = null)
        {
            var itemType = type.GetElementType();

            var lengthLocal = il.DeclareLocal(typeof(int));
            var arrayLocal = il.DeclareLocal(type);
            var itemLocal = il.DeclareLocal(itemType);
            var indexLocal = il.DeclareLocal(typeof(int));
            var startLabel = il.DefineLabel();
            var endLabel = il.DefineLabel();

            il.Emit(OpCodes.Ldarg_2);
            il.Emit(OpCodes.Ldarg_3);
            il.Emit(OpCodes.Ldc_I4, tag);
            il.Emit(OpCodes.Call, GetCollectionLengthMethod);
            il.Emit(OpCodes.Stloc, lengthLocal);
            il.Emit(OpCodes.Ldloc, lengthLocal.LocalIndex);
            il.Emit(OpCodes.Newarr, itemType);
            il.Emit(OpCodes.Stloc, arrayLocal.LocalIndex);

            il.Emit(OpCodes.Ldc_I4_0);
            il.Emit(OpCodes.Stloc, indexLocal.LocalIndex);
            il.Emit(OpCodes.Br, startLabel);
            il.MarkLabel(endLabel);

            WriteDeserializerReadValue(typeBuilder, il, itemType, 1, itemLocal.LocalIndex);

            il.Emit(OpCodes.Ldloc, arrayLocal.LocalIndex);
            il.Emit(OpCodes.Ldloc, indexLocal.LocalIndex);
            il.Emit(OpCodes.Ldloc, itemLocal.LocalIndex);
            il.Emit(OpCodes.Stelem, itemType);

            il.Emit(OpCodes.Ldloc, indexLocal.LocalIndex);
            il.Emit(OpCodes.Ldc_I4_1);
            il.Emit(OpCodes.Add);
            il.Emit(OpCodes.Stloc, indexLocal.LocalIndex);
            il.MarkLabel(startLabel);
            il.Emit(OpCodes.Ldloc, indexLocal.LocalIndex);
            il.Emit(OpCodes.Ldloc, lengthLocal.LocalIndex);
            il.Emit(OpCodes.Blt, endLabel);

            if (itemLocalIndex == null) {
                il.Emit(OpCodes.Ldarg_1);
                il.Emit(OpCodes.Ldloc, arrayLocal.LocalIndex);
                il.Emit(OpCodes.Callvirt, setMethod);
            } else {
                il.Emit(OpCodes.Ldloc, arrayLocal.LocalIndex);
                il.Emit(OpCodes.Stloc, itemLocalIndex.Value);
            }
        }
开发者ID:blooop,项目名称:MessageShark,代码行数:51,代码来源:CustomBinary.IL.Deserialize.cs

示例10: Initialize

		/// <summary>
		/// Initializes the CodeGenerator infrastructure, binds the ILGenerator, 
		/// creates temporaries; resets evaluation condition caches.
		/// Ready to compile a new SDF.
		/// </summary>
		/// <param name="ilg">The ILGenerator used by all compile methods</param>
		public static void Initialize(ILGenerator ilg) {
			CodeGenerate.ilg = ilg;
			numberVariables = new Dictionary<FullCellAddr, Variable>();
			testDouble = ilg.DeclareLocal(typeof (double));
			testValue = ilg.DeclareLocal(Value.type);
			tmpFullCellAddr = ilg.DeclareLocal(FullCellAddr.type);
		}
开发者ID:josiahdj,项目名称:SDFCalc,代码行数:13,代码来源:CodeGenerate.cs

示例11: BuildArguments

        public override LocalBuilder BuildArguments(ILGenerator ilGenerator)
        {
            var aspectArgLocalBuilder = ilGenerator.DeclareLocal(ArgumentType);
            var eventArgumentContract = Member.ToEventArgumentContract();
            var ctorInterceptionArgs = ArgumentType.GetConstructors().Single(ctor => ctor.GetParameters().Length != 0);
            var eventBrokerProperty = eventArgumentContract.GetProperty("EventBroker");
            var eventBrokerType = eventBrokerProperty.PropertyType;
            var handlerType = eventBrokerType.GetGenericArguments().First();
            var parameters = handlerType.GetInvokeMethod().GetParameters();

            ilGenerator.EmitLoadArg(1);
            ilGenerator.Emit(OpCodes.Ldind_Ref);
            ilGenerator.EmitLoadArg(3);
            ilGenerator.Emit(OpCodes.Callvirt, eventArgumentContract.GetProperty("Event").GetGetMethod());
            ilGenerator.EmitLoadArg(3);
            ilGenerator.Emit(OpCodes.Callvirt, eventArgumentContract.GetProperty("Handler").GetGetMethod());
            ilGenerator.Emit(OpCodes.Ldsfld, BindingsDependency);
            ilGenerator.EmitLoadArg(3);
            ilGenerator.Emit(OpCodes.Callvirt, eventBrokerProperty.GetGetMethod());

            parameters.ForEach(1, (arg, i) => {
                var property = ArgumentType.GetProperty("Arg{0}".Fmt(i));

                ilGenerator.EmitLoadArg(3);
                ilGenerator.Emit(OpCodes.Callvirt, property.GetGetMethod());
            });

            ilGenerator.Emit(OpCodes.Newobj, ctorInterceptionArgs);
            ilGenerator.EmitStoreLocal(aspectArgLocalBuilder);

            return aspectArgLocalBuilder;
        }
开发者ID:sagifogel,项目名称:NCop,代码行数:32,代码来源:BindingEventInterceptionArgumentsWeaver.cs

示例12: EmitNullableCast

 protected override void EmitNullableCast(ILGenerator ilGenerator, Type nullableType)
 {
     ilGenerator.DeclareLocal(outputType);
     ilGenerator.Emit(OpCodes.Stloc_0);
     ilGenerator.Emit(OpCodes.Ldloca_S, 0);
     ilGenerator.Emit(OpCodes.Call, nullableType.GetProperty("Value").GetGetMethod());
 }
开发者ID:undeadcat,项目名称:simple-container,代码行数:7,代码来源:UnboxingCaster.cs

示例13: Emit

		public override void Emit(IEasyMember 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);
				}
				
				gen.Emit(OpCodes.Stelem_Ref);
			}

			gen.Emit(OpCodes.Ldloc, local);
		}
开发者ID:ralescano,项目名称:castle,代码行数:31,代码来源:ReferencesToObjectArrayExpression.cs

示例14: GenerateMethod

        public virtual void GenerateMethod(PropertyInfo pi, MethodInfo mi, ILGenerator gen)
        {
            gen.DeclareLocal(typeof(Type));
            gen.EmitLdType(mi.GetGenericArguments()[0]);
            gen.Emit(OpCodes.Stloc_0);

            foreach (var scc in _pcb.ProxyCoderContext.MixinCoderContexts.SelectMany(a => a.SubjectCoderContexts))
            {
                var smes = scc.GetPerSubjectCoder<ISubjectMethodExistsPerSubjectCoder>();
                if (smes==null)
                    continue;

                var falseTarget = gen.DefineLabel();
                gen.Emit(OpCodes.Ldloc_0);
                gen.EmitLdType(scc.SubjectType);
                gen.EmitOpEqualityCall(typeof(Type));
                gen.Emit(OpCodes.Brfalse, falseTarget);
                smes.PutSubjectMethodExistsOnStack(gen);
                // Required for PE Verification
                gen.Emit(OpCodes.Castclass, mi.ReturnType);
                gen.Emit(OpCodes.Ret);
                gen.MarkLabel(falseTarget);
            }

            gen.Emit(OpCodes.Ldnull);
            gen.Emit(OpCodes.Ret);
        }
开发者ID:davidvmckay,项目名称:ProxyFoo,代码行数:27,代码来源:MethodExistsProxyMetaSubjectCoder.cs

示例15: Generate

        public override void Generate(ILGenerator generator, Symbols symbols)
        {
            //Save the previous variables
            var currentVariables = new List<string>();
            foreach (var item in symbols.Variables)
            {
                currentVariables.Add(item.Key);
                generator.Emit(OpCodes.Ldsfld, symbols.Variables[item.Key]);
            }

            DeclarationBlock.Generate(generator, symbols);
            InstructionsBlock.Generate(generator, symbols);

            LocalBuilder returnValue = null;
            if (InstructionsBlock.ExpressionType.Type != TypesEnumeration.Void)
            {
                returnValue = generator.DeclareLocal(symbols.GetRealType(InstructionsBlock.ExpressionType.ILName));
                generator.Emit(OpCodes.Stloc, returnValue);
            }

            currentVariables.Reverse();
            //load in the variables it's previous values
            currentVariables.ForEach(x => generator.Emit(OpCodes.Stsfld, symbols.Variables[x]));
            if (InstructionsBlock.ExpressionType.Type != TypesEnumeration.Void)
                generator.Emit(OpCodes.Ldloc, returnValue);
        }
开发者ID:hansel0691,项目名称:Tiger,代码行数:26,代码来源:LetInEndNode.cs


注:本文中的System.Reflection.Emit.ILGenerator.DeclareLocal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。