ソースを参照

Add support for parsing "refcounted" in classes.

pdecobj.pas:
  * parse_object_options: parse "refcounted" at the same position as "sealed" and "abstract"
  * parse_parent_classes: a class inherits the "oo_is_reference_counted" flag from its parent class
  * object_dec: if a class has "oo_is_reference_counted" set, then we add a hidden 32-bit signed integer field named "$refcount" if it is the first class in the hierarchy to have the flag (otherwise the field is "inherited" from its parent)

git-svn-id: branches/svenbarth/arc@28805 -
svenbarth 10 年 前
コミット
586c54dad2
1 ファイル変更17 行追加0 行削除
  1. 17 0
      compiler/pdecobj.pas

+ 17 - 0
compiler/pdecobj.pas

@@ -496,6 +496,10 @@ implementation
                   else
                   if try_to_consume(_SEALED) then
                     include(current_structdef.objectoptions,oo_is_sealed)
+                  else
+                  if (current_objectdef.objecttype=odt_class) and
+                      try_to_consume(_REFCOUNTED) then
+                    include(current_structdef.objectoptions,oo_is_reference_counted)
                   else if (current_objectdef.objecttype=odt_javaclass) and
                           (token=_ID) and
                           (idtoken=_EXTERNAL) then
@@ -640,6 +644,8 @@ implementation
                          childof:=nil;
                        end;
                 end;
+                if oo_is_reference_counted in childof.objectoptions then
+                  include(current_objectdef.objectoptions,oo_is_reference_counted);
               end;
             hasparentdefined:=true;
           end;
@@ -1496,6 +1502,17 @@ implementation
             else
               olddef:=nil;
 
+            if (oo_is_reference_counted in current_objectdef.objectoptions) and
+                (
+                  not assigned(current_objectdef.childof) or
+                  not (oo_is_reference_counted in current_objectdef.childof.objectoptions)
+                ) then
+              begin
+                fsym:=cfieldvarsym.create('$refcount',vs_value,s32inttype,[]);
+                current_objectdef.symtable.insert(fsym);
+                tobjectsymtable(current_objectdef.symtable).addfield(fsym,vis_private);
+              end;
+
             { parse and insert object members }
             parse_object_members;