Beispiel #1
0
 public int RegisterMethod(MethodInfo info, int type_id)
 {
     int num = this.FindMethod(info);
     if (num <= 0)
     {
         num = this.AppVar();
         this[num].Name = info.Name;
         this[num].Level = type_id;
         this[num].Kind = MemberKind.Method;
         this[num].TypeId = this.RegisterType(info.ReturnType, false);
         FunctionObject m = new FunctionObject(this.scripter, num, type_id);
         if (info.IsPublic)
         {
             m.Modifiers.Add(Modifier.Public);
         }
         if (info.IsStatic)
         {
             m.Modifiers.Add(Modifier.Static);
         }
         if (info.IsAbstract)
         {
             m.Modifiers.Add(Modifier.Abstract);
         }
         if (info.IsVirtual)
         {
             m.Modifiers.Add(Modifier.Virtual);
         }
         m.Imported = true;
         m.Method_Info = info;
         this[num].Value = m;
         this.AppVar();
         int num2 = this.AppVar();
         this[num2].Level = num;
         this[num2].TypeId = this.RegisterType(info.ReturnType, false);
         int num3 = this.AppVar();
         this[num3].Level = num;
         if (!info.IsStatic)
         {
             this[num3].Name = "this";
         }
         bool flag = false;
         int id = 0;
         foreach (ParameterInfo info2 in info.GetParameters())
         {
             id = this.AppVar();
             this[id].Level = num;
             this[id].TypeId = this.RegisterType(info2.ParameterType, false);
             m.AddParam(id, ParamMod.None);
             if (flag || ((info2.DefaultValue != null) && (info2.DefaultValue != DBNull.Value)))
             {
                 int typeId = this[id].TypeId;
                 object defaultValue = info2.DefaultValue;
                 if (info2.ParameterType.IsEnum)
                 {
                     defaultValue = ConvertHelper.ToEnum(info2.ParameterType, defaultValue);
                 }
                 int num6 = this.AppConst(defaultValue, typeId);
                 m.AddDefaultValueId(id, num6);
                 flag = true;
             }
         }
         if (id != 0)
         {
             int num7 = this[id].TypeId;
             if (CSLite_System.GetRank(this[num7].Name) == 1)
             {
                 m.ParamsId = id;
                 int num8 = this[m.ParamsId].TypeId;
                 string elementTypeName = CSLite_System.GetElementTypeName(this[num8].Name);
                 int num9 = this.scripter.GetTypeId(elementTypeName);
                 m.ParamsElementId = this.AppVar();
                 this[m.ParamsElementId].TypeId = num9;
             }
         }
         m.SetupParameters();
         ((ClassObject) this[type_id].Val).AddMember(m);
     }
     return num;
 }