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


C# PEAPI.AddMethAttribute方法代码示例

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


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

示例1: WriteCode

                protected void WriteCode (CodeGen code_gen, PEAPI.MethodDef methoddef)
                {
                        /// Add the custrom attributes to this method
                        if (customattr_list != null)
                                foreach (CustomAttr customattr in customattr_list) {
                                        customattr.AddTo (code_gen, methoddef);
                                        if (customattr.IsSuppressUnmanaged (code_gen))
                                                methoddef.AddMethAttribute (PEAPI.MethAttr.HasSecurity);
				}

                        /// Add declarative security to this method
			if (decl_sec != null) {
				decl_sec.AddTo (code_gen, methoddef);
                                methoddef.AddMethAttribute (PEAPI.MethAttr.HasSecurity);
                        }        

                        // Generic type parameters
                        if (gen_params != null)
                                gen_params.Resolve (code_gen, methoddef);

                        if (type_def == null) {
                                //Global method
                                meth_attr &= ~PEAPI.MethAttr.Abstract;
                                meth_attr |= PEAPI.MethAttr.Static;
                        } else {
                                if ((inst_list.Count > 0) && type_def.IsInterface && !IsStatic)
                                        Report.Error (start, "Method cannot have body if it is non-static declared in an interface");
                                
                                if (IsAbstract) {
                                        if (!type_def.IsAbstract)
                                                Report.Error (start, String.Format ("Abstract method '{0}' in non-abstract class '{1}'", 
                                                                        Name, type_def.FullName));
                                        if (inst_list.Count > 0)
                                                Report.Error (start, "Method cannot have body if it is abstract.");
                                        return;
                                }
                        }

                        if (entry_point)
                                methoddef.DeclareEntryPoint ();

                        if (local_list.Count > 0) {
                                int ec = Report.ErrorCount;
                                PEAPI.Local[] local_array = new PEAPI.Local[local_list.Count];

                                foreach (Local local in local_list)
                                        local_array[local.Slot]  = local.GetPeapiLocal (code_gen);

                                if (Report.ErrorCount > ec)
                                        return;

                                if (zero_init)
                                        init_locals = true;
                                
                                methoddef.AddLocals (local_array, init_locals);
                        }

                        /// Nothing seems to work if maxstack is not set,
                        /// i need to find out if this NEEDs to be set
                        /// and what its default value should be
                        if (max_stack < 0)
                                max_stack = 8;
                        methoddef.SetMaxStack (max_stack);

                        if (pinvoke_info) {
                                methoddef.AddPInvokeInfo (pinvoke_mod.ModuleRef,
                                                (pinvoke_name != null ? pinvoke_name : name), pinvoke_attr);
                        }

                        if ((impl_attr & PEAPI.ImplAttr.Runtime) == PEAPI.ImplAttr.Runtime) {
                                if (inst_list.Count > 0)
                                        Report.Error (start, String.Format ("Method cannot have body if it is non-IL runtime-supplied, '{0}'", 
                                                                FullName));
                        } else {
                                if (((impl_attr & PEAPI.ImplAttr.Native) != 0) ||
                                        ((impl_attr & PEAPI.ImplAttr.Unmanaged) != 0))
                                        Report.Error (start, String.Format ("Cannot compile native/unmanaged method, '{0}'", 
                                                                FullName));
                        }

                        if (inst_list.Count > 0) {
                                /* Has body */
                                if ((impl_attr & PEAPI.ImplAttr.InternalCall) != 0)
                                        Report.Error (start, String.Format ("Method cannot have body if it is an internal call, '{0}'", 
                                                                FullName));

                                if (pinvoke_info)
                                        Report.Error (start, String.Format ("Method cannot have body if it is pinvoke, '{0}'",
                                                                FullName));
                        } else {
                                if (pinvoke_info ||
                                        ((impl_attr & PEAPI.ImplAttr.Runtime) != 0) ||
                                        ((impl_attr & PEAPI.ImplAttr.InternalCall) != 0))
                                        /* No body required */
                                        return;

                                Report.Warning (start, "Method has no body, 'ret' emitted.");
                                AddInstr (new SimpInstr (PEAPI.Op.ret, start));
                        }

//.........这里部分代码省略.........
开发者ID:Profit0004,项目名称:mono,代码行数:101,代码来源:MethodDef.cs


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