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


C# Emit.LocalBuilder类代码示例

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


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


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