home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk14 / doc.pak / SYSTEM.INT < prev    next >
Encoding:
Text File  |  1995-08-24  |  13.8 KB  |  341 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Runtime Library                          }
  5. {       System Unit                                     }
  6. {                                                       }
  7. {       Copyright (C) 1988,95 Borland International     }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit System;
  12.  
  13. { This unit implements Delphi's runtime library. When compiling
  14.   this unit, the compiler automatically includes a boot-strap symbol
  15.   table (SYSTEM.TPS) which declares all built-in types, procedures, and
  16.   functions. }
  17.  
  18. {$IFDEF DPMI}
  19. {$C FIXED PRELOAD PERMANENT}
  20. {$ENDIF}
  21.  
  22. {$IFDEF WINDOWS}
  23. {$C MOVEABLE PRELOAD PERMANENT}
  24. {$ENDIF}
  25.  
  26. {$IFDEF MSDOS}
  27.  
  28. {$L MAIN.OBJ}           { Main module }
  29. {$L EXIT.OBJ}           { Termination procedures }
  30. {$L HEAP.OBJ}           { Heap manager }
  31. {$L ERRC.OBJ}           { Error check routines }
  32. {$L EI86.OBJ}           { Software emulator initialization }
  33. {$L EI87.OBJ}           { Hardware emulator initialization }
  34. {$L EM86.OBJ}           { Software 80x87 emulator }
  35. {$L EM87.OBJ}           { Hardware 80x87 emulator }
  36. {$L F87H.OBJ}           { 80x87 support routines }
  37. {$L EXCP.OBJ}           { Exception handling routines }
  38.  
  39. {$ENDIF}
  40.  
  41. {$IFDEF DPMI}
  42.  
  43. {$L DAPP.OBP}           { DPMI application main module }
  44. {$L DLIB.OBP}           { DPMI library main module }
  45. {$L EXIT.OBP}           { DPMI termination procedures }
  46. {$L WMEM.OBP}           { DPMI heap manager }
  47. {$L ERRC.OBP}           { Error check routines }
  48. {$L EI86.OBP}           { Software emulator initialization }
  49. {$L EI87.OBP}           { Hardware emulator initialization }
  50. {$L EM86.OBP}           { Software 80x87 emulator }
  51. {$L EM87.OBP}           { Hardware 80x87 emulator }
  52. {$L F87H.OBP}           { 80x87 support routines }
  53. {$L EXCP.OBP}           { Exception handling routines }
  54.  
  55. {$ENDIF}
  56.  
  57. {$IFNDEF Windows}
  58.  
  59. {$L OBJH.OBJ}           { Object handling routines }
  60. {$L FDIV.OBJ}           { Pentium-safe FDIV routines }
  61. {$L DF87.OBJ}           { 80x87 Binary/Decimal routines }
  62. {$L TCTL.OBJ}           { Textfile control routines }
  63. {$L TGPC.OBJ}           { Textfile low-level I/O }
  64. {$L TCHR.OBJ}           { Textfile character I/O }
  65. {$L TPCH.OBJ}           { Textfile character array I/O}
  66. {$L TSTR.OBJ}           { Textfile string I/O }
  67. {$L TBOL.OBJ}           { Textfile boolean I/O }
  68. {$L TINT.OBJ}           { Textfile integer I/O }
  69. {$L TF48.OBJ}           { Textfile real I/O }
  70. {$L TF87.OBJ}           { Textfile 80x87 I/O }
  71. {$L TFUN.OBJ}           { Textfile support functions }
  72. {$L FCTL.OBJ}           { File control routines }
  73. {$L FDIR.OBJ}           { File utility routines }
  74. {$L CINT.OBJ}           { Integer Str/Val routines }
  75. {$L CF48.OBJ}           { Real Str/Val routines }
  76. {$L CF87.OBJ}           { 80x87 Str/Val routines }
  77. {$L PARS.OBJ}           { Command line parameter routines }
  78. {$L DIRH.OBJ}           { Directory handling routines }
  79.  
  80. {$ELSE}
  81.  
  82. {$L WAPP.OBW}           { Windows application main module }
  83. {$L WLIB.OBW}           { Windows library main module }
  84. {$L EXIT.OBW}           { Windows termination procedures }
  85. {$L WMEM.OBW}           { Windows heap manager }
  86. {$L ERRC.OBW}           { Error check routines }
  87. {$L OBJH.OBW}           { Object handling routines }
  88. {$L FDIV.OBW}           { Pentium-safe FDIV routines }
  89. {$L DF87.OBW}           { 80x87 Binary/Decimal routines }
  90. {$L TCTL.OBW}           { Textfile control routines }
  91. {$L TGPC.OBW}           { Textfile low-level I/O }
  92. {$L TCHR.OBW}           { Textfile character I/O }
  93. {$L TSTR.OBW}           { Textfile string I/O }
  94. {$L TPCH.OBW}           { Textfile character array I/O}
  95. {$L TBOL.OBW}           { Textfile boolean I/O }
  96. {$L TINT.OBW}           { Textfile integer I/O }
  97. {$L TF48.OBW}           { Textfile real I/O }
  98. {$L TF87.OBW}           { Textfile 80x87 I/O }
  99. {$L TFUN.OBW}           { Textfile support functions }
  100. {$L FCTL.OBW}           { File control routines }
  101. {$L FDIR.OBW}           { File utility routines }
  102. {$L CINT.OBW}           { Integer Str/Val routines }
  103. {$L CF48.OBW}           { Real Str/Val routines }
  104. {$L CF87.OBW}           { 80x87 Str/Val routines }
  105. {$L WPAR.OBW}           { Command line parameter routines }
  106. {$L DIRH.OBW}           { Directory handling routines }
  107. {$L WI87.OBW}           { 80x87 initialization }
  108. {$L WX87.OBW}           { 80x87 exception handler }
  109. {$L WE87.OBW}           { 80x87 support routines }
  110. {$L WF87.OBJ}           { 80x87 transcendental routines }
  111. {$L EXCP.OBW}           { Exception handling routines }
  112.  
  113. {$ENDIF}
  114.  
  115. {$L VARH.OBJ}           { Variable support routines }
  116. {$L LONG.OBJ}           { Longint arithmetic routines }
  117. {$L LOVF.OBJ}           { Longint arith with overflow checks }
  118. {$L STRH.OBJ}           { String support routines }
  119. {$L SETH.OBJ}           { Set support routines }
  120. {$L TFIO.OBJ}           { Textfile open routine }
  121. {$L FP48.OBJ}           { Real kernel routines }
  122. {$L F48H.OBJ}           { Real support routines }
  123. {$L F48F.OBJ}           { Real standard functions }
  124. {$L RAND.OBJ}           { Random number generator }
  125. {$L DINT.OBJ}           { Integer Binary/Decimal routines }
  126. {$L DF48.OBJ}           { Real Binary/Decimal routines }
  127. {$L SINT.OBJ}           { Integer Str/Val routines }
  128. {$L SF48.OBJ}           { Real Str/Val routines }
  129. {$L SF87.OBJ}           { 80x87 Str/Val routines }
  130. {$L FFUN.OBJ}           { File support functions }
  131. {$L MEMH.OBJ}           { Block move and fill routines }
  132. {$L CHAR.OBJ}           { Character handling routines }
  133. {$L DMTH.OBJ}           { Dynamic method call dispatcher }
  134. {$L CLSH.OBJ}           { Class handling routines }
  135. {$L CLSF.OBJ}           { Class standrad methods }
  136. {$L INFO.OBJ}           { Standard type information }
  137.  
  138. {$IFDEF MSDOS}
  139.  
  140. {$L LAST.OBJ}           { Data segment initialization }
  141.  
  142. {$ENDIF}
  143.  
  144. interface
  145.  
  146. { type
  147.     TObject = class;
  148.     TClass = class of TObject;
  149.     TObject = class
  150.       constructor Create;
  151.       destructor Destroy; virtual;
  152.       procedure Free;
  153.       class function NewInstance: TObject; virtual;
  154.       procedure FreeInstance; virtual;
  155.       class procedure InitInstance(Instance: Pointer): TObject;
  156.       function ClassType: TClass;
  157.       class function ClassName: string;
  158.       class function ClassParent: TClass;
  159.       class function ClassInfo: Pointer;
  160.       class function InstanceSize: Word;
  161.       class function InheritsForm(AClass: TClass): Boolean;
  162.       procedure DefaultHandler(var Message); virtual;
  163.       procedure Dispatch(var Message);
  164.       class function MethodAddress(const Name: string): Pointer;
  165.       class function MethodName(Address: Pointer): string;
  166.       function FieldAddress(const Name: string): Pointer;
  167.     end; }
  168.  
  169. { const
  170.     vtInteger  = 0;
  171.     vtBoolean  = 1;
  172.     vtChar     = 2;
  173.     vtExtended = 3;
  174.     vtString   = 4;
  175.     vtPointer  = 5;
  176.     vtPChar    = 6;
  177.     vtObject   = 7;
  178.     vtClass    = 8;
  179.  
  180.   type
  181.     TVarRec = record
  182.       case Integer of
  183.         vtInteger:  (VInteger: Longint; VType: Byte);
  184.         vtBoolean:  (VBoolean: Boolean);
  185.         vtChar:     (VChar: Char);
  186.         vtExtended: (VExtended: PExtended);
  187.         vtString:   (VString: PString);
  188.         vtPointer:  (VPointer: Pointer);
  189.         vtPChar:    (VPChar: PChar);
  190.         vtObject:   (VObject: TObject);
  191.         vtClass:    (VClass: TClass);
  192.     end; }
  193.  
  194. { Initialized public variables. The compiler depends upon the order
  195.   of declaration of the following typed constants, so it must not be
  196.   changed. In addition, the following declaration section must be the
  197.   first "const" section in this unit. }
  198.  
  199. const
  200.  
  201.   ExitProc: Pointer = nil;      { Exit procedure }
  202.   ExitCode: Integer = 0;        { Exit code }
  203.   ErrorAddr: Pointer = nil;     { Runtime error address }
  204.   PrefixSeg: Word = 0;          { Program segment prefix }
  205.   InOutRes: Integer = 0;        { I/O result buffer }
  206.   RandSeed: Longint = 0;        { Random seed }
  207.   SelectorInc: Word = $1000;    { Selector increment }
  208.   HeapError: Pointer = nil;     { Heap error function }
  209.   Test8086: Byte = 0;           { 80x86 test result }
  210.   FileMode: Byte = 2;           { File open mode }
  211.  
  212. {$IFDEF MSDOS}
  213.  
  214.   OvrCodeList: Word = 0;        { Overlay code segment list }
  215.   OvrHeapSize: Word = 0;        { Initial overlay buffer size }
  216.   OvrDebugPtr: Pointer = nil;   { Overlay debugger hook }
  217.   OvrHeapOrg: Word = 0;         { Overlay buffer origin }
  218.   OvrHeapPtr: Word = 0;         { Overlay buffer pointer }
  219.   OvrHeapEnd: Word = 0;         { Overlay buffer end }
  220.   OvrLoadList: Word = 0;        { Loaded overlays list }
  221.   OvrDosHandle: Word = 0;       { Overlay DOS handle }
  222.   OvrEmsHandle: Word = $FFFF;   { Overlay EMS handle }
  223.   HeapOrg: Pointer = nil;       { Heap origin }
  224.   HeapPtr: Pointer = nil;       { Heap pointer }
  225.   HeapEnd: Pointer = nil;       { Heap end }
  226.   FreeList: Pointer = nil;      { Free list pointer }
  227.   FreeZero: Pointer = nil;      { Must be zero }
  228.   StackLimit: Word = 0;         { Stack pointer low limit }
  229.   Seg0040: Word = $0040;        { Selector for segment $0040 }
  230.   SegA000: Word = $A000;        { Selector for segment $A000 }
  231.   SegB000: Word = $B000;        { Selector for segment $B000 }
  232.   SegB800: Word = $B800;        { Selector for segment $B800 }
  233.   Test8087: Byte = 0;           { 80x87 test result }
  234.   TestFDIV: Byte = 0;           { Flawed FDIV indicator }
  235.  
  236. {$ENDIF}
  237.  
  238. {$IFDEF DPMI}
  239.  
  240.   HInstance: Word = 0;          { Module instance handle }
  241.   HeapList: Word = 0;           { Heap segment list }
  242.   HeapLimit: Word = 1024;       { Heap small block limit }
  243.   HeapBlock: Word = 8192;       { Heap block size }
  244.   HeapAllocFlags: Word = 2;     { Heap allocation flags, gmem_Moveable }
  245.   Seg0040: Word = 0;            { Selector for segment $0040 }
  246.   SegA000: Word = 0;            { Selector for segment $A000 }
  247.   SegB000: Word = 0;            { Selector for segment $B000 }
  248.   SegB800: Word = 0;            { Selector for segment $B800 }
  249.   Test8087: Byte = 0;           { 80x87 test result }
  250.   TestFDIV: Byte = 0;           { Flawed FDIV indicator }
  251.   HaltVector: Word = 0;        { Library init code halt vector }
  252.  
  253. {$ENDIF}
  254.  
  255. {$IFDEF Windows}
  256.  
  257.   HPrevInst: Word = 0;          { Handle of previous instance }
  258.   HInstance: Word = 0;          { Handle of this instance }
  259.   CmdShow: Integer = 0;         { CmdShow parameter for CreateWindow }
  260.   CmdLine: PChar = nil;         { Command line pointer }
  261.   HeapList: Word = 0;           { Heap segment list }
  262.   HeapLimit: Word = 1024;       { Heap small block limit }
  263.   HeapBlock: Word = 8192;       { Heap block size }
  264.   HeapAllocFlags: Word = 2;     { Heap allocation flags, gmem_Moveable }
  265.   TestFDIV: Byte = 0;           { Flawed FDIV indicator }
  266.   HaltVector: Word = 0;        { Library init code halt vector }
  267.  
  268. {$ENDIF}
  269.  
  270. { Uninitialized public variables. The compiler depends upon the order
  271.   of declaration of the following variables, so it must not be changed.
  272.   In addition, the following declaration section must be the first "var"
  273.   section in this unit. }
  274.  
  275. var
  276.  
  277.   Input: Text;                  { Input standard file }
  278.   Output: Text;                 { Output standard file }
  279.  
  280. {$IFDEF MSDOS}
  281.  
  282.   SaveInt00: Pointer;           { Saved interrupt $00 }
  283.   SaveInt02: Pointer;           { Saved interrupt $02 }
  284.   SaveInt1B: Pointer;           { Saved interrupt $1B }
  285.   SaveInt21: Pointer;           { Saved interrupt $21 }
  286.   SaveInt23: Pointer;           { Saved interrupt $23 }
  287.   SaveInt24: Pointer;           { Saved interrupt $24 }
  288.   SaveInt34: Pointer;           { Saved interrupt $34 }
  289.   SaveInt35: Pointer;           { Saved interrupt $35 }
  290.   SaveInt36: Pointer;           { Saved interrupt $36 }
  291.   SaveInt37: Pointer;           { Saved interrupt $37 }
  292.   SaveInt38: Pointer;           { Saved interrupt $38 }
  293.   SaveInt39: Pointer;           { Saved interrupt $39 }
  294.   SaveInt3A: Pointer;           { Saved interrupt $3A }
  295.   SaveInt3B: Pointer;           { Saved interrupt $3B }
  296.   SaveInt3C: Pointer;           { Saved interrupt $3C }
  297.   SaveInt3D: Pointer;           { Saved interrupt $3D }
  298.   SaveInt3E: Pointer;           { Saved interrupt $3E }
  299.   SaveInt3F: Pointer;           { Saved interrupt $3F }
  300.   SaveInt75: Pointer;           { Saved interrupt $75 }
  301.  
  302. {$ENDIF}
  303.  
  304. {$IFDEF DPMI}
  305.  
  306.   SaveInt00: Pointer;           { Saved exception $00 }
  307.   SaveInt02: Pointer;           { Saved interrupt $02 }
  308.   SaveInt0C: Pointer;           { Saved exception $0C }
  309.   SaveInt0D: Pointer;           { Saved exception $0D }
  310.   SaveInt1B: Pointer;           { Saved interrupt $1B }
  311.   SaveInt21: Pointer;           { Saved interrupt $21 }
  312.   SaveInt23: Pointer;           { Saved real mode interrupt $23 }
  313.   SaveInt24: Pointer;           { Saved real mode interrupt $24 }
  314.   SaveInt34: Pointer;           { Saved interrupt $34 }
  315.   SaveInt35: Pointer;           { Saved interrupt $35 }
  316.   SaveInt36: Pointer;           { Saved interrupt $36 }
  317.   SaveInt37: Pointer;           { Saved interrupt $37 }
  318.   SaveInt38: Pointer;           { Saved interrupt $38 }
  319.   SaveInt39: Pointer;           { Saved interrupt $39 }
  320.   SaveInt3A: Pointer;           { Saved interrupt $3A }
  321.   SaveInt3B: Pointer;           { Saved interrupt $3B }
  322.   SaveInt3C: Pointer;           { Saved interrupt $3C }
  323.   SaveInt3D: Pointer;           { Saved interrupt $3D }
  324.   SaveInt3E: Pointer;           { Saved interrupt $3E }
  325.   SaveInt3F: Pointer;           { Saved interrupt $3F }
  326.   SaveInt75: Pointer;           { Saved interrupt $75 }
  327.  
  328.   RealModeRegs: array[0..49] of Byte; { Real mode call-back registers }
  329.  
  330. {$ENDIF}
  331.  
  332. { Public procedures and functions. The compiler depends upon the order
  333.   of declaration of the following procedures and functions, so it must not
  334.   be changed. In addition, no other procedures or functions can be declared
  335.   in the interface part. }
  336.  
  337. procedure FSafeDivide;
  338. procedure FSafeDivideR;
  339.  
  340. implementation
  341.