Browse Source

* changed the parameter of fpcDeepCopy() from an out-parameter of the
actual recordtype into FpcBaseRecordType so we can also use
the deep copy routine in the RTL
+ added abstract fpcDeepCopy() declaration to FpcBaseRecordType class

git-svn-id: branches/jvmbackend@18718 -

Jonas Maebe 14 years ago
parent
commit
3ac950eed7
3 changed files with 4 additions and 3 deletions
  1. 1 1
      compiler/pjvm.pas
  2. 2 2
      compiler/symcreat.pas
  3. 1 0
      rtl/java/jrech.inc

+ 1 - 1
compiler/pjvm.pas

@@ -194,7 +194,7 @@ implementation
         { can't use def.typesym, not yet set at this point }
         if not assigned(def.symtable.realname) then
           internalerror(2011032803);
-        if str_parse_method_dec('procedure fpcDeepCopy(out result:'+def.symtable.realname^+');',potype_procedure,false,def,pd) then
+        if str_parse_method_dec('procedure fpcDeepCopy(result: FpcBaseRecordType);override;',potype_procedure,false,def,pd) then
           pd.synthetickind:=tsk_record_deepcopy
         else
           internalerror(2011032807);

+ 2 - 2
compiler/symcreat.pas

@@ -382,14 +382,14 @@ implementation
          not assigned(struct.typesym) then
         internalerror(2011032811);
       { copy all fields }
-      str:='begin ';
+      str:='type _fpc_ptrt = ^'+struct.typesym.realname+'; var res: _fpc_ptrt; begin res:=_fpc_ptrt(result);';
       for i:=0 to struct.symtable.symlist.count-1 do
         begin
           sym:=tsym(struct.symtable.symlist[i]);
           if (sym.typ=fieldvarsym) then
             begin
               fsym:=tfieldvarsym(sym);
-              str:=str+'result.&'+fsym.realname+':=&'+fsym.realname+';';
+              str:=str+'res^.&'+fsym.realname+':=&'+fsym.realname+';';
             end;
         end;
       str:=str+'end;';

+ 1 - 0
rtl/java/jrech.inc

@@ -24,5 +24,6 @@ type
     function clone: JLObject;override;
     { create an empty instance of the current type }
     function newEmpty: FpcBaseRecordType;
+    procedure fpcDeepCopy(result: FpcBaseRecordType);virtual;abstract;
   end;