소스 검색

* export filerec/textrec from the system unit and use them in the compiler
to determine their size, rather than hardcoding the size for all possible
configurations

git-svn-id: branches/cpstrrtl@24957 -

Jonas Maebe 12 년 전
부모
커밋
5a72bc3656
3개의 변경된 파일32개의 추가작업 그리고 68개의 파일을 삭제
  1. 18 54
      compiler/symdef.pas
  2. 0 12
      rtl/inc/system.inc
  3. 14 2
      rtl/inc/systemh.inc

+ 18 - 54
compiler/symdef.pas

@@ -133,6 +133,7 @@ interface
           procedure deref;override;
           function  GetTypeName:string;override;
           function  getmangledparaname:TSymStr;override;
+          function  size:asizeint;override;
           procedure setsize;
        end;
 
@@ -2560,7 +2561,6 @@ implementation
          inherited create(filedef);
          filetyp:=ft_text;
          typedfiledef:=nil;
-         setsize;
       end;
 
 
@@ -2569,7 +2569,6 @@ implementation
          inherited create(filedef);
          filetyp:=ft_untyped;
          typedfiledef:=nil;
-         setsize;
       end;
 
 
@@ -2578,7 +2577,6 @@ implementation
          inherited create(filedef);
          filetyp:=ft_typed;
          typedfiledef:=def;
-         setsize;
       end;
 
 
@@ -2590,7 +2588,6 @@ implementation
            ppufile.getderef(typedfiledefderef)
          else
            typedfiledef:=nil;
-         setsize;
       end;
 
 
@@ -2625,63 +2622,30 @@ implementation
       end;
 
 
+    function  tfiledef.size:asizeint;
+      begin
+        if savesize=0 then
+          setsize;
+        size:=savesize;
+      end;
+
+
     procedure tfiledef.setsize;
       begin
-{$ifdef cpu64bitaddr}
-        case filetyp of
-          ft_text :
-            if target_info.system in [system_x86_64_win64,system_ia64_win64] then
-              savesize:=640
-            else
-              savesize:=632;
-          ft_typed,
-          ft_untyped :
-            if target_info.system in [system_x86_64_win64,system_ia64_win64] then
-              savesize:=376
-            else
-              savesize:=368;
-        end;
-{$endif cpu64bitaddr}
-{$ifdef cpu32bitaddr}
-        case filetyp of
-          ft_text :
-            savesize:=596; { keep this dividable by 4 for proper alignment of arrays of text, see tw0754 e.g. on arm }
-          ft_typed,
-          ft_untyped :
-            savesize:=332;
-        end;
-{$endif cpu32bitaddr}
-{$ifdef cpu16bitaddr}
-        case filetyp of
-          ft_text :
-            {$if defined(avr)}
-              savesize:=96;
-            {$elseif defined(i8086)}
-              case current_settings.x86memorymodel of
-                mm_tiny,mm_small: savesize:=576;
-                mm_medium:        savesize:=584;
-                else
-                  internalerror(2013060901);
-              end;
-            {$else}
-              {$fatal TODO: define the textrec size for your cpu}
-            {$endif}
-          ft_typed,
-          ft_untyped :
-            {$if defined(avr)}
-              savesize:=76;
-            {$elseif defined(i8086)}
-              savesize:=316;
-            {$else}
-              {$fatal TODO: define the textrec size for your cpu}
-            {$endif}
-        end;
-{$endif cpu16bitaddr}
+       case filetyp of
+         ft_text    :
+           savesize:=search_system_type('TEXTREC').typedef.size;
+         ft_typed,
+         ft_untyped :
+           savesize:=search_system_type('FILEREC').typedef.size;
+         end;
       end;
 
 
     procedure tfiledef.ppuwrite(ppufile:tcompilerppufile);
       begin
+         if savesize=0 then
+           internalerror(201305131);
          inherited ppuwrite(ppufile);
          ppufile.putbyte(byte(filetyp));
          if filetyp=ft_typed then

+ 0 - 12
rtl/inc/system.inc

@@ -57,18 +57,6 @@ Const
                                 Local types
 ****************************************************************************}
 
-{
-  TextRec and FileRec are put in a separate file to make it available to other
-  units without putting it explicitly in systemh.
-  This way we keep TP compatibility, and the TextRec definition is available
-  for everyone who needs it.
-}
-{$ifdef FPC_HAS_FEATURE_FILEIO}
-{$i filerec.inc}
-{$endif FPC_HAS_FEATURE_FILEIO}
-
-{$i textrec.inc}
-
 {$ifdef FPC_HAS_FEATURE_EXITCODE}
   {$ifdef FPC_OBJFPC_EXTENDED_IF}
     {$if High(errorcode)<>maxExitCode}

+ 14 - 2
rtl/inc/systemh.inc

@@ -495,8 +495,6 @@ type
 
   TSystemCodePage     = Word;
 
-  { Needed for fpc_get_output }
-  PText               = ^Text;
 
   TTextLineBreakStyle = (tlbsLF,tlbsCRLF,tlbsCR);
 
@@ -509,7 +507,21 @@ type
 { platform-dependent defines }
 {$i rtldefs.inc}
 
+{*****************************************************************************
+                   TextRec/FileRec exported to allow compiler to take size
+*****************************************************************************}
+
+{$ifdef FPC_HAS_FEATURE_FILEIO}
+{$i filerec.inc}
+{$endif FPC_HAS_FEATURE_FILEIO}
+
+{$i textrec.inc}
+
+
 type
+  { Needed for fpc_get_output }
+  PText               = ^Text;
+
   TEntryInformation = record
     InitFinalTable : Pointer;
     ThreadvarTablesTable : Pointer;