当前位置: 首页>>代码示例>>C#>>正文


C# CodeGen.EmitSymbolId方法代码示例

本文整理汇总了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");
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:UnboundExpression.cs

示例2: EmitGet

 public override void EmitGet(CodeGen cg)
 {
     // RuntimeHelpers.LookupName(context, name)
     _frame.EmitGet(cg);
     cg.EmitSymbolId(_name);
     cg.EmitCall(typeof(RuntimeHelpers), "LookupName");
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:LocalNamedFrameSlot.cs

示例3: Emit

 public override void Emit(CodeGen cg)
 {
     // RuntimeHelpers.RemoveName(CodeContext, name)
     cg.EmitCodeContext();
     cg.EmitSymbolId(_name);
     cg.EmitCall(typeof(RuntimeHelpers), "RemoveName");
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:DeleteUnboundExpression.cs

示例4: Emit

 public override void Emit(CodeGen cg) {
   //EmitLocation(cg);
     _value.EmitAsObject(cg);
     cg.EmitCodeContext();
     cg.EmitSymbolId(_name);
     cg.EmitCall(typeof(RuntimeHelpers), "SetNameReorder");
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:UnboundAssignment.cs

示例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");
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:9,代码来源:NamedFrameSlot.cs

示例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);
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:9,代码来源:LocalNamedFrameSlot.cs

示例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);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:21,代码来源:Slot.cs

示例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) {
//.........这里部分代码省略.........
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:101,代码来源:Statements.cs

示例9: EmitGet

 public override void EmitGet(CodeGen cg)
 {
     frame.EmitGet(cg);
     cg.EmitSymbolId(name);
     cg.EmitCall(typeof(ModuleScope), "GetLocal");
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:6,代码来源:Slot.cs

示例10: EmitSet

 internal override void EmitSet(CodeGen cg)
 {
     target.Emit(cg);
     cg.EmitSymbolId(name);
     cg.EmitCallerContext();
     cg.EmitCall(typeof(Ops), "SetAttrStackHelper");
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:7,代码来源:Expressions.cs

示例11: EmitDel

 internal override void EmitDel(CodeGen cg)
 {
     cg.EmitCallerContext();
     target.Emit(cg);
     cg.EmitSymbolId(name);
     cg.EmitCall(typeof(Ops), "DelAttr");
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:7,代码来源:Expressions.cs

示例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) });
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:9,代码来源:Expressions.cs

示例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");
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:9,代码来源:Slot.cs

示例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++;
      }
    }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:91,代码来源:SerializedConstant.cs

示例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");
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:8,代码来源:Slot.cs


注:本文中的CodeGen.EmitSymbolId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。