瀏覽代碼

compiler: write correct method kind for constructors,destructors and class methods

git-svn-id: trunk@14512 -
paul 15 年之前
父節點
當前提交
c83fc67e32
共有 2 個文件被更改,包括 24 次插入7 次删除
  1. 22 5
      compiler/ncgrtti.pas
  2. 2 2
      rtl/objpas/typinfo.pp

+ 22 - 5
compiler/ncgrtti.pas

@@ -697,11 +697,28 @@ implementation
                if (tf_requires_proper_alignment in target_info.flags) then
                  current_asmdata.asmlists[al_rtti].concat(cai_align.Create(sizeof(TConstPtrUInt)));
 
-               { write kind of method (can only be function or procedure)}
-               if def.returndef = voidtype then
-                 methodkind := mkProcedure
+               { write kind of method }
+               case def.proctypeoption of
+                 potype_constructor: methodkind:=mkConstructor;
+                 potype_destructor: methodkind:=mkDestructor;
+                 potype_procedure: 
+                   if po_classmethod in def.procoptions then 
+                     methodkind:=mkClassProcedure
+                   else
+                     methodkind:=mkProcedure;
+                 potype_function:
+                   if po_classmethod in def.procoptions then 
+                     methodkind:=mkClassFunction
+                   else
+                     methodkind:=mkFunction;
                else
-                 methodkind := mkFunction;
+                 begin                   
+                   if def.returndef = voidtype then
+                     methodkind:=mkProcedure
+                   else
+                     methodkind:=mkFunction;
+                 end;
+               end;
                current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(methodkind));
 
                { write parameter info. The parameters must be written in reverse order
@@ -711,7 +728,7 @@ implementation
                for i:=0 to def.paras.count-1 do
                  write_para(tparavarsym(def.paras[i]));
 
-               if methodkind=mkFunction then
+               if (methodkind=mkFunction) or (methodkind=mkClassFunction) then
                begin
                  { write name of result type }
                  write_rtti_name(def.returndef);

+ 2 - 2
rtl/objpas/typinfo.pp

@@ -137,8 +137,8 @@ unit typinfo;
                     TypeName : ShortString;
                   end;
               followed by
-                  ResultType : ShortString     // for mkFunction only
-                  ResultTypeRef : PPTypeInfo;  // for mkFunction only
+                  ResultType : ShortString     // for mkFunction, mkClassFunction only
+                  ResultTypeRef : PPTypeInfo;  // for mkFunction, mkClassFunction only
                   CC : TCallConv;
                   ParamTypeRefs : array[1..ParamCount] of PPTypeInfo;}
               );