本文整理汇总了C#中CodeGen.EmitCodeContext方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.EmitCodeContext方法的具体用法?C# CodeGen.EmitCodeContext怎么用?C# CodeGen.EmitCodeContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.EmitCodeContext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
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;
}
示例5: 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();
}
示例6: 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);
}
示例7: Emit
public override void Emit(CodeGen cg) {
cg.EmitCodeContext();
}
示例8: EmitGetStorageFromContext
public override void EmitGetStorageFromContext(CodeGen cg)
{
cg.EmitCodeContext();
cg.EmitPropertyGet(typeof(CodeContext), "Scope");
cg.EmitCall(typeof(RuntimeHelpers).GetMethod("GetStorageData").MakeGenericMethod(StorageType));
}
示例9: Emit
// Action expression is different in that it mutates its
// Type based on the need of the outer codegen.
// Therefore, unless asked explicitly, it will emit itself as object.
public override void Emit(CodeGen cg) {
bool fast;
Slot site = cg.CreateDynamicSite(_action, GetSiteTypes(), out fast);
MethodInfo method = site.Type.GetMethod("Invoke");
Debug.Assert(!method.IsStatic);
// Emit "this" - the site
site.EmitGet(cg);
ParameterInfo[] parameters = method.GetParameters();
int first = 0;
// Emit code context for unoptimized sites only
if (!fast) {
Debug.Assert(parameters[0].ParameterType == typeof(CodeContext));
cg.EmitCodeContext();
// skip the CodeContext parameter
first = 1;
}
if (parameters.Length < _arguments.Count + first) {
// tuple parameters
Debug.Assert(parameters.Length == first + 1);
cg.EmitTuple(site.Type.GetGenericArguments()[0], _arguments.Count, delegate(int index) { _arguments[index].Emit(cg); });
} else {
// Emit the arguments
for (int arg = 0; arg < _arguments.Count; arg++) {
Debug.Assert(parameters[arg + first].ParameterType == _arguments[arg].Type);
_arguments[arg].Emit(cg);
}
}
// Emit the site invoke
cg.EmitCall(site.Type, "Invoke", tailcall);
}