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


C# ILGen.EmitFieldGet方法代码示例

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


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

示例1: Create

        internal static Type Create(GenContext context, Type baseClass)
        {
            //ModuleBuilder mb = context.ModuleBldr;
            string name = baseClass.Name + "_impl";
            //TypeBuilder baseTB = context.ModuleBldr.DefineType(name, TypeAttributes.Class | TypeAttributes.Public, baseClass);
            TypeBuilder baseTB = context.AssemblyGen.DefinePublicType(name, baseClass, true);

            ObjExpr.MarkAsSerializable(baseTB);

            baseTB.DefineDefaultConstructor(MethodAttributes.Public);

            FieldBuilder metaField = baseTB.DefineField("_meta", typeof(IPersistentMap), FieldAttributes.Public);

            MethodBuilder metaMB = baseTB.DefineMethod("meta", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.ReuseSlot, typeof(IPersistentMap), Type.EmptyTypes);
            ILGen gen = new ILGen(metaMB.GetILGenerator());
            gen.EmitLoadArg(0);
            gen.EmitFieldGet(metaField);
            gen.Emit(OpCodes.Ret);

            MethodBuilder withMB = baseTB.DefineMethod("withMeta", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.ReuseSlot, typeof(IObj), new Type[] { typeof(IPersistentMap)});
            gen = new ILGen(withMB.GetILGenerator());
            gen.EmitLoadArg(0);
            gen.EmitCall(Compiler.Method_Object_MemberwiseClone);
            gen.Emit(OpCodes.Castclass, baseTB);
            gen.Emit(OpCodes.Dup);
            gen.EmitLoadArg(1);
            gen.EmitFieldSet(metaField);
            gen.Emit(OpCodes.Ret);

            for (int i = 0; i < 20; i++ )
                DefineDelegateFieldAndOverride(baseTB, i);

            return baseTB.CreateType();
        }
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:34,代码来源:AFnImplGenerator.cs

示例2: Compile

 public override Type Compile(Executive engine, ILGen il, LocalAccess locals, Type[] parameterTypes)
 {
     for (int k = 0; k < parameterTypes.Length; k++)
         il.Emit(OpCodes.Pop);
     il.EmitFieldGet(typeof(DBNull), "Value");
     return typeof(DBNull);
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例3: EmitClrCallStub

        /// <summary>
        /// Generates stub to receive the CLR call and then call the dynamic language code.
        /// This code is same as StubGenerator.cs in the Microsoft.Scripting, except it
        /// accepts ILGen instead of Compiler.
        /// </summary>
        private void EmitClrCallStub(ILGen il, MethodInfo mi, LocalBuilder callTarget) {
            int firstArg = 0;
            bool list = false;              // The list calling convention
            bool context = false;           // Context is an argument

            ParameterInfo[] pis = mi.GetParameters();
            if (pis.Length > 0) {
                if (pis[0].ParameterType == typeof(CodeContext)) {
                    firstArg = 1;
                    context = true;
                }
                if (pis[pis.Length - 1].IsDefined(typeof(ParamArrayAttribute), false)) {
                    list = true;
                }
            }
            ParameterInfo[] args = pis;
            int nargs = args.Length - firstArg;
            Type[] genericArgs = mi.GetGenericArguments();

            // Create the action
            ILGen cctor = GetCCtor();
            if (list || genericArgs.Length > 0) {
                // Use a complex call signature that includes param array and keywords
                cctor.EmitInt(nargs);
                cctor.EmitBoolean(list);

                // Emit an array of keyword names:
                cctor.EmitInt(genericArgs.Length);
                cctor.Emit(OpCodes.Newarr, typeof(string));
                for (int i = 0; i < genericArgs.Length; i++) {
                    cctor.Emit(OpCodes.Dup);
                    cctor.EmitInt(i);
                    cctor.Emit(OpCodes.Ldelema, typeof(string));
                    cctor.Emit(OpCodes.Ldstr, genericArgs[i].Name);
                    cctor.Emit(OpCodes.Stobj, typeof(string));
                }
                cctor.EmitCall(typeof(PythonOps).GetMethod("MakeComplexCallAction"));
            } else {
                cctor.EmitInt(nargs);
                cctor.EmitCall(typeof(PythonOps).GetMethod("MakeSimpleCallAction"));
            }

            // Create the dynamic site
            Type siteType = CompilerHelpers.MakeCallSiteType(MakeSiteSignature(nargs + genericArgs.Length));
            FieldBuilder site = _tg.DefineField("site$" + _site++, siteType, FieldAttributes.Private | FieldAttributes.Static);
            cctor.EmitCall(siteType.GetMethod("Create"));
            cctor.EmitFieldSet(site);

            List<ReturnFixer> fixers = new List<ReturnFixer>(0);

            //
            // Emit the site invoke
            //
            il.EmitFieldGet(site);
            FieldInfo target = siteType.GetField("Target");
            il.EmitFieldGet(target);
            il.EmitFieldGet(site);

            // Emit the code context
            EmitCodeContext(il, context);

            il.Emit(OpCodes.Ldloc, callTarget);

            for (int i = firstArg; i < args.Length; i++) {
                ReturnFixer rf = ReturnFixer.EmitArgument(il, args[i], i + 1);
                if (rf != null) {
                    fixers.Add(rf);
                }
            }

            for (int i = 0; i < genericArgs.Length; i++) {
                il.EmitType(genericArgs[i]);
                il.EmitCall(typeof(DynamicHelpers).GetMethod("GetPythonTypeFromType"));
            }

            il.EmitCall(target.FieldType, "Invoke");

            foreach (ReturnFixer rf in fixers) {
                rf.FixReturn(il);
            }

            EmitConvertFromObject(il, mi.ReturnType);
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:88,代码来源:NewTypeMaker.cs

示例4: EmitSymbolId

        private void EmitSymbolId(ILGen il, string name) {
            Debug.Assert(name != null);
            SymbolId id = SymbolTable.StringToId(name);

            FieldBuilder fb;
            if (!_symbolFields.TryGetValue(id, out fb)) {
                fb = _tg.DefineField("symbol_" + name, typeof(int), FieldAttributes.Private | FieldAttributes.Static);
                ILGen cctor = GetCCtor();
                LocalBuilder localTmp = GetCCtorSymbolIdTemp();
                cctor.EmitString(name);
                cctor.EmitCall(typeof(SymbolTable), "StringToId");
                cctor.Emit(OpCodes.Stloc, localTmp);
                cctor.Emit(OpCodes.Ldloca, localTmp);
                cctor.EmitPropertyGet(typeof(SymbolId), "Id");
                cctor.EmitFieldSet(fb);

                _symbolFields[id] = fb;
            }

            il.EmitFieldGet(fb);
            // TODO: Cache the signature type!!!
            il.EmitNew(typeof(SymbolId), new Type[] { typeof(int) });
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:23,代码来源:NewTypeMaker.cs

示例5: EmitNonInheritedMethodLookup

        /// <summary>
        /// Emits the call to lookup a member defined in the user's type.  Returns
        /// the local which stores the resulting value and leaves a value on the
        /// stack indicating the success of the lookup.
        /// </summary>
        private LocalBuilder EmitNonInheritedMethodLookup(string name, ILGen il) {
            LocalBuilder callTarget = il.DeclareLocal(typeof(object));

            // emit call to helper to do lookup
            il.EmitLoadArg(0);

            if (typeof(IPythonObject).IsAssignableFrom(_baseType)) {
                Debug.Assert(_typeField == null);
                il.EmitPropertyGet(TypeInfo._IPythonObject.PythonType);
            } else {
                il.EmitFieldGet(_typeField);
            }

            il.EmitLoadArg(0);
            EmitSymbolId(il, name);
            il.Emit(OpCodes.Ldloca, callTarget);
            il.EmitCall(typeof(UserTypeOps), "TryGetNonInheritedMethodHelper");
            return callTarget;
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:24,代码来源:NewTypeMaker.cs

示例6: EmitClrCallStub

        /// <summary>
        /// Generates stub to receive the CLR call and then call the dynamic language code.
        /// This code is similar to that in DelegateSignatureInfo.cs in the Microsoft.Scripting.
        /// </summary>
        internal void EmitClrCallStub(ILGen/*!*/ il, MethodInfo/*!*/ mi, string/*!*/ name) {
            int firstArg = 0;
            bool list = false;              // The list calling convention
            bool context = false;           // Context is an argument

            ParameterInfo[] pis = mi.GetParameters();
            if (pis.Length > 0) {
                if (pis[0].ParameterType == ContextType) {
                    firstArg = 1;
                    context = true;
                }
                if (pis[pis.Length - 1].IsDefined(typeof(ParamArrayAttribute), false)) {
                    list = true;
                }
            }

            ParameterInfo[] args = pis;
            int nargs = args.Length - firstArg;

            // Create the action
            ILGen cctor = GetCCtor();
            EmitMakeCallAction(name, nargs, list);

            // Create the dynamic site
            Type siteType = CompilerHelpers.MakeCallSiteType(MakeSiteSignature(nargs));
            FieldBuilder site = _tb.DefineField("site$" + _site++, siteType, FieldAttributes.Private | FieldAttributes.Static);
            cctor.EmitCall(siteType.GetMethod("Create"));
            cctor.EmitFieldSet(site);

            //
            // Emit the site invoke
            //
            il.EmitFieldGet(site);
            FieldInfo target = siteType.GetField("Target");
            il.EmitFieldGet(target);
            il.EmitFieldGet(site);

            // Emit the code context
            EmitContext(il, context);

            il.Emit(OpCodes.Ldarg_0);

            List<ReturnFixer> fixers = new List<ReturnFixer>(0);
            for (int i = firstArg; i < args.Length; i++) {
                ReturnFixer rf = ReturnFixer.EmitArgument(il, args[i], i + 1);
                if (rf != null) {
                    fixers.Add(rf);
                }
            }

            il.EmitCall(target.FieldType, "Invoke");

            foreach (ReturnFixer rf in fixers) {
                rf.FixReturn(il);
            }
        }
开发者ID:BrianGenisio,项目名称:ironruby,代码行数:60,代码来源:ClsTypeEmitter.cs

示例7: EmitGetVar

        static void EmitGetVar(ILGen gen, FieldBuilder fb)
        {
            Label falseLabel = gen.DefineLabel();
            Label endLabel = gen.DefineLabel();

            gen.EmitFieldGet(fb);                       // gen.Emit(OpCodes.Ldsfld,fb);
            gen.Emit(OpCodes.Dup);
            gen.EmitCall(Method_Var_isBound);           // gen.Emit(OpCodes.Call, Method_Var_IsBound);
            gen.Emit(OpCodes.Brfalse_S,falseLabel);
            gen.Emit(OpCodes.Call,Method_Var_get);
            gen.Emit(OpCodes.Br_S,endLabel);
            gen.MarkLabel(falseLabel);
            gen.Emit(OpCodes.Pop);
            gen.EmitNull();                             // gen.Emit(OpCodes.Ldnull);
            gen.MarkLabel(endLabel);
        }
开发者ID:ragnard,项目名称:clojure-clr,代码行数:16,代码来源:GenClass.cs

示例8: ImplementProtectedFieldAccessors

        private void ImplementProtectedFieldAccessors(Dictionary<string, string[]> specialNames) {
            // For protected fields to be accessible from the derived type in Silverlight,
            // we need to create public helper methods that expose them. These methods are
            // used by the IDynamicMetaObjectProvider implementation (in MetaUserObject)

            FieldInfo[] fields = _baseType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy);
            foreach (FieldInfo fi in fields) {
                if (!fi.IsProtected()) {
                    continue;
                }

                List<string> fieldAccessorNames = new List<string>();

                PropertyBuilder pb = _tg.DefineProperty(fi.Name, PropertyAttributes.None, fi.FieldType, Type.EmptyTypes);
                MethodAttributes methodAttrs = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName;
                if (fi.IsStatic) {
                    methodAttrs |= MethodAttributes.Static;
                }

                MethodBuilder method;
                method = _tg.DefineMethod(FieldGetterPrefix + fi.Name, methodAttrs,
                                          fi.FieldType, Type.EmptyTypes);
                ILGen il = new ILGen(method.GetILGenerator());
                if (!fi.IsStatic) {
                    il.EmitLoadArg(0);
                }

                if (fi.IsLiteral) {
                    // literal fields need to be inlined directly in here... We use GetRawConstant
                    // which will work even in partial trust if the constant is protected.
                    object value = fi.GetRawConstantValue();
                    switch (Type.GetTypeCode(fi.FieldType)) {
                        case TypeCode.Boolean:
                            if ((bool)value) {
                                il.Emit(OpCodes.Ldc_I4_1);
                            } else {
                                il.Emit(OpCodes.Ldc_I4_0);
                            }
                            break;
                        case TypeCode.Byte: il.Emit(OpCodes.Ldc_I4, (byte)value); break;
                        case TypeCode.Char: il.Emit(OpCodes.Ldc_I4, (char)value); break;
                        case TypeCode.Double: il.Emit(OpCodes.Ldc_R8, (double)value); break;
                        case TypeCode.Int16: il.Emit(OpCodes.Ldc_I4, (short)value); break;
                        case TypeCode.Int32: il.Emit(OpCodes.Ldc_I4, (int)value); break;
                        case TypeCode.Int64: il.Emit(OpCodes.Ldc_I8, (long)value); break;
                        case TypeCode.SByte: il.Emit(OpCodes.Ldc_I4, (sbyte)value); break;
                        case TypeCode.Single: il.Emit(OpCodes.Ldc_R4, (float)value); break;
                        case TypeCode.String: il.Emit(OpCodes.Ldstr, (string)value); break;
                        case TypeCode.UInt16: il.Emit(OpCodes.Ldc_I4, (ushort)value); break;
                        case TypeCode.UInt32: il.Emit(OpCodes.Ldc_I4, (uint)value); break;
                        case TypeCode.UInt64: il.Emit(OpCodes.Ldc_I8, (ulong)value); break;
                    }
                } else {
                    il.EmitFieldGet(fi);
                }
                il.Emit(OpCodes.Ret);

                pb.SetGetMethod(method);
                fieldAccessorNames.Add(method.Name);

                if (!fi.IsLiteral && !fi.IsInitOnly) {
                    method = _tg.DefineMethod(FieldSetterPrefix + fi.Name, methodAttrs,
                                              null, new Type[] { fi.FieldType });
                    method.DefineParameter(1, ParameterAttributes.None, "value");
                    il = new ILGen(method.GetILGenerator());
                    il.EmitLoadArg(0);
                    if (!fi.IsStatic) {
                        il.EmitLoadArg(1);
                    }
                    il.EmitFieldSet(fi);
                    il.Emit(OpCodes.Ret);
                    pb.SetSetMethod(method);

                    fieldAccessorNames.Add(method.Name);
                }

                specialNames[fi.Name] = fieldAccessorNames.ToArray();
            }
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:79,代码来源:NewTypeMaker.cs

示例9: EmitConvertFromObject

        /// <summary>
        /// Emit code to convert object to a given type. This code is semantically equivalent
        /// to PythonBinder.EmitConvertFromObject, except this version accepts ILGen whereas
        /// PythonBinder accepts Compiler. The Binder will chagne soon and the two will merge.
        /// </summary>
        public void EmitConvertFromObject(ILGen il, Type toType) {
            if (toType == typeof(object)) {
                return;
            } else if (toType == typeof(void)) {
                il.Emit(OpCodes.Pop);
                return;
            }

            var callTarget = il.DeclareLocal(typeof(object));
            il.Emit(OpCodes.Stloc, callTarget);

            var site = GetConversionSite(toType);

            // Emit the site invoke
            il.EmitFieldGet(site);
            FieldInfo target = site.FieldType.GetField("Target");
            il.EmitFieldGet(target);
            il.EmitFieldGet(site);

            // Emit the context
            EmitContext(il, false);

            il.Emit(OpCodes.Ldloc, callTarget);

            il.EmitCall(target.FieldType, "Invoke");
        }
开发者ID:techarch,项目名称:ironruby,代码行数:31,代码来源:ClsTypeEmitter.cs

示例10: GenerateProxyMethod

        private static void GenerateProxyMethod(
            TypeBuilder proxyTB,
            FieldBuilder mapField,
            MethodInfo m,
            HashSet<MethodBuilder> specialMethods)
        {
            MethodAttributes attribs = m.Attributes;

            bool callBaseMethod;

            if ( (attribs & MethodAttributes.Abstract) == MethodAttributes.Abstract )
            {
                attribs &= ~MethodAttributes.Abstract;
                callBaseMethod = false;
            }
            else
            {
                callBaseMethod = true;

            }

            attribs &= ~MethodAttributes.NewSlot;
            attribs |= MethodAttributes.Virtual | MethodAttributes.HideBySig | MethodAttributes.Public;

            //Console.Write("Generating proxy method {0}(", m.Name);
            //foreach (ParameterInfo p in m.GetParameters())
            //    Console.Write("{0}, ", p.ParameterType.FullName);
            //Console.Write(") ");
            //Console.WriteLine(attribs.ToString());

            MethodBuilder proxym = proxyTB.DefineMethod(
                m.Name,
                attribs,
                m.CallingConvention,
                m.ReturnType,
                m.GetParameters().Select<ParameterInfo, Type>(p => p.ParameterType).ToArray<Type>());

            if (m.IsSpecialName)
                specialMethods.Add(proxym);

            ILGen gen = new ILGen(proxym.GetILGenerator());

            Label elseLabel = gen.DefineLabel();
            Label endLabel = gen.DefineLabel();

            //// Print a little message, for debugging purposes
            //gen.Emit(OpCodes.Ldstr, String.Format("Calling {0} / {1}", proxyTB.FullName, m.ToString()));
            //gen.Emit(OpCodes.Call, typeof(Console).GetMethod("WriteLine",
            //    new Type[] { typeof(string) }));
            //gen.Emit(OpCodes.Call, typeof(Console).GetMethod("get_Out"));
            //gen.Emit(OpCodes.Call, typeof(System.IO.TextWriter).GetMethod("Flush"));

            // Lookup method name in map
            gen.EmitLoadArg(0);                             // gen.Emit(OpCodes.Ldarg_0);
            gen.EmitFieldGet(mapField);                     // gen.Emit(OpCodes.Ldfld, mapField);
            gen.EmitString(m.Name);                         // gen.Emit(OpCodes.Ldstr, m.Name);
            gen.EmitCall(Method_RT_get);                    // gen.Emit(OpCodes.Call, Method_RT_get);
            gen.Emit(OpCodes.Dup);
            gen.EmitNull();                                 // gen.Emit(OpCodes.Ldnull);
            gen.Emit(OpCodes.Beq_S, elseLabel);

            // map entry found
            ParameterInfo[] pinfos = m.GetParameters();
            gen.Emit(OpCodes.Castclass, typeof(IFn));
            gen.EmitLoadArg(0);                             // gen.Emit(OpCodes.Ldarg_0);  // push implicit 'this' arg.
            for (int i = 0; i < pinfos.Length; i++)
            {
                gen.EmitLoadArg(i + 1);                     // gen.Emit(OpCodes.Ldarg, i + 1);
                if (m.GetParameters()[i].ParameterType.IsValueType)
                    gen.Emit(OpCodes.Box,pinfos[i].ParameterType);
            }

            int parmCount = pinfos.Length;
            gen.EmitCall(GetIFnInvokeMethodInfo(parmCount+1));        // gen.Emit(OpCodes.Call, GetIFnInvokeMethodInfo(parmCount + 1));
            if (m.ReturnType == typeof(void))
                gen.Emit(OpCodes.Pop);
            else
                gen.Emit(OpCodes.Unbox_Any, m.ReturnType);

            gen.Emit(OpCodes.Br_S,endLabel);

            // map entry not found
            gen.MarkLabel(elseLabel);
            gen.Emit(OpCodes.Pop); // get rid of null leftover from the 'get'

            if ( callBaseMethod )
            {
                gen.EmitLoadArg(0);                                     // gen.Emit(OpCodes.Ldarg_0);
                for (int i = 0; i < parmCount; i++)
                    gen.EmitLoadArg(i + 1);                             // gen.Emit(OpCodes.Ldarg, i + 1);
                gen.Emit(OpCodes.Call, m);                              // gen.EmitCall(m) improperly emits a callvirt in some cases
            }
            else
            {
                gen.EmitString(m.Name);                                 // gen.Emit(OpCodes.Ldstr, m.Name);
                gen.EmitNew(CtorInfo_NotImplementedException_1);        // gen.Emit(OpCodes.Newobj, CtorInfo_NotImplementedException_1);
                gen.Emit(OpCodes.Throw);
            }

            gen.MarkLabel(endLabel);
//.........这里部分代码省略.........
开发者ID:101v,项目名称:clojure-clr,代码行数:101,代码来源:GenProxy.cs

示例11: AddIProxyMethods

        private static FieldBuilder AddIProxyMethods(TypeBuilder proxyTB)
        {
            FieldBuilder fb = proxyTB.DefineField(
                _methodMapFieldName,
                typeof(IPersistentMap),
                 FieldAttributes.Private);

            MethodBuilder initMb = proxyTB.DefineMethod(
                "__initClojureFnMappings",
                 MethodAttributes.Public|MethodAttributes.Virtual|MethodAttributes.HideBySig,
                 typeof(void),
                 new Type[] { typeof(IPersistentMap) });
            ILGen gen = new ILGen(initMb.GetILGenerator());
            gen.EmitLoadArg(0);                     // gen.Emit(OpCodes.Ldarg_0);
            gen.EmitLoadArg(1);                     // gen.Emit(OpCodes.Ldarg_1);
            gen.EmitFieldSet(fb);                   // gen.Emit(OpCodes.Stfld, fb);
            gen.Emit(OpCodes.Ret);

            MethodBuilder updateTB = proxyTB.DefineMethod(
                "__updateClojureFnMappings",
                 MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
                 typeof(void),
                 new Type[] { typeof(IPersistentMap) });
            gen = new ILGen(updateTB.GetILGenerator());
            gen.EmitLoadArg(0);                     // gen.Emit(OpCodes.Ldarg_0);

            gen.Emit(OpCodes.Dup);
            gen.EmitFieldGet(fb);                   // gen.Emit(OpCodes.Ldfld, fb);
            gen.Emit(OpCodes.Castclass, typeof(IPersistentCollection));

            gen.EmitLoadArg(1);                                     // gen.Emit(OpCodes.Ldarg_1);
            gen.EmitCall(Method_IPersistentCollection_Cons);        //gen.Emit(OpCodes.Call, Method_IPersistentCollection_Cons);

            gen.EmitFieldSet(fb);                                   // gen.Emit(OpCodes.Stfld, fb);
            gen.Emit(OpCodes.Ret);

            MethodBuilder getMb = proxyTB.DefineMethod(
                "__getClojureFnMappings",
                 MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
                typeof(IPersistentMap),
                Type.EmptyTypes);

            gen = new ILGen(getMb.GetILGenerator());
            gen.EmitLoadArg(0);                                     // gen.Emit(OpCodes.Ldarg_0);
            gen.EmitFieldGet(fb);                                   // gen.Emit(OpCodes.Ldfld, fb);
            gen.Emit(OpCodes.Ret);

            return fb;
        }
开发者ID:101v,项目名称:clojure-clr,代码行数:49,代码来源:GenProxy.cs

示例12: EmitGetDict

 protected void EmitGetDict(ILGen gen) {
     if (_dictField != null) {
         gen.EmitFieldGet(_dictField);
     } else {
         gen.EmitPropertyGet(typeof(IPythonObject).GetProperty("Dict"));
     }
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:7,代码来源:NewTypeMaker.cs

示例13: EmitBaseClassCallCheckForProperties

        /// <summary>
        /// Emits code to check if the class has overridden this specific
        /// function.  For example:
        /// 
        /// MyDerivedType.SomeVirtualFunction = ...
        ///     or
        /// 
        /// class MyDerivedType(MyBaseType):
        ///     def SomeVirtualFunction(self, ...):
        /// 
        /// </summary>
        internal LocalBuilder EmitBaseClassCallCheckForProperties(ILGen il, MethodInfo baseMethod, string name) {
            Label instanceCall = il.DefineLabel();
            LocalBuilder callTarget = il.DeclareLocal(typeof(object));

            il.EmitLoadArg(0);
            il.EmitFieldGet(_typeField);
            il.EmitLoadArg(0);
            EmitSymbolId(il, name);
            il.Emit(OpCodes.Ldloca, callTarget);
            il.EmitCall(typeof(UserTypeOps), "TryGetNonInheritedValueHelper");

            il.Emit(OpCodes.Brtrue, instanceCall);

            EmitBaseMethodDispatch(baseMethod, il);

            il.MarkLabel(instanceCall);

            return callTarget;
        }
开发者ID:octavioh,项目名称:ironruby,代码行数:30,代码来源:NewTypeMaker.cs

示例14: FixReturn

 public void FixReturn(ILGen il) {
     il.EmitLoadArg(_index);
     il.Emit(OpCodes.Ldloc, _reference);
     il.EmitFieldGet(_reference.LocalType.GetField("Value"));
     il.EmitStoreValueIndirect(_parameter.ParameterType.GetElementType());
 }
开发者ID:Hank923,项目名称:ironruby,代码行数:6,代码来源:NewTypeMaker.cs

示例15: EmitClassObjectFromInstance

 protected override void EmitClassObjectFromInstance(ILGen il) {
     if (typeof(IRubyObject).IsAssignableFrom(BaseType)) {
         il.EmitCall(Methods.IRubyObject_get_ImmediateClass);
     } else {
         il.EmitFieldGet(_immediateClassField);
     }
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:7,代码来源:RubyTypeEmitter.cs


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