本文整理汇总了C#中CodeGen.EmitCall方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.EmitCall方法的具体用法?C# CodeGen.EmitCall怎么用?C# CodeGen.EmitCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.EmitCall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit(CodeGen cg) {
// RuntimeHelpers.LookupName(CodeContext, name)
cg.EmitCodeContext();
cg.EmitSymbolId(_name);
cg.EmitUnbox(typeof(SymbolId));
cg.EmitCall(typeof(RuntimeHelpers), "LookupName");
}
示例2: Emit
public override void Emit(CodeGen cg)
{
// RuntimeHelpers.RemoveName(CodeContext, name)
cg.EmitCodeContext();
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "RemoveName");
}
示例3: Emit
public override void Emit(CodeGen cg) {
//EmitLocation(cg);
_value.EmitAsObject(cg);
cg.EmitCodeContext();
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "SetNameReorder");
}
示例4: Emit
public override void Emit(CodeGen cg) {
// emit "this", if any
EmitInstance(cg);
if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
{
cg.EmitConstant(SpanToLong(Span));
cg.EmitCall(Debugging.DebugMethods.ExpressionIn);
}
EmitLocation(cg);
switch (_member.MemberType) {
case MemberTypes.Field:
FieldInfo field = (FieldInfo)_member;
cg.EmitFieldGet(field);
break;
case MemberTypes.Property:
PropertyInfo property = (PropertyInfo)_member;
cg.EmitPropertyGet(property);
break;
default:
Debug.Assert(false, "Invalid member type");
break;
}
if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
{
cg.EmitConstant(SpanToLong(Span));
cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
}
}
示例5: EmitGet
public override void EmitGet(CodeGen cg)
{
// RuntimeHelpers.LookupName(context, name)
_frame.EmitGet(cg);
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "LookupName");
}
示例6: FixReturn
public void FixReturn(CodeGen cg)
{
_argSlot.EmitGet(cg);
_refSlot.EmitGet(cg);
cg.EmitCall(typeof(BinderOps).GetMethod("GetBox").MakeGenericMethod(_argSlot.Type.GetElementType()));
cg.EmitStoreValueIndirect(_argSlot.Type.GetElementType());
}
示例7: EmitDelete
public override void EmitDelete(CodeGen cg, SymbolId name, bool check)
{
// Emit the following:
// RuntimeHelpers.RemoveName(context, symbol_id)
_frame.EmitGet(cg);
cg.EmitSymbolId(name);
cg.EmitCall(typeof(RuntimeHelpers), "RemoveName");
cg.Emit(OpCodes.Pop);
}
示例8: EmitDelete
public override void EmitDelete(CodeGen cg, SymbolId name, bool check)
{
//
// RuntimeHelpers.DeleteGlobalName(context, name)
//
_frame.EmitGet(cg);
cg.EmitSymbolId(name);
cg.EmitCall(typeof(RuntimeHelpers), "RemoveGlobalName");
}
示例9: Emit
internal override void Emit(CodeGen cg)
{
left.Emit(cg);
cg.Emit(OpCodes.Dup);
cg.EmitCall(typeof(Ops), "IsTrue");
//cg.emitNonzero(left);
Label l = cg.DefineLabel();
cg.Emit(OpCodes.Brfalse, l);
cg.Emit(OpCodes.Pop);
right.Emit(cg);
cg.MarkLabel(l);
}
示例10: Emit
public override void Emit(CodeGen cg) {
Slot tempContext = cg.ContextSlot;
Slot newContext = cg.GetLocalTmp(typeof(CodeContext));
_scope.Emit(cg); //Locals dictionary
cg.EmitCodeContext(); //CodeContext
//cg.EmitBoolean(true); //Visible = true
cg.EmitCall(typeof(RuntimeHelpers), "CreateNestedCodeContext");
newContext.EmitSet(cg);
cg.ContextSlot = newContext;
_body.Emit(cg);
cg.ContextSlot = tempContext;
}
示例11: EmitClrCallStub
/// <summary>
/// Generates stub to receive the CLR call and then call the dynamic language code.
/// </summary>
public static void EmitClrCallStub(CodeGen cg, Slot callTarget, int firstArg, CallType functionAttributes) {
List<ReturnFixer> fixers = new List<ReturnFixer>(0);
IList<Slot> args = cg.ArgumentSlots;
int nargs = args.Count - firstArg;
CallAction action;
if ((functionAttributes & CallType.ArgumentList) != 0) {
ArgumentInfo[] infos = CompilerHelpers.MakeRepeatedArray(ArgumentInfo.Simple, nargs);
infos[nargs - 1] = new ArgumentInfo(ArgumentKind.List);
action = CallAction.Make(new CallSignature(infos));
} else {
action = CallAction.Make(nargs);
}
bool fast;
Slot site = cg.CreateDynamicSite(action,
CompilerHelpers.MakeRepeatedArray(typeof(object), nargs + 2),
out fast);
site.EmitGet(cg);
if (!fast) cg.EmitCodeContext();
if (DynamicSiteHelpers.IsBigTarget(site.Type)) {
cg.EmitTuple(site.Type.GetGenericArguments()[0], args.Count + 1, delegate(int index) {
if (index == 0) {
callTarget.EmitGet(cg);
} else {
ReturnFixer rf = ReturnFixer.EmitArgument(cg, args[index - 1]);
if (rf != null) fixers.Add(rf);
}
});
} else {
callTarget.EmitGet(cg);
for (int i = firstArg; i < args.Count; i++) {
ReturnFixer rf = ReturnFixer.EmitArgument(cg, args[i]);
if (rf != null) fixers.Add(rf);
}
}
cg.EmitCall(site.Type, "Invoke");
foreach (ReturnFixer rf in fixers) {
rf.FixReturn(cg);
}
cg.EmitReturnFromObject();
}
示例12: EmitLocation
protected override void EmitLocation(CodeGen cg)
{
if (ScriptDomainManager.Options.LightweightDebugging)
{
if (!cg.IsDynamicMethod)
{
var s = SpanToLong(Span);
cg.EmitConstant(s);
cg.EmitCall(Debugging.DebugMethods.ExpressionIn);
}
}
else
{
base.EmitLocation(cg);
}
}
示例13: EmitGet
public override void EmitGet(CodeGen cg)
{
Contract.RequiresNotNull(cg, "cg");
MethodInfo method = _property.GetGetMethod();
Debug.Assert(method != null, "Cannot set property");
Debug.Assert(method.GetParameters().Length == 0, "Wrong number of parameters on the property getter");
// Emit instance
if (!method.IsStatic) {
Debug.Assert(_instance != null, "need instance slot for instance property");
_instance.EmitGet(cg);
}
// Emit call
cg.EmitCall(method);
}
示例14: EmitCheck
public virtual void EmitCheck(CodeGen cg, SymbolId name)
{
Contract.RequiresNotNull(cg, "cg");
Label endCheck = cg.DefineLabel();
cg.Emit(OpCodes.Dup);
cg.EmitUninitialized();
cg.Emit(OpCodes.Bne_Un_S, endCheck);
if (_local) {
cg.EmitSymbolId(name);
cg.EmitUnbox(typeof(SymbolId));
cg.EmitCall(typeof(RuntimeHelpers), "ThrowUnboundLocalError");
} else {
cg.Emit(OpCodes.Pop);
cg.EmitCodeContext();
cg.EmitSymbolId(name);
cg.EmitUnbox(typeof(SymbolId));
cg.EmitCall(typeof(RuntimeHelpers), "LookupName");
}
cg.MarkLabel(endCheck);
}
示例15: Emit
internal override void Emit(CodeGen cg)
{
Label eol = cg.DefineLabel();
Label breakTarget = cg.DefineLabel();
Label continueTarget = cg.DefineLabel();
cg.EmitPosition(Start, header);
list.Emit(cg);
cg.EmitCall(typeof(Ops), "GetEnumeratorForIteration");
Slot iter;
if (cg.IsGenerator()) {
iter = cg.Names.GetTempSlot("iter", typeof(IEnumerator));
} else {
iter = cg.GetLocalTmp(typeof(IEnumerator));
}
iter.EmitSet(cg);
cg.MarkLabel(continueTarget);
iter.EmitGet(cg);
cg.EmitCall(typeof(IEnumerator), "MoveNext");
cg.Emit(OpCodes.Brfalse, eol);
cg.PushTargets(breakTarget, continueTarget);
iter.EmitGet(cg);
cg.EmitCall(typeof(IEnumerator).GetProperty("Current").GetGetMethod());
lhs.EmitSet(cg);
body.Emit(cg);
cg.Emit(OpCodes.Br, continueTarget);
cg.PopTargets();
cg.MarkLabel(eol);
if (elseStmt != null) {
elseStmt.Emit(cg);
}
cg.MarkLabel(breakTarget);
if (!cg.IsGenerator()) {
cg.FreeLocalTmp(iter);
}
}