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


C# ILGenerator.LoadField方法代码示例

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


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

示例1: GenerateStub

        /// <summary>
        /// Generates a method that does type conversion and calls the bound method.
        /// </summary>
        /// <param name="generator"> The ILGenerator used to output the body of the method. </param>
        /// <param name="argumentCount"> The number of arguments that will be passed to the delegate. </param>
        /// <returns> A delegate that does type conversion and calls the method represented by this
        /// object. </returns>
        protected override void GenerateStub(ILGenerator generator, int argumentCount)
        {
            // Check for the correct number of arguments.
            if (argumentCount != 0)
            {
                EmitHelpers.EmitThrow(generator, "TypeError", "Wrong number of arguments");
                EmitHelpers.EmitDefaultValue(generator, PrimitiveType.Any);
                generator.Complete();
                return;
            }

            if (this.field.IsStatic == false)
            {
                generator.LoadArgument(1);
                ClrBinder.EmitConversionToType(generator, this.field.DeclaringType, convertToAddress: true);
            }
            generator.LoadField(this.field);
            ClrBinder.EmitConversionToObject(generator, this.field.FieldType);
            generator.Complete();
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:27,代码来源:FieldBinders.cs

示例2: EmitUndefined

 /// <summary>
 /// Emits undefined.
 /// </summary>
 /// <param name="generator"> The IL generator. </param>
 public static void EmitUndefined(ILGenerator generator)
 {
     generator.LoadField(ReflectionHelpers.Undefined_Value);
 }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:8,代码来源:EmitHelpers.cs

示例3: EmitNull

 /// <summary>
 /// Emits null.
 /// </summary>
 /// <param name="generator"> The IL generator. </param>
 public static void EmitNull(ILGenerator generator)
 {
     generator.LoadField(ReflectionHelpers.Null_Value);
 }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:8,代码来源:EmitHelpers.cs

示例4: EmitTypeConversion

        /// <summary>
        /// Pops the value on the stack, converts it from one type to another, then pushes the
        /// result onto the stack.  Undefined is converted to the given default value.
        /// </summary>
        /// <param name="generator"> The IL generator. </param>
        /// <param name="fromType"> The type to convert from. </param>
        /// <param name="targetParameter"> The type to convert to and the default value, if there is one. </param>
        private static void EmitTypeConversion(ILGenerator generator, Type fromType, BinderArgument argument)
        {
            // Emit either the default value if there is one, otherwise emit "undefined".
            if (argument.HasDefaultValue)
            {
                // Check if the input value is undefined.
                var elseClause = generator.CreateLabel();
                generator.Duplicate();
                generator.BranchIfNull(elseClause);
                generator.Duplicate();
                generator.LoadField(ReflectionHelpers.Undefined_Value);
                generator.CompareEqual();
                generator.BranchIfTrue(elseClause);

                // Convert as per normal.
                EmitTypeConversion(generator, fromType, argument.Type);

                // Jump to the end.
                var endOfIf = generator.CreateLabel();
                generator.Branch(endOfIf);
                generator.DefineLabelPosition(elseClause);

                // Pop the existing value and emit the default value.
                generator.Pop();
                EmitUndefined(generator, argument);

                // Define the end of the block.
                generator.DefineLabelPosition(endOfIf);
            }
            else
            {
                // Convert as per normal.
                EmitTypeConversion(generator, fromType, argument.Type);
            }
        }
开发者ID:benliddicott,项目名称:JS360,代码行数:42,代码来源:JSBinder.cs


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