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


C# CodeGen.EmitFieldGet方法代码示例

本文整理汇总了C#中CodeGen.EmitFieldGet方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.EmitFieldGet方法的具体用法?C# CodeGen.EmitFieldGet怎么用?C# CodeGen.EmitFieldGet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeGen的用法示例。


在下文中一共展示了CodeGen.EmitFieldGet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

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

示例2: EmitConvertFromObject

 public override void EmitConvertFromObject(CodeGen cg, Type paramType)
 {
   if (paramType == typeof(void))
   {
     cg.EmitFieldGet(Compiler.Generator.Unspecified);
   }
   else
   {
     cg.EmitCast(typeof(object), paramType);
   }
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:11,代码来源:IronSchemeActionBinder.cs

示例3: EmitYieldDispatch

        private void EmitYieldDispatch(List<YieldTarget> yieldTargets, Slot isYielded, Slot choiceVar, CodeGen cg)
        {
            if (IsBlockYieldable(yieldTargets)) {
                cg.EmitFieldGet(typeof(Ops).GetField("FALSE"));
                isYielded.EmitSet(cg);

                int index = 0;
                foreach (YieldTarget yt in yieldTargets) {
                    choiceVar.EmitGet(cg);
                    cg.EmitInt(index);
                    cg.Emit(OpCodes.Beq, yt.YieldContinuationTarget);
                    index++;
                }
            }
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:15,代码来源:Statements.cs

示例4: Emit

        // codegen algorithm for unified try-catch-else-finally
        //    isTryYielded = false
        //    isCatchYielded = false
        //    isFinallyYielded = false
        //    isElseYielded = false
        //    Set up the labels for Try Yield Targets
        //    Set up the labels for Catch Yield Targets
        //    Set up the labels for Else Yield Targets
        //    Set up the labels for Finally Yield Targets
        //    returnVar = false
        //    isElseBlock = false
        //TRY:
        //    if isCatchYielded :
        //        rethow  storedException
        //    if finallyYielded :
        //        goto endOfTry
        //    if isElseYielded :
        //        goto beginElseBlock
        //    if isTryYielded:
        //        isTryYielded = false
        //        goto desired_label_in_TRY-BODY
        //    TRY-BODY
        //  beginElseBlock: # Note we are still under TRY
        //    isElseBlock = true
        //    if isElseYielded :
        //        isElseYielded  = false
        //        goto desired_label_in_ELSE-BODY
        //    ELSE-BODY
        //  endOfTry:
        //EXCEPT: # catches any exception
        //    if isElseBlock:
        //        rethrow
        //    pyExc = ExtractException()
        //    storedException = ExtractSysExcInfo()
        //    if pyExc == handler[0].Test :
        //        if isCatchYielded :
        //            isCatchYielded  = false
        //            goto desired_label_in_HANDLER-BODY
        //        HANDLER-BODY
        //        ClearException()
        //        Leave afterFinally
        //    elif pyExc == handler[1].Test :
        //        if isCatchYielded :
        //            isCatchYielded  = false
        //            goto desired_label_in_HANDLER-BODY
        //        HANDLER-BODY
        //        ClearException()
        //        Leave afterFinally
        //    .
        //    .
        //    .
        //    Rethrow
        //FINALLY:
        //    if (isTryYielded  or isCatchYielded  or isElseYielded ):
        //        goto endOfFinally
        //    if isFinallyYielded :
        //        isFinallyYielded  = false
        //        goto desired_label_in_FINALLY-BODY
        //    FINALLY-BODY
        //  endOfFinally:
        // #try-cathch-finally ends here
        // afterFinally:
        //    if not returnVar :
        //      goto noReturn
        //    if (finally may yield ):
        //          return 1
        //    else
        //          return appropriate_return_value
        //  noReturn:
        internal override void Emit(CodeGen cg)
        {
            // environmental slots
            Slot isTryYielded = null;
            Slot isCatchYielded = null;
            Slot isFinallyYielded = null;
            Slot isElseYielded = null;
            Slot storedException = null;

            // local slots
            Slot tryChoiceVar = null;
            Slot catchChoiceVar = null;
            Slot elseChoiceVar = null;
            Slot finallyChoiceVar = null;

            Slot flowControlVar = cg.GetLocalTmp(typeof(int));
            Slot isElseBlock = null;

            cg.EmitPosition(Start, header);

            if (IsBlockYieldable(tryYieldTargets)) {
                tryChoiceVar = cg.GetLocalTmp(typeof(int));
                isTryYielded = cg.Names.GetTempSlot("is", typeof(object));
                cg.EmitFieldGet(typeof(Ops).GetField("FALSE"));
                isTryYielded.EmitSet(cg);
            }

            if (IsBlockYieldable(catchYieldTargets)) {
                catchChoiceVar = cg.GetLocalTmp(typeof(int));
                storedException = cg.Names.GetTempSlot("exc", typeof(object));
                isCatchYielded = cg.Names.GetTempSlot("is", typeof(object));
//.........这里部分代码省略.........
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:101,代码来源:Statements.cs

示例5: EmitGenerator

        private void EmitGenerator(CodeGen ncg)
        {
            YieldTarget[] targets = YieldLabelBuilder.BuildYieldTargets(this, ncg);

            Label[] jumpTable = new Label[yieldCount];
            for (int i = 0; i < yieldCount; i++) jumpTable[i] = targets[i].TopBranchTarget;
            ncg.yieldLabels = jumpTable;

            // Generator will ofcourse yield, but we are not interested in the isBlockYielded value
            // hence push a dummySlot to pass the Assertion.

            Slot dummySlot = ncg.GetLocalTmp(typeof(object));
            ncg.PushTryBlock(dummySlot);
            ncg.BeginExceptionBlock();

            ncg.Emit(OpCodes.Ldarg_0);
            ncg.EmitFieldGet(typeof(Generator), "location");
            ncg.Emit(OpCodes.Switch, jumpTable);

            // fall-through on first pass
            // yield statements will insert the needed labels after their returns
            Body.Emit(ncg);
            //free the dummySlot
            ncg.FreeLocalTmp(dummySlot);
            // fall-through is almost always possible in generators, so this
            // is almost always needed
            ncg.EmitReturnInGenerator(null);

            // special handling for StopIteration thrown in body
            ncg.BeginCatchBlock(typeof(StopIterationException));
            ncg.EndExceptionBlock();
            ncg.EmitReturnInGenerator(null);
            ncg.PopTargets();

            ncg.Finish();
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:36,代码来源:FuncDef.cs

示例6: EmitAs

 /// <summary>
 /// Generates code for this expression in a value position.  This will leave
 /// the value of the expression on the top of the stack typed as asType.
 /// </summary>
 /// <param name="cg">Where to generate the code.</param>
 /// <param name="asType">The type to leave on top of the stack.</param>
 internal void EmitAs(CodeGen cg, Type asType)
 {
     if (this is ConstantExpression && asType == typeof(object) && Type == typeof(bool))
       {
     if (IsConstant(true))
     {
       cg.EmitFieldGet(True);
     }
     else
     {
       cg.EmitFieldGet(False);
     }
       }
       else
       {
     if (this is UnaryExpression)
     {
       UnaryExpression ue = this as UnaryExpression;
       if (ue.NodeType == AstNodeType.Convert)
       {
         if (ue.Operand.Type == asType)
         {
           ue.Operand.Emit(cg);
           return;
         }
       }
     }
     this.Emit(cg);  // emit as Type
     if (asType.IsValueType || !IsConstant(null) && Type != typeof(SymbolId))
     {
       cg.EmitConvert(Type, asType);
     }
       }
 }
开发者ID:kkirstein,项目名称:IronScheme,代码行数:40,代码来源:Expression.cs

示例7: EmitGet

        public override void EmitGet(CodeGen cg)
        {
            Contract.RequiresNotNull(cg, "cg");

            cg.EmitFieldGet(_field);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:6,代码来源:StaticFieldSlot.cs

示例8: EmitGet

 public override void EmitGet(CodeGen cg)
 {
     cg.EmitFieldGet(field);
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:4,代码来源:Slot.cs


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