本文整理汇总了C#中CodeGen.EmitSymbolId方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.EmitSymbolId方法的具体用法?C# CodeGen.EmitSymbolId怎么用?C# CodeGen.EmitSymbolId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.EmitSymbolId方法的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: EmitGet
public override void EmitGet(CodeGen cg)
{
// RuntimeHelpers.LookupName(context, name)
_frame.EmitGet(cg);
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "LookupName");
}
示例3: Emit
public override void Emit(CodeGen cg)
{
// RuntimeHelpers.RemoveName(CodeContext, name)
cg.EmitCodeContext();
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "RemoveName");
}
示例4: Emit
public override void Emit(CodeGen cg) {
//EmitLocation(cg);
_value.EmitAsObject(cg);
cg.EmitCodeContext();
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "SetNameReorder");
}
示例5: 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");
}
示例6: 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);
}
示例7: 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);
}
示例8: Emit
// ***WITH STATEMENT CODE GENERATION ALGORITHM***
//
//GRAMMAR :=
//with EXPR as VAR:
// BLOCK
//
//CODE GEN :=
//
//mgr = (EXPR)
//exit = mgr.__exit__ # Not calling it yet
//value = mgr.__enter__()
//exc = True
//isTryYielded = False
//try:
//
// VAR = value # Only if "as VAR" is present
// BLOCK
// // if yield happens in the Block,
// // then isTryYielded is set to True by Yield's Code Gen
//except:
// # The exceptional case is handled here
// exc = False
// if not exit(*sys.exc_info()):
// raise
// # The exception is consumed if exit() returns true
//finally:
// # The normal and non-local-goto cases are handled here
// if isTryYielded = False && exc == True :
// exit(None, None, None)
internal override void Emit(CodeGen cg)
{
Slot exc = null;
Slot isTryYielded = null;
Slot exit = null;
if (cg.IsGenerator()) {
exc = cg.Names.GetTempSlot("with", typeof(object));
isTryYielded = cg.Names.GetTempSlot("with", typeof(object));
exit = cg.Names.GetTempSlot("with", typeof(object));
} else {
exc = cg.GetLocalTmp(typeof(object));
isTryYielded = cg.GetLocalTmp(typeof(object));
exit = cg.GetLocalTmp(typeof(object));
}
// mgr = (EXPR)
Slot mgr = cg.GetLocalTmp(typeof(object));
contextManager.Emit(cg);
mgr.EmitSet(cg);
// exit = mgr.__exit__ # not calling it yet
cg.EmitCallerContext();
mgr.EmitGet(cg);
cg.EmitSymbolId("__exit__");
cg.EmitCall(typeof(Ops), "GetAttr");
exit.EmitSet(cg);
mgr.EmitGet(cg);
cg.FreeLocalTmp(mgr);
cg.EmitSymbolId("__enter__");
cg.EmitObjectArray(new Expression[0]);
cg.EmitCall(typeof(Ops), "Invoke", new Type[] { typeof(object), typeof(SymbolId), typeof(object[]) });
Slot value = cg.GetLocalTmp(typeof(object));
value.EmitSet(cg);
// exc = True
cg.EmitConstantBoxed(true);
exc.EmitSet(cg);
Slot choiceVar = null;
if (yieldTargets != null && yieldTargets.Count > 0) {
Label startOfBlock = cg.DefineLabel();
choiceVar = cg.GetLocalTmp(typeof(int));
cg.EmitInt(-1);
choiceVar.EmitSet(cg);
cg.Emit(OpCodes.Br, startOfBlock);
int index = 0;
foreach (YieldTarget yt in yieldTargets) {
cg.MarkLabel(yt.TopBranchTarget);
cg.EmitInt(index++);
choiceVar.EmitSet(cg);
cg.Emit(OpCodes.Br, startOfBlock);
}
cg.MarkLabel(startOfBlock);
}
cg.EmitConstantBoxed(false);
isTryYielded.EmitSet(cg);
Label beforeFinally = cg.DefineLabel();
cg.PushWithTryBlock(isTryYielded);
cg.BeginExceptionBlock();
if (yieldTargets != null && yieldTargets.Count > 0) {
int index = 0;
foreach (YieldTarget yt in yieldTargets) {
//.........这里部分代码省略.........
示例9: EmitGet
public override void EmitGet(CodeGen cg)
{
frame.EmitGet(cg);
cg.EmitSymbolId(name);
cg.EmitCall(typeof(ModuleScope), "GetLocal");
}
示例10: EmitSet
internal override void EmitSet(CodeGen cg)
{
target.Emit(cg);
cg.EmitSymbolId(name);
cg.EmitCallerContext();
cg.EmitCall(typeof(Ops), "SetAttrStackHelper");
}
示例11: EmitDel
internal override void EmitDel(CodeGen cg)
{
cg.EmitCallerContext();
target.Emit(cg);
cg.EmitSymbolId(name);
cg.EmitCall(typeof(Ops), "DelAttr");
}
示例12: Emit
internal override void Emit(CodeGen cg)
{
cg.EmitCallerContext();
target.Emit(cg);
cg.EmitSymbolId(name);
cg.EmitCall(typeof(Ops), "GetAttr"); //, new Type[] { typeof(object), typeof(SymbolId) });
}
示例13: EmitSet
public override void EmitSet(CodeGen cg, Slot val)
{
// Emit the following:
// frame.SetLocal(symbol_id, val)
frame.EmitGet(cg);
cg.EmitSymbolId(name);
val.EmitGet(cg);
cg.EmitCall(typeof(ModuleScope), "SetLocal");
}
示例14: EmitCreation
public override void EmitCreation(CodeGen cg)
{
if (cg.IsDynamicMethod)
{
throw new NotSupportedException("no can do");
}
else
{
var tg = cg.TypeGen;
var ag = tg.AssemblyGen;
index = tg.ConstantCounter;
var snippets = ScriptDomainManager.CurrentManager.Snippets;
if (snippets.Assembly == ag || snippets.DebugAssembly == ag)
{
var sym = Runtime.Builtins.GenSym("s11n:" + index);
Runtime.Builtins.SetSymbolValueFast(sym, value);
cg.EmitSymbolId((SymbolId) sym);
cg.EmitCall(typeof(Runtime.Builtins), "SymbolValue");
}
else
{
fs = tg.AddStaticField(typeof(object), "s11n:" + index) as StaticFieldSlot;
tg.SerializedConstants.Add(this);
var tcg = tg.TypeInitializer;
if (index == 0)
{
arrloc = tcg.DeclareLocal(typeof(object[]));
// first
// setup deserializtion to array, then assign to fields
tcg.EmitType(tg.TypeBuilder);
tcg.EmitCall(typeof(Runtime.Helpers), "DeserializeAssemblyConstants");
tcg.Emit(OpCodes.Stloc, arrloc);
tg.CreatingType += (sender, ea) =>
{
var constants = new List<object>();
foreach (SerializedConstant sc in tg.SerializedConstants)
{
constants.Add(sc.value);
}
var constantsarray = constants.ToArray();
MemoryStream s = new MemoryStream();
bf.Serialize(s, constantsarray);
s.Position = 0;
totallength += s.Length;
var mb = tg.TypeBuilder.Module as ModuleBuilder;
if (compress)
{
var cms = new MemoryStream();
var cs = new System.IO.Compression.GZipStream(cms, System.IO.Compression.CompressionMode.Compress, true);
var content = s.ToArray();
cs.Write(content, 0, content.Length);
cs.Close();
mb.DefineManifestResource("SerializedConstants.gz", cms, System.Reflection.ResourceAttributes.Public);
}
else
{
mb.DefineManifestResource("SerializedConstants", s, System.Reflection.ResourceAttributes.Public);
}
};
}
tcg.Emit(OpCodes.Ldloc, ((SerializedConstant) tg.SerializedConstants[0]).arrloc);
tcg.EmitInt(index);
tcg.Emit(OpCodes.Ldelem_Ref);
fs.EmitSet(tcg);
fs.EmitGet(cg);
}
tg.ConstantCounter++;
}
}
示例15: EmitDelete
public override void EmitDelete(CodeGen cg, SymbolId name, bool check)
{
// Emit the following:
// frame.DelLocal(symbol_id)
frame.EmitGet(cg);
cg.EmitSymbolId(name);
cg.EmitCall(typeof(ModuleScope), "DelLocal");
}