本文整理汇总了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;
}
示例2: DefineLocalVariable
public static void DefineLocalVariable (string name, LocalBuilder builder)
{
if (symwriter != null) {
int index = MonoDebuggerSupport.GetLocalIndex (builder);
symwriter.DefineLocalVariable (index, name);
}
}
示例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);
}
示例4: AspectArgsMethodWeaver
internal AspectArgsMethodWeaver(MethodInfo method, LocalBuilder methodLocalBuilder, Type[] parameters, IAspectWeavingSettings aspectWeavingSettings)
{
this.method = method;
this.parameters = parameters;
this.methodLocalBuilder = methodLocalBuilder;
this.aspectWeavingSettings = aspectWeavingSettings;
}
示例5: ILForLoop
public ILForLoop(Label conditionLabel, Label startLoopLogicLabel, LocalBuilder counter, LocalBuilder max)
{
ConditionLabel = conditionLabel;
Counter = counter;
Max = max;
StartLoopLogicLabel = startLoopLogicLabel;
}
示例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);
}
示例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);
}
示例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) }));
}
示例9: ForState
internal ForState(LocalBuilder indexVar, Label beginLabel, Label testLabel, object end)
{
this.indexVar = indexVar;
this.beginLabel = beginLabel;
this.testLabel = testLabel;
this.end = end;
}
示例10: InitializeInvokerArgumentArrayStatement
public InitializeInvokerArgumentArrayStatement(
LocalBuilder argumentArrayLocal,
ParameterInfo[] parameters)
{
_argumentArrayLocal = argumentArrayLocal;
_parameters = parameters;
}
示例11: MethodCallExpression
public MethodCallExpression(LocalBuilder instance, string methodName, params object[] args)
: base(args)
{
_instance = new Variable(instance);
_methodName = methodName;
LookupMethod(instance.LocalType, methodName);
}
示例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);
}
}
示例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);
}
示例14: Emit
internal override void Emit (EmitContext ec, LocalBuilder local)
{
var member = EmitLoadMember (ec, local);
foreach (var binding in bindings)
binding.Emit (ec, member);
}
示例15: StoreOutArgumentsStatement
public StoreOutArgumentsStatement(
LocalBuilder argumentArrayLocal,
ParameterInfo[] parameters)
{
_argumentArrayLocal = argumentArrayLocal;
_parameters = parameters;
}