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


C# ILGen.EmitPropertyGet方法代码示例

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


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

示例1: EmitCodeContext

 private static void EmitCodeContext(ILGen il, bool context) {
     if (context) {
         il.EmitLoadArg(1);
     } else {
         il.EmitPropertyGet(typeof(DefaultContext).GetProperty("Default"));
     }
 }
开发者ID:Hank923,项目名称:ironruby,代码行数:7,代码来源:NewTypeMaker.cs

示例2: CompileExpr

 internal void CompileExpr(ILGen il, LocalAccess locals, Stack<Type> st, object lval)
 {
     if (lval == null)
     {
         il.EmitNull();
         st.Push(typeof(System.Object));
     }
     else if (Lisp.IsNode(lval))
     {
         if (lval == Lisp.NIL || lval == Lisp.T)
         {
             if (lval == Lisp.NIL)
                 il.EmitNull();
             else
                 il.Emit(OpCodes.Ldsfld, typeof(RuntimeOps).GetField("True"));
             st.Push(typeof(System.Object));
         }
         else if (lval == Lisp.INST)
         {
             il.Emit(OpCodes.Ldarg_0);
             il.EmitPropertyGet(typeof(CompiledLambda), "Engine");
             st.Push(typeof(Executive));
         }
         else if (lval == Lisp.ARGV)
         {
             il.Emit(OpCodes.Ldarg_2);
             st.Push(typeof(object[]));
         }
         else if (lval == Lisp.MPOOL)
         {
             il.Emit(OpCodes.Ldarg_3);
             st.Push(typeof(MemoryPool));
         }
         else
         {
             LocalBuilder localVar = locals.GetLocal(lval);
             if (localVar != null)
             {
                 il.Emit(OpCodes.Ldloc, localVar);
                 st.Push(localVar.LocalType);
             }
             else
             {
                 Type type = lval.GetType();
                 if (type == typeof(Integer))
                 {
                     il.EmitDecimal((Decimal)((Integer)lval));
                     il.EmitNew(typeof(Integer).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null,
                         new Type[] { typeof(Decimal) }, null));
                 }
                 else if (!il.TryEmitConstant(lval, type))
                 {
                     il.Emit(OpCodes.Ldarg_1);
                     il.EmitInt(locals.DefineConstant(lval));
                     il.Emit(OpCodes.Ldelem_Ref);
                     if (type.IsValueType)
                         il.EmitUnbox(type);
                 }
                 st.Push(type);
             }
         }
     }
     else if (Lisp.IsFunctor(lval))
     {
         object head = Lisp.Car(lval);
         object[] args = Lisp.ToArray(Lisp.Cdr(lval));
         ControlFormBase control;
         if (m_control.TryGetValue(head, out control))
             control.Compile(this, lval, il, locals, st, args);
         else
         {
             foreach (object a in args)
                 CompileExpr(il, locals, st, a);
             Type[] parameterTypes = new Type[args.Length];
             for (int k = args.Length - 1; k >= 0; k--)
                 parameterTypes[k] = st.Pop();
             FuncName name = new FuncName(head, parameterTypes);
             FuncBase body = GetFunc(name, false);
             if (body == null)
             {
                 bool successed = false;
                 if (parameterTypes.Length == 2)
                 {
                     Type castType = ValueProxy.GetType(parameterTypes[0], parameterTypes[1]);
                     ValueConverter converter1 = FindConverter(parameterTypes[0], castType);
                     ValueConverter converter2 = FindConverter(parameterTypes[1], castType);
                     body = GetFunc(new FuncName(name.ID, new Type[] { castType, castType }), false);
                     if (body != null && converter1 != null && converter2 != null)
                     {
                         LocalBuilder localVar = il.DeclareLocal(parameterTypes[1]);
                         il.Emit(OpCodes.Stloc, localVar);
                         converter1.Compile(this, il, locals, parameterTypes[0]);
                         il.Emit(OpCodes.Ldloc, localVar);
                         il.FreeLocal(localVar);
                         converter2.Compile(this, il, locals, parameterTypes[1]);
                         successed = true;
                     }
                 }
                 if (!successed)
                 {
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例3: 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

示例4: EmitImplicitContext

 protected override void EmitImplicitContext(ILGen il) {
     il.EmitLoadArg(0);
     EmitClassObjectFromInstance(il);
     il.EmitPropertyGet(typeof(RubyModule), "Context");
 }
开发者ID:bclubb,项目名称:ironruby,代码行数:5,代码来源:RubyTypeEmitter.cs

示例5: WriteEpilog

 private void WriteEpilog(ILGen il, Parameter[] parameters, LocalAccess locals)
 {
     if (locals.HasLocals || parameters.Length > 0)
     {
         Label label = il.DefineLabel();
         if (parameters.Length > 0)
         {
             for (int k = 0; k < parameters.Length; k++)
             {
                 il.Emit(OpCodes.Ldarg_2);
                 il.EmitInt(k);
                 il.Emit(OpCodes.Ldelem_Ref);
                 if (parameters[k].Type.IsValueType)
                 {
                     il.Emit(OpCodes.Isinst, parameters[k].Type);
                     il.Emit(OpCodes.Dup);
                     il.Emit(OpCodes.Brfalse, label);
                     if (locals.IsParameterBinded(parameters[k].ID))
                     {
                         LocalBuilder local = locals.GetLocal(parameters[k].ID);
                         il.EmitUnbox(local.LocalType);
                         il.Emit(OpCodes.Stloc, local);
                     }
                     else
                         il.Emit(OpCodes.Pop);
                 }
                 else
                 {
                     Label label2 = il.DefineLabel();
                     il.Emit(OpCodes.Dup);
                     il.Emit(OpCodes.Brfalse_S, label2);
                     il.Emit(OpCodes.Isinst, parameters[k].Type);
                     il.Emit(OpCodes.Dup);
                     il.Emit(OpCodes.Brfalse, label);
                     il.MarkLabel(label2);
                     if (locals.IsParameterBinded(parameters[k].ID))
                     {                                                                
                         LocalBuilder local = locals.GetLocal(parameters[k].ID);
                         il.Emit(OpCodes.Stloc, local);
                     }
                     else
                         il.Emit(OpCodes.Pop);
                 }
             }
         }
         if (locals.HasLocals)
         {
             il.Emit(OpCodes.Ldarg_0);
             il.EmitPropertyGet(typeof(CompiledLambda), "Values");
             LocalBuilder values = il.DeclareLocal(typeof(SymbolLink[]));
             il.Emit(OpCodes.Stloc, values);
             int k = 0;
             foreach (LocalAccess.LocalBinding b in locals)
             {
                 il.Emit(OpCodes.Ldarg_3);                        
                 il.Emit(OpCodes.Ldloc, values);
                 il.EmitInt(k++);
                 il.Emit(OpCodes.Ldelem_Ref);
                 il.EmitCall(m_memoryPoolGetData);
                 if (b.Local.LocalType.IsValueType)
                 {
                     il.Emit(OpCodes.Isinst, b.Local.LocalType);
                     il.Emit(OpCodes.Dup);
                     il.Emit(OpCodes.Brfalse, label);
                     il.EmitUnbox(b.Local.LocalType);
                     il.Emit(OpCodes.Stloc, b.Local);
                 }
                 else
                 {
                     Label label2 = il.DefineLabel();
                     il.Emit(OpCodes.Dup);
                     il.Emit(OpCodes.Brfalse_S, label2);
                     il.Emit(OpCodes.Isinst, b.Local.LocalType);
                     il.Emit(OpCodes.Dup);
                     il.Emit(OpCodes.Brfalse, label);
                     il.MarkLabel(label2);
                     il.Emit(OpCodes.Stloc, b.Local);
                 }
             }
             il.FreeLocal(values);
         }
         Label end = il.DefineLabel();
         il.Emit(OpCodes.Br_S, end);
         il.MarkLabel(label);
         il.Emit(OpCodes.Pop); // Isinst
         il.EmitPropertyGet(typeof(Undefined), "Value");
         il.Emit(OpCodes.Ret);
         il.MarkLabel(end);                
     }
 }
开发者ID:,项目名称:,代码行数:90,代码来源:

示例6: 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

示例7: Compile

 public override Type Compile(Executive engine, ILGen il, LocalAccess locals, Type[] parameterTypes)
 {
     if (_implictExecutive)
     {
         LocalBuilder[] localVar = new LocalBuilder[parameterTypes.Length];
         for (int k = localVar.Length - 1; k >= 0; k--)
         {
             localVar[k] = il.DeclareLocal(parameterTypes[k]);
             il.Emit(OpCodes.Stloc, localVar[k]);
         }
         il.Emit(OpCodes.Ldarg_0);
         il.EmitPropertyGet(typeof(CompiledLambda), "Engine");
         for (int k = 0; k < localVar.Length; k++)
         {
             il.Emit(OpCodes.Ldloc, localVar[k]);
             il.FreeLocal(localVar[k]);
         }                
     }
     if (Name.VariableLength)
     {
         LocalBuilder[] localVar = new LocalBuilder[parameterTypes.Length - Name.Arity + 1];
         for (int k = 0; k < localVar.Length; k++)
         {
             if (parameterTypes[k + Name.Arity - 1] != Name.VariableParamType &&
                 Name.VariableParamType != typeof(System.Object))
                 throw new InvalidOperationException();
             localVar[localVar.Length - k -1] = il.DeclareLocal(parameterTypes[k + Name.Arity - 1]);
             il.Emit(OpCodes.Stloc, localVar[localVar.Length - k - 1]);
         }
         il.EmitInt(localVar.Length);
         il.Emit(OpCodes.Newarr, Name.VariableParamType);
         for (int k = 0; k < localVar.Length; k++)
         {
             il.Emit(OpCodes.Dup);
             il.EmitInt(k);
             il.Emit(OpCodes.Ldloc, localVar[k]);
             if (localVar[k].LocalType != Name.VariableParamType &&
                 localVar[k].LocalType.IsValueType)
                 il.Emit(OpCodes.Box, localVar[k].LocalType);
             il.EmitStoreElement(Name.VariableParamType);
             il.FreeLocal(localVar[k]);
         }
     }
     il.EmitCall(_methodInfo);
     return _methodInfo.GetReturnType();
 }
开发者ID:,项目名称:,代码行数:46,代码来源:

示例8: EmitClassObjectFromInstance

 protected override void EmitClassObjectFromInstance(ILGen il) {
     if (typeof(IRubyObject).IsAssignableFrom(BaseType)) {
         il.EmitPropertyGet(typeof(IRubyObject), "Class");
     } else {
         il.EmitFieldGet(_classField);
     }
 }
开发者ID:tnachen,项目名称:ironruby,代码行数:7,代码来源:RubyTypeEmitter.cs


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