• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Emit.LocalBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



LocalBuilder类属于System.Reflection.Emit命名空间,在下文中一共展示了LocalBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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


示例2: DefineLocalVariable

		public static void DefineLocalVariable (string name, LocalBuilder builder)
		{
			if (symwriter != null) {
				int index = MonoDebuggerSupport.GetLocalIndex (builder);
				symwriter.DefineLocalVariable (index, name);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:symbolwriter.cs


示例3: AddLocalToLocalDictionary

 /// Generates the code that adds an object from a local variable to a dictionary also stored in a local
 /// <param name="ilGenerator"></param>
 /// <param name="dictionary"></param>
 /// <param name="key"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public static void AddLocalToLocalDictionary(this ILGenerator ilGenerator, LocalBuilder dictionary, object key, LocalBuilder value)
 {
     ilGenerator.Emit(OpCodes.Ldloc, dictionary);
     ilGenerator.LoadValue(key);
     ilGenerator.Emit(OpCodes.Ldloc, value);
     ilGenerator.Emit(OpCodes.Callvirt, DictionaryAdd);
 }
开发者ID:tu226,项目名称:Eagle,代码行数:13,代码来源:EmitHelper.cs


示例4: AspectArgsMethodWeaver

 internal AspectArgsMethodWeaver(MethodInfo method, LocalBuilder methodLocalBuilder, Type[] parameters, IAspectWeavingSettings aspectWeavingSettings)
 {
     this.method = method;
     this.parameters = parameters;
     this.methodLocalBuilder = methodLocalBuilder;
     this.aspectWeavingSettings = aspectWeavingSettings;
 }
开发者ID:sagifogel,项目名称:NCop,代码行数:7,代码来源:AspectArgsMethodWeaver.cs


示例5: ILForLoop

 public ILForLoop(Label conditionLabel, Label startLoopLogicLabel, LocalBuilder counter, LocalBuilder max)
 {
     ConditionLabel = conditionLabel;
     Counter = counter;
     Max = max;
     StartLoopLogicLabel = startLoopLogicLabel;
 }
开发者ID:dreasgrech,项目名称:yabfcompiler,代码行数:7,代码来源:ILForLoop.cs


示例6: Emit_IncreasePointer

 public static void Emit_IncreasePointer(this ILGenerator il, LocalBuilder dataPointerVar, LocalBuilder distanceVar)
 {
     il.Emit(OpCodes.Ldloc, dataPointerVar);
     il.Emit(OpCodes.Ldloc, distanceVar);
     il.Emit(OpCodes.Add);
     il.Emit(OpCodes.Stloc, dataPointerVar);
 }
开发者ID:Eisenstein,项目名称:SharpRPC,代码行数:7,代码来源:ILGeneratorExtensions.cs


示例7: CodeCall

 private void CodeCall(FuncCallExpression call, List<LocalVariable> locals, List<GlobalVariable> globals, FuncParam[] parameters, ILGenerator il, List<Function> allFuncs, LocalBuilder tmpVar)
 {
     var func = FindFunc(call, allFuncs);
     foreach (var expression in call.Params)
         CodeExpression(expression, locals, globals, parameters, il, allFuncs, tmpVar);
     il.Emit(OpCodes.Call, func.Info);
 }
开发者ID:nmenshov,项目名称:Iron-C--,代码行数:7,代码来源:CodeGenerator.cs


示例8: SetMemberValue

        public void SetMemberValue(CodeGenerator generator, ArgBuilder targetObject, string memberName, LocalBuilder memberValue)
        {
            generator.Ldarg(targetObject);
            generator.Load(memberName);
            generator.Ldloc(memberValue);

            // Type originalType = memberValue.LocalType.IsEnum ? typeof(int) : memberValue.LocalType;
            if (memberValue.LocalType.IsValueType)
            {
                generator.Box(memberValue.LocalType.IsEnum ? typeof(int) : memberValue.LocalType);
            }
            //���ֵΪ�գ����ܵ���ToString
            generator.Load(null);
            generator.If(Cmp.NotEqualTo);
            generator.Ldloc(memberValue);

            // Type originalType = memberValue.LocalType.IsEnum ? typeof(int) : memberValue.LocalType;
            if (memberValue.LocalType.IsValueType)
            {
                generator.Box(memberValue.LocalType.IsEnum ? typeof(int) : memberValue.LocalType);
            }
            generator.Call(typeof(object).GetMethod("ToString", Type.EmptyTypes));
            generator.Else();
            generator.LoadDefaultValue(memberValue.LocalType);
            if (memberValue.LocalType.IsValueType)
            {
                generator.Box(memberValue.LocalType.IsEnum ? typeof(int) : memberValue.LocalType);
            }
            generator.EndIf();
            generator.Call(typeof(NameValueCollection).GetMethod("Add", new Type[] { typeof(string), typeof(string) }));
        }
开发者ID:Oman,项目名称:Maleos,代码行数:31,代码来源:NameValueSetterGenerator.cs


示例9: ForState

 internal ForState(LocalBuilder indexVar, Label beginLabel, Label testLabel, object end)
 {
     this.indexVar = indexVar;
     this.beginLabel = beginLabel;
     this.testLabel = testLabel;
     this.end = end;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:ForState.cs


示例10: InitializeInvokerArgumentArrayStatement

 public InitializeInvokerArgumentArrayStatement(
     LocalBuilder argumentArrayLocal,
     ParameterInfo[] parameters)
 {
     _argumentArrayLocal = argumentArrayLocal;
     _parameters = parameters;
 }
开发者ID:bradleyjford,项目名称:inception,代码行数:7,代码来源:InitializeInvokerArgumentArrayStatement.cs


示例11: MethodCallExpression

 public MethodCallExpression(LocalBuilder instance, string methodName, params object[] args)
     : base(args)
 {
     _instance = new Variable(instance);
     _methodName = methodName;
     LookupMethod(instance.LocalType, methodName);
 }
开发者ID:einaregilsson,项目名称:Process-Language-Runtime,代码行数:7,代码来源:MethodCallExpression.cs


示例12: if

        void ICanModifyContext.EmitDecls(EmitContext ec)
        {
            object var;

            if ((var = CodeGenerator.variable_defined_in_current_scope (id)) != null) {
                Type t = var.GetType ();
                if (t == typeof (FieldBuilder))
                    field_info = (FieldBuilder) var;
                else if (t == typeof (LocalBuilder))
                    local_builder = (LocalBuilder) var;
                return;
            }

            ILGenerator ig = ec.ig;
            if (parent == null || (parent.GetType () != typeof (FunctionDeclaration)
                           && parent.GetType () != typeof (FunctionExpression))) {
                FieldBuilder field_builder;
                TypeBuilder type_builder  = ec.type_builder;

                field_builder = type_builder.DefineField (id, this.type, FieldAttributes.Public | FieldAttributes.Static);
                TypeManager.Add (id, field_builder);
                field_info = field_builder;
            } else {
                local_builder = ig.DeclareLocal (type);
                TypeManager.Add (id, local_builder);
            }
        }
开发者ID:mayatforest,项目名称:Refractor,代码行数:27,代码来源:VariableDeclaration.cs


示例13: EmitPrivateFieldAssignment

        private void EmitPrivateFieldAssignment(LocalBuilder localbuilder) {
            var fieldInfo = Member as FieldInfo;
            var methodAttributes = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig;
            var methodBuilder = DynamicTypeBuilder.Current.DefineMethod("EmitPrivateFieldAssignment", methodAttributes);
            var methodBuilderILGenerator = methodBuilder.GetILGenerator();

            Type = fieldInfo.FieldType;
            methodBuilder.SetReturnType(Type);
            _assignorExpression.AcceptVisitor(Visitor, methodBuilderILGenerator);

            methodBuilderILGenerator.DeclareLocal(Type);
            methodBuilderILGenerator.Emit(OpCodes.Stloc_1);
            methodBuilderILGenerator.Emit(OpCodes.Ldtoken, Target);
            methodBuilderILGenerator.Emit(OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle"));
            methodBuilderILGenerator.Emit(OpCodes.Ldstr, Member.Name);
            methodBuilderILGenerator.EmitPushInteger(Convert.ToInt32(BindingFlags.NonPublic | BindingFlags.Static));
            methodBuilderILGenerator.Emit(OpCodes.Callvirt, typeof(Type).GetMethod("GetField", new Type[] { TypeSystem.String, typeof(BindingFlags) }));
            methodBuilderILGenerator.Emit(OpCodes.Ldnull);
            methodBuilderILGenerator.Emit(OpCodes.Ldloc_1);
            methodBuilderILGenerator.Emit(OpCodes.Callvirt, typeof(FieldInfo).GetMethod("SetValue", new Type[] { TypeSystem.Object, TypeSystem.Object }));
            methodBuilderILGenerator.Emit(OpCodes.Ldloc_1);
            methodBuilderILGenerator.Emit(OpCodes.Ret);

            ILGenerator.Emit(OpCodes.Call, methodBuilder);
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:25,代码来源:MultipuleAssignmentEmitter.cs


示例14: Emit

		internal override void Emit (EmitContext ec, LocalBuilder local)
		{
			var member = EmitLoadMember (ec, local);

			foreach (var binding in bindings)
				binding.Emit (ec, member);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:MemberMemberBinding.cs


示例15: StoreOutArgumentsStatement

 public StoreOutArgumentsStatement(
     LocalBuilder argumentArrayLocal, 
     ParameterInfo[] parameters)
 {
     _argumentArrayLocal = argumentArrayLocal;
     _parameters = parameters;
 }
开发者ID:bradleyjford,项目名称:inception,代码行数:7,代码来源:StoreOutArgumentsStatement.cs


示例16: Emit_DecreaseInteger

 public static void Emit_DecreaseInteger(this ILGenerator il, LocalBuilder remainingBytesVal, LocalBuilder distanceVar)
 {
     il.Emit(OpCodes.Ldloc, remainingBytesVal);
     il.Emit(OpCodes.Ldloc, distanceVar);
     il.Emit(OpCodes.Sub);
     il.Emit(OpCodes.Stloc, remainingBytesVal);
 }
开发者ID:Eisenstein,项目名称:SharpRPC,代码行数:7,代码来源:ILGeneratorExtensions.cs


示例17: EmitStoreLocalShortTerm

        private static void EmitStoreLocalShortTerm(this ILGenerator ILGenerator, LocalBuilder localBuilder) {
            switch (localBuilder.LocalIndex) {
                case 0:

                    ILGenerator.Emit(OpCodes.Stloc_0);
                    break;

                case 1:

                    ILGenerator.Emit(OpCodes.Stloc_1);
                    break;

                case 2:

                    ILGenerator.Emit(OpCodes.Stloc_2);
                    break;

                case 3:

                    ILGenerator.Emit(OpCodes.Stloc_3);
                    break;

                default:

                    ILGenerator.Emit(OpCodes.Stloc_S, localBuilder);
                    break;
            }
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:28,代码来源:ILGeneratorExtensions.cs


示例18: EmitDecodeAndStore

 protected override void EmitDecodeAndStore(IEmittingContext context, LocalBuilder collectionVar, Action emitLoadIndex, bool doNotCheckBounds)
 {
     var il = context.IL;
     il.Ldloc(collectionVar);
     ElementCodec.EmitDecode(context, doNotCheckBounds);
     il.Callvirt(addMethod);
 }
开发者ID:yonglehou,项目名称:SharpRPC,代码行数:7,代码来源:CollectionCodec.cs


示例19: GetPropertyValue

 public static LocalBuilder GetPropertyValue(this ILGenerator il, PropertyInfo property, LocalBuilder target)
 {
     var x = il.DeclareLocal(property.PropertyType);
     il.LoadPropertyValue(property, target);
     il.SetLocal(x);
     return x;
 }
开发者ID:akarpov89,项目名称:DynamicComparer,代码行数:7,代码来源:GeneratorExtensions.cs


示例20: Emit

		internal override void Emit (EmitContext ec, LocalBuilder local)
		{
			var member = EmitLoadMember (ec, local);

			foreach (var initializer in initializers)
				initializer.Emit (ec, member);
		}
开发者ID:Galigator,项目名称:db4o,代码行数:7,代码来源:MemberListBinding.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Emit.MethodBuilder类代码示例发布时间:2022-05-26
下一篇:
C# Emit.Label类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap