예제 #1
0
파일: MethodDef.cs 프로젝트: mdae/MonoRT
        private PEAPI.Param [] GenerateParams(CodeGen code_gen)
        {
            PEAPI.Param[] param_array;

            if (param_list != null && param_list.Count > 0)
            {
                int param_count = param_list.Count;

                // Remove the last param if its the sentinel, not sure what
                // should happen with more then one sentinel
                ParamDef last = (ParamDef)param_list [param_count - 1];
                if (last.IsSentinel())
                {
                    param_count--;
                }

                param_array = new PEAPI.Param [param_count];
                for (int i = 0; i < param_count; i++)
                {
                    ParamDef paramdef = (ParamDef)param_list [i];
                    paramdef.Define(code_gen);
                    param_array [i] = paramdef.PeapiParam;
                }
            }
            else
            {
                param_array = new PEAPI.Param [0];
            }

            return(param_array);
        }
예제 #2
0
파일: MethodDef.cs 프로젝트: mdae/MonoRT
        public PEAPI.MethodDef Resolve(CodeGen code_gen, PEAPI.ClassDef classdef)
        {
            if (is_resolved)
            {
                return(methoddef);
            }

            PEAPI.Param [] param_array = GenerateParams(code_gen);
            FixAttributes();
            ret_param.Define(code_gen);

            if (classdef == null)
            {
                methoddef = code_gen.PEFile.AddMethod(meth_attr, impl_attr,
                                                      name, ret_param.PeapiParam, param_array);
            }
            else
            {
                methoddef = classdef.AddMethod(meth_attr, impl_attr,
                                               name, ret_param.PeapiParam, param_array);
            }

            methoddef.AddCallConv(call_conv);

            is_resolved = true;

            return(methoddef);
        }