本文整理汇总了C#中IKVM.Internal.CodeEmitter类的典型用法代码示例。如果您正苦于以下问题:C# CodeEmitter类的具体用法?C# CodeEmitter怎么用?C# CodeEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeEmitter类属于IKVM.Internal命名空间,在下文中一共展示了CodeEmitter类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Emit
internal static bool Emit(DynamicTypeWrapper.FinishContext context, TypeWrapper wrapper, CodeEmitter ilgen, ClassFile classFile, int i, ClassFile.Method.Instruction[] code, InstructionFlags[] flags)
{
if (i >= 3
&& (flags[i - 0] & InstructionFlags.BranchTarget) == 0
&& (flags[i - 1] & InstructionFlags.BranchTarget) == 0
&& (flags[i - 2] & InstructionFlags.BranchTarget) == 0
&& (flags[i - 3] & InstructionFlags.BranchTarget) == 0
&& code[i - 1].NormalizedOpCode == NormalizedByteCode.__ldc
&& code[i - 2].NormalizedOpCode == NormalizedByteCode.__ldc
&& code[i - 3].NormalizedOpCode == NormalizedByteCode.__ldc)
{
// we now have a structural match, now we need to make sure that the argument values are what we expect
TypeWrapper tclass = classFile.GetConstantPoolClassType(code[i - 3].Arg1);
TypeWrapper vclass = classFile.GetConstantPoolClassType(code[i - 2].Arg1);
string fieldName = classFile.GetConstantPoolConstantString(code[i - 1].Arg1);
if (tclass == wrapper && !vclass.IsUnloadable && !vclass.IsPrimitive && !vclass.IsNonPrimitiveValueType)
{
FieldWrapper field = wrapper.GetFieldWrapper(fieldName, vclass.SigName);
if (field != null && !field.IsStatic && field.IsVolatile && field.DeclaringType == wrapper && field.FieldTypeWrapper == vclass)
{
// everything matches up, now call the actual emitter
DoEmit(context, wrapper, ilgen, field);
return true;
}
}
}
return false;
}
开发者ID:samskivert,项目名称:ikvm-monotouch,代码行数:28,代码来源:atomic.cs
示例2: DoEmit
private static void DoEmit(DynamicTypeWrapper.FinishContext context, TypeWrapper wrapper, CodeEmitter ilgen, FieldWrapper field)
{
ConstructorBuilder cb;
bool exists;
lock (map)
{
exists = map.TryGetValue(field, out cb);
}
if (!exists)
{
// note that we don't need to lock here, because we're running as part of FinishCore, which is already protected by a lock
TypeWrapper arfuTypeWrapper = ClassLoaderWrapper.LoadClassCritical("ikvm.internal.IntrinsicAtomicReferenceFieldUpdater");
TypeBuilder tb = wrapper.TypeAsBuilder.DefineNestedType("__<ARFU>_" + field.Name + field.Signature.Replace('.', '/'), TypeAttributes.NestedPrivate | TypeAttributes.Sealed, arfuTypeWrapper.TypeAsBaseType);
EmitCompareAndSet("compareAndSet", tb, field.GetField());
EmitGet(tb, field.GetField());
EmitSet("set", tb, field.GetField());
cb = tb.DefineConstructor(MethodAttributes.Assembly, CallingConventions.Standard, Type.EmptyTypes);
lock (map)
{
map.Add(field, cb);
}
CodeEmitter ctorilgen = CodeEmitter.Create(cb);
ctorilgen.Emit(OpCodes.Ldarg_0);
MethodWrapper basector = arfuTypeWrapper.GetMethodWrapper("<init>", "()V", false);
basector.Link();
basector.EmitCall(ctorilgen);
ctorilgen.Emit(OpCodes.Ret);
context.RegisterPostFinishProc(delegate
{
arfuTypeWrapper.Finish();
tb.CreateType();
});
}
ilgen.LazyEmitPop();
ilgen.LazyEmitPop();
ilgen.LazyEmitPop();
ilgen.Emit(OpCodes.Newobj, cb);
}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:39,代码来源:atomic.cs
示例3: Emit
internal static bool Emit(DynamicTypeWrapper.FinishContext context, ClassFile classFile, int constantPoolIndex, ClassFile.ConstantPoolItemInvokeDynamic cpi, CodeEmitter ilgen)
{
ClassFile.BootstrapMethod bsm = classFile.GetBootstrapMethod(cpi.BootstrapMethod);
if (!IsLambdaMetafactory(classFile, bsm) && !IsLambdaAltMetafactory(classFile, bsm))
{
return false;
}
LambdaMetafactory lmf = context.GetValue<LambdaMetafactory>(constantPoolIndex);
if (lmf.ctor == null && !lmf.EmitImpl(context, classFile, cpi, bsm, ilgen))
{
#if STATIC_COMPILER
if (context.TypeWrapper.GetClassLoader().DisableDynamicBinding)
{
StaticCompiler.IssueMessage(Message.UnableToCreateLambdaFactory);
}
#endif
return false;
}
ilgen.Emit(OpCodes.Newobj, lmf.ctor);
// the CLR verification rules about type merging mean we have to explicitly cast to the interface type here
ilgen.Emit(OpCodes.Castclass, cpi.GetRetType().TypeAsBaseType);
return true;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:23,代码来源:LambdaMetafactory.cs
示例4: EmitNewobj
internal virtual void EmitNewobj(CodeEmitter ilgen)
{
throw new InvalidOperationException();
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:4,代码来源:MemberWrapper.cs
示例5: EmitSetImpl
protected override void EmitSetImpl(CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Call, setter);
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:4,代码来源:MemberWrapper.cs
示例6: EmitGetImpl
protected override void EmitGetImpl(CodeEmitter ilgen)
{
// Reading a field should trigger the cctor, but since we're inlining the value
// we have to trigger it explicitly
DeclaringType.EmitRunClassConstructor(ilgen);
// NOTE even though you're not supposed to access a constant static final (the compiler is supposed
// to inline them), we have to support it (because it does happen, e.g. if the field becomes final
// after the referencing class was compiled, or when we're accessing an unsigned primitive .NET field)
object v = GetConstantValue();
if(v == null)
{
ilgen.Emit(OpCodes.Ldnull);
}
else if(constant is int ||
constant is short ||
constant is ushort ||
constant is byte ||
constant is sbyte ||
constant is char ||
constant is bool)
{
ilgen.Emit(OpCodes.Ldc_I4, ((IConvertible)constant).ToInt32(null));
}
else if(constant is string)
{
ilgen.Emit(OpCodes.Ldstr, (string)constant);
}
else if(constant is float)
{
ilgen.Emit(OpCodes.Ldc_R4, (float)constant);
}
else if(constant is double)
{
ilgen.Emit(OpCodes.Ldc_R8, (double)constant);
}
else if(constant is long)
{
ilgen.Emit(OpCodes.Ldc_I8, (long)constant);
}
else if(constant is uint)
{
ilgen.Emit(OpCodes.Ldc_I4, unchecked((int)((IConvertible)constant).ToUInt32(null)));
}
else if(constant is ulong)
{
ilgen.Emit(OpCodes.Ldc_I8, unchecked((long)(ulong)constant));
}
else
{
throw new InvalidOperationException(constant.GetType().FullName);
}
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:53,代码来源:MemberWrapper.cs
示例7: NewobjImpl
protected override void NewobjImpl(CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Newobj, (ConstructorInfo)GetMethod());
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:4,代码来源:MemberWrapper.cs
示例8: CallImpl
protected override void CallImpl(CodeEmitter ilgen)
{
ilgen.Emit(OpCodes.Call, (ConstructorInfo)GetMethod());
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:4,代码来源:MemberWrapper.cs
示例9: CallvirtImpl
protected override void CallvirtImpl(CodeEmitter ilgen)
{
ilgen.Emit(SimpleOpCodeToOpCode(callvirt), (MethodInfo)GetMethod());
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:4,代码来源:MemberWrapper.cs
示例10: EmitCallvirt
internal override void EmitCallvirt(CodeEmitter ilgen)
{
ilgen.Emit(SimpleOpCodeToOpCode(callvirt), (MethodInfo)GetMethod());
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:4,代码来源:MemberWrapper.cs
示例11: EmitThrowNoSuchMethodErrorForGetter
internal static void EmitThrowNoSuchMethodErrorForGetter(CodeEmitter ilgen, TypeWrapper type, bool isStatic)
{
// HACK the branch around the throw is to keep the verifier happy
CodeEmitterLabel label = ilgen.DefineLabel();
ilgen.Emit(OpCodes.Ldc_I4_0);
ilgen.Emit(OpCodes.Brtrue_S, label);
ilgen.EmitThrow("java.lang.NoSuchMethodError");
ilgen.MarkLabel(label);
if (!isStatic)
{
ilgen.Emit(OpCodes.Pop);
}
ilgen.Emit(OpCodes.Ldloc, ilgen.DeclareLocal(type.TypeAsLocalOrStackType));
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:14,代码来源:MemberWrapper.cs
示例12: EmitThrowNoSuchMethodErrorForSetter
internal static void EmitThrowNoSuchMethodErrorForSetter(CodeEmitter ilgen, bool isStatic)
{
// HACK the branch around the throw is to keep the verifier happy
CodeEmitterLabel label = ilgen.DefineLabel();
ilgen.Emit(OpCodes.Ldc_I4_0);
ilgen.Emit(OpCodes.Brtrue_S, label);
ilgen.EmitThrow("java.lang.NoSuchMethodError");
ilgen.MarkLabel(label);
ilgen.Emit(OpCodes.Pop);
if (!isStatic)
{
ilgen.Emit(OpCodes.Pop);
}
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:14,代码来源:MemberWrapper.cs
示例13: EmitSet
internal void EmitSet(CodeEmitter ilgen)
{
AssertLinked();
EmitSetImpl(ilgen);
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:5,代码来源:MemberWrapper.cs
示例14: EmitCallvirtReflect
internal virtual void EmitCallvirtReflect(CodeEmitter ilgen)
{
EmitCallvirt(ilgen);
}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:4,代码来源:MemberWrapper.cs
注:本文中的IKVM.Internal.CodeEmitter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论