Esempio n. 1
0
        internal override void Emit(ILGenerator ilg, bool preserve)
        {
            // Emit nested codeblock
            var source = Token.ToString();
            var dlg    = NestedBinder.Emit(Codeblock, source) as RuntimeCodeblockDelegate;
            var rtc    = new RuntimeCodeblock(dlg, NestedBinder.ParamCount);

            CbList[CbIndex] = new _Codeblock(rtc, source, true, NestedBinder.CreatesAutoVars);

            // Emit code to retrieve codeblock
            var lidx = Constant.Create(CbIndex);

            Symbol.EmitGet(ilg);
            lidx.EmitGet(ilg);
            ilg.Emit(OpCodes.Ldelem, Datatype.Type);
            if (!preserve)
            {
                ilg.Emit(OpCodes.Pop);
            }
        }
Esempio n. 2
0
        internal override void Emit(ILGenerator ilg, bool preserve)
        {
            // Emit nested codeblock
            var source = Token.ToString();

            if (usualMacro)
            {
                var dlg = NestedBinder.Emit(Codeblock, source) as UsualMacro.MacroCodeblockDelegate;
                if (NestedBinder.CreatesAutoVars)
                {
                    CbList[CbIndex] = new UsualMacro.MacroMemVarCodeblock(dlg, NestedBinder.ParamCount, source, true);
                }
                else
                {
                    CbList[CbIndex] = new UsualMacro.MacroCodeblock(dlg, NestedBinder.ParamCount, source, true);
                }
            }
            else
            {
                var        dlg = NestedBinder.Emit(Codeblock, source) as ObjectMacro.MacroCodeblockDelegate;
                ICodeblock rtc = NestedBinder.CreatesAutoVars ? new ObjectMacro.MacroMemVarCodeblock(dlg, NestedBinder.ParamCount)
                                                              : new ObjectMacro.MacroCodeblock(dlg, NestedBinder.ParamCount);
                CbList[CbIndex] = new _Codeblock(rtc, source, true, false);
            }

            // Emit code to retrieve codeblock
            var lidx = Constant.Create(CbIndex);

            Symbol.EmitGet(ilg);
            lidx.EmitGet(ilg);
            ilg.Emit(OpCodes.Ldelem, Datatype.Type);
            if (!preserve)
            {
                ilg.Emit(OpCodes.Pop);
            }
        }