Browse Source

* move writing of the methodkind into its own function (and return the value as its a bit more complicated to calculate than merely checking proctypeoption)

git-svn-id: trunk@35248 -
svenbarth 8 years ago
parent
commit
e3f10500b0
1 changed files with 33 additions and 25 deletions
  1. 33 25
      compiler/ncgrtti.pas

+ 33 - 25
compiler/ncgrtti.pas

@@ -58,6 +58,7 @@ interface
         procedure write_child_rtti_data(def:tdef;rt:trttitype);
         procedure write_child_rtti_data(def:tdef;rt:trttitype);
         procedure write_rtti_reference(tcb: ttai_typedconstbuilder; def: tdef; rt: trttitype);
         procedure write_rtti_reference(tcb: ttai_typedconstbuilder; def: tdef; rt: trttitype);
         procedure write_header(tcb: ttai_typedconstbuilder; def: tdef; typekind: byte);
         procedure write_header(tcb: ttai_typedconstbuilder; def: tdef; typekind: byte);
+        function write_methodkind(tcb:ttai_typedconstbuilder;def:tabstractprocdef):byte;
       public
       public
         constructor create;
         constructor create;
         procedure write_rtti(def:tdef;rt:trttitype);
         procedure write_rtti(def:tdef;rt:trttitype);
@@ -181,6 +182,37 @@ implementation
         tcb.end_anonymous_record;
         tcb.end_anonymous_record;
       end;
       end;
 
 
+
+    function TRTTIWriter.write_methodkind(tcb:ttai_typedconstbuilder;def:tabstractprocdef):byte;
+      begin
+        case def.proctypeoption of
+          potype_constructor: result:=mkConstructor;
+          potype_destructor: result:=mkDestructor;
+          potype_class_constructor: result:=mkClassConstructor;
+          potype_class_destructor: result:=mkClassDestructor;
+          potype_operator: result:=mkOperatorOverload;
+          potype_procedure:
+            if po_classmethod in def.procoptions then
+              result:=mkClassProcedure
+            else
+              result:=mkProcedure;
+          potype_function:
+            if po_classmethod in def.procoptions then
+              result:=mkClassFunction
+            else
+              result:=mkFunction;
+        else
+          begin
+            if def.returndef = voidtype then
+              result:=mkProcedure
+            else
+              result:=mkFunction;
+          end;
+        end;
+        tcb.emit_ord_const(result,u8inttype);
+      end;
+
+
     procedure TRTTIWriter.write_rtti_name(tcb: ttai_typedconstbuilder; def: tdef);
     procedure TRTTIWriter.write_rtti_name(tcb: ttai_typedconstbuilder; def: tdef);
       begin
       begin
          if is_open_array(def) then
          if is_open_array(def) then
@@ -1006,31 +1038,7 @@ implementation
                  targetinfos[target_info.system]^.alignment.maxCrecordalign);
                  targetinfos[target_info.system]^.alignment.maxCrecordalign);
 
 
                { write kind of method }
                { write kind of method }
-               case def.proctypeoption of
-                 potype_constructor: methodkind:=mkConstructor;
-                 potype_destructor: methodkind:=mkDestructor;
-                 potype_class_constructor: methodkind:=mkClassConstructor;
-                 potype_class_destructor: methodkind:=mkClassDestructor;
-                 potype_operator: methodkind:=mkOperatorOverload;
-                 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
-                 begin
-                   if def.returndef = voidtype then
-                     methodkind:=mkProcedure
-                   else
-                     methodkind:=mkFunction;
-                 end;
-               end;
-               tcb.emit_ord_const(methodkind,u8inttype);
+               methodkind:=write_methodkind(tcb,def);
 
 
                { write parameter info. The parameters must be written in reverse order
                { write parameter info. The parameters must be written in reverse order
                  if this method uses right to left parameter pushing! }
                  if this method uses right to left parameter pushing! }