home *** CD-ROM | disk | FTP | other *** search
-
- {*******************************************************}
- { }
- { Delphi Runtime Library }
- { System Unit }
- { }
- { Copyright (C) 1988,95 Borland International }
- { }
- {*******************************************************}
-
- unit System;
-
- { This unit implements Delphi's runtime library. When compiling
- this unit, the compiler automatically includes a boot-strap symbol
- table (SYSTEM.TPS) which declares all built-in types, procedures, and
- functions. }
-
- {$IFDEF DPMI}
- {$C FIXED PRELOAD PERMANENT}
- {$ENDIF}
-
- {$IFDEF WINDOWS}
- {$C MOVEABLE PRELOAD PERMANENT}
- {$ENDIF}
-
- {$IFDEF MSDOS}
-
- {$L MAIN.OBJ} { Main module }
- {$L EXIT.OBJ} { Termination procedures }
- {$L HEAP.OBJ} { Heap manager }
- {$L ERRC.OBJ} { Error check routines }
- {$L EI86.OBJ} { Software emulator initialization }
- {$L EI87.OBJ} { Hardware emulator initialization }
- {$L EM86.OBJ} { Software 80x87 emulator }
- {$L EM87.OBJ} { Hardware 80x87 emulator }
- {$L F87H.OBJ} { 80x87 support routines }
- {$L EXCP.OBJ} { Exception handling routines }
-
- {$ENDIF}
-
- {$IFDEF DPMI}
-
- {$L DAPP.OBP} { DPMI application main module }
- {$L DLIB.OBP} { DPMI library main module }
- {$L EXIT.OBP} { DPMI termination procedures }
- {$L WMEM.OBP} { DPMI heap manager }
- {$L ERRC.OBP} { Error check routines }
- {$L EI86.OBP} { Software emulator initialization }
- {$L EI87.OBP} { Hardware emulator initialization }
- {$L EM86.OBP} { Software 80x87 emulator }
- {$L EM87.OBP} { Hardware 80x87 emulator }
- {$L F87H.OBP} { 80x87 support routines }
- {$L EXCP.OBP} { Exception handling routines }
-
- {$ENDIF}
-
- {$IFNDEF Windows}
-
- {$L OBJH.OBJ} { Object handling routines }
- {$L FDIV.OBJ} { Pentium-safe FDIV routines }
- {$L DF87.OBJ} { 80x87 Binary/Decimal routines }
- {$L TCTL.OBJ} { Textfile control routines }
- {$L TGPC.OBJ} { Textfile low-level I/O }
- {$L TCHR.OBJ} { Textfile character I/O }
- {$L TPCH.OBJ} { Textfile character array I/O}
- {$L TSTR.OBJ} { Textfile string I/O }
- {$L TBOL.OBJ} { Textfile boolean I/O }
- {$L TINT.OBJ} { Textfile integer I/O }
- {$L TF48.OBJ} { Textfile real I/O }
- {$L TF87.OBJ} { Textfile 80x87 I/O }
- {$L TFUN.OBJ} { Textfile support functions }
- {$L FCTL.OBJ} { File control routines }
- {$L FDIR.OBJ} { File utility routines }
- {$L CINT.OBJ} { Integer Str/Val routines }
- {$L CF48.OBJ} { Real Str/Val routines }
- {$L CF87.OBJ} { 80x87 Str/Val routines }
- {$L PARS.OBJ} { Command line parameter routines }
- {$L DIRH.OBJ} { Directory handling routines }
-
- {$ELSE}
-
- {$L WAPP.OBW} { Windows application main module }
- {$L WLIB.OBW} { Windows library main module }
- {$L EXIT.OBW} { Windows termination procedures }
- {$L WMEM.OBW} { Windows heap manager }
- {$L ERRC.OBW} { Error check routines }
- {$L OBJH.OBW} { Object handling routines }
- {$L FDIV.OBW} { Pentium-safe FDIV routines }
- {$L DF87.OBW} { 80x87 Binary/Decimal routines }
- {$L TCTL.OBW} { Textfile control routines }
- {$L TGPC.OBW} { Textfile low-level I/O }
- {$L TCHR.OBW} { Textfile character I/O }
- {$L TSTR.OBW} { Textfile string I/O }
- {$L TPCH.OBW} { Textfile character array I/O}
- {$L TBOL.OBW} { Textfile boolean I/O }
- {$L TINT.OBW} { Textfile integer I/O }
- {$L TF48.OBW} { Textfile real I/O }
- {$L TF87.OBW} { Textfile 80x87 I/O }
- {$L TFUN.OBW} { Textfile support functions }
- {$L FCTL.OBW} { File control routines }
- {$L FDIR.OBW} { File utility routines }
- {$L CINT.OBW} { Integer Str/Val routines }
- {$L CF48.OBW} { Real Str/Val routines }
- {$L CF87.OBW} { 80x87 Str/Val routines }
- {$L WPAR.OBW} { Command line parameter routines }
- {$L DIRH.OBW} { Directory handling routines }
- {$L WI87.OBW} { 80x87 initialization }
- {$L WX87.OBW} { 80x87 exception handler }
- {$L WE87.OBW} { 80x87 support routines }
- {$L WF87.OBJ} { 80x87 transcendental routines }
- {$L EXCP.OBW} { Exception handling routines }
-
- {$ENDIF}
-
- {$L VARH.OBJ} { Variable support routines }
- {$L LONG.OBJ} { Longint arithmetic routines }
- {$L LOVF.OBJ} { Longint arith with overflow checks }
- {$L STRH.OBJ} { String support routines }
- {$L SETH.OBJ} { Set support routines }
- {$L TFIO.OBJ} { Textfile open routine }
- {$L FP48.OBJ} { Real kernel routines }
- {$L F48H.OBJ} { Real support routines }
- {$L F48F.OBJ} { Real standard functions }
- {$L RAND.OBJ} { Random number generator }
- {$L DINT.OBJ} { Integer Binary/Decimal routines }
- {$L DF48.OBJ} { Real Binary/Decimal routines }
- {$L SINT.OBJ} { Integer Str/Val routines }
- {$L SF48.OBJ} { Real Str/Val routines }
- {$L SF87.OBJ} { 80x87 Str/Val routines }
- {$L FFUN.OBJ} { File support functions }
- {$L MEMH.OBJ} { Block move and fill routines }
- {$L CHAR.OBJ} { Character handling routines }
- {$L DMTH.OBJ} { Dynamic method call dispatcher }
- {$L CLSH.OBJ} { Class handling routines }
- {$L CLSF.OBJ} { Class standrad methods }
- {$L INFO.OBJ} { Standard type information }
-
- {$IFDEF MSDOS}
-
- {$L LAST.OBJ} { Data segment initialization }
-
- {$ENDIF}
-
- interface
-
- { type
- TObject = class;
- TClass = class of TObject;
- TObject = class
- constructor Create;
- destructor Destroy; virtual;
- procedure Free;
- class function NewInstance: TObject; virtual;
- procedure FreeInstance; virtual;
- class procedure InitInstance(Instance: Pointer): TObject;
- function ClassType: TClass;
- class function ClassName: string;
- class function ClassParent: TClass;
- class function ClassInfo: Pointer;
- class function InstanceSize: Word;
- class function InheritsForm(AClass: TClass): Boolean;
- procedure DefaultHandler(var Message); virtual;
- procedure Dispatch(var Message);
- class function MethodAddress(const Name: string): Pointer;
- class function MethodName(Address: Pointer): string;
- function FieldAddress(const Name: string): Pointer;
- end; }
-
- { const
- vtInteger = 0;
- vtBoolean = 1;
- vtChar = 2;
- vtExtended = 3;
- vtString = 4;
- vtPointer = 5;
- vtPChar = 6;
- vtObject = 7;
- vtClass = 8;
-
- type
- TVarRec = record
- case Integer of
- vtInteger: (VInteger: Longint; VType: Byte);
- vtBoolean: (VBoolean: Boolean);
- vtChar: (VChar: Char);
- vtExtended: (VExtended: PExtended);
- vtString: (VString: PString);
- vtPointer: (VPointer: Pointer);
- vtPChar: (VPChar: PChar);
- vtObject: (VObject: TObject);
- vtClass: (VClass: TClass);
- end; }
-
- { Initialized public variables. The compiler depends upon the order
- of declaration of the following typed constants, so it must not be
- changed. In addition, the following declaration section must be the
- first "const" section in this unit. }
-
- const
-
- ExitProc: Pointer = nil; { Exit procedure }
- ExitCode: Integer = 0; { Exit code }
- ErrorAddr: Pointer = nil; { Runtime error address }
- PrefixSeg: Word = 0; { Program segment prefix }
- InOutRes: Integer = 0; { I/O result buffer }
- RandSeed: Longint = 0; { Random seed }
- SelectorInc: Word = $1000; { Selector increment }
- HeapError: Pointer = nil; { Heap error function }
- Test8086: Byte = 0; { 80x86 test result }
- FileMode: Byte = 2; { File open mode }
-
- {$IFDEF MSDOS}
-
- OvrCodeList: Word = 0; { Overlay code segment list }
- OvrHeapSize: Word = 0; { Initial overlay buffer size }
- OvrDebugPtr: Pointer = nil; { Overlay debugger hook }
- OvrHeapOrg: Word = 0; { Overlay buffer origin }
- OvrHeapPtr: Word = 0; { Overlay buffer pointer }
- OvrHeapEnd: Word = 0; { Overlay buffer end }
- OvrLoadList: Word = 0; { Loaded overlays list }
- OvrDosHandle: Word = 0; { Overlay DOS handle }
- OvrEmsHandle: Word = $FFFF; { Overlay EMS handle }
- HeapOrg: Pointer = nil; { Heap origin }
- HeapPtr: Pointer = nil; { Heap pointer }
- HeapEnd: Pointer = nil; { Heap end }
- FreeList: Pointer = nil; { Free list pointer }
- FreeZero: Pointer = nil; { Must be zero }
- StackLimit: Word = 0; { Stack pointer low limit }
- Seg0040: Word = $0040; { Selector for segment $0040 }
- SegA000: Word = $A000; { Selector for segment $A000 }
- SegB000: Word = $B000; { Selector for segment $B000 }
- SegB800: Word = $B800; { Selector for segment $B800 }
- Test8087: Byte = 0; { 80x87 test result }
- TestFDIV: Byte = 0; { Flawed FDIV indicator }
-
- {$ENDIF}
-
- {$IFDEF DPMI}
-
- HInstance: Word = 0; { Module instance handle }
- HeapList: Word = 0; { Heap segment list }
- HeapLimit: Word = 1024; { Heap small block limit }
- HeapBlock: Word = 8192; { Heap block size }
- HeapAllocFlags: Word = 2; { Heap allocation flags, gmem_Moveable }
- Seg0040: Word = 0; { Selector for segment $0040 }
- SegA000: Word = 0; { Selector for segment $A000 }
- SegB000: Word = 0; { Selector for segment $B000 }
- SegB800: Word = 0; { Selector for segment $B800 }
- Test8087: Byte = 0; { 80x87 test result }
- TestFDIV: Byte = 0; { Flawed FDIV indicator }
- HaltVector: Word = 0; { Library init code halt vector }
-
- {$ENDIF}
-
- {$IFDEF Windows}
-
- HPrevInst: Word = 0; { Handle of previous instance }
- HInstance: Word = 0; { Handle of this instance }
- CmdShow: Integer = 0; { CmdShow parameter for CreateWindow }
- CmdLine: PChar = nil; { Command line pointer }
- HeapList: Word = 0; { Heap segment list }
- HeapLimit: Word = 1024; { Heap small block limit }
- HeapBlock: Word = 8192; { Heap block size }
- HeapAllocFlags: Word = 2; { Heap allocation flags, gmem_Moveable }
- TestFDIV: Byte = 0; { Flawed FDIV indicator }
- HaltVector: Word = 0; { Library init code halt vector }
-
- {$ENDIF}
-
- { Uninitialized public variables. The compiler depends upon the order
- of declaration of the following variables, so it must not be changed.
- In addition, the following declaration section must be the first "var"
- section in this unit. }
-
- var
-
- Input: Text; { Input standard file }
- Output: Text; { Output standard file }
-
- {$IFDEF MSDOS}
-
- SaveInt00: Pointer; { Saved interrupt $00 }
- SaveInt02: Pointer; { Saved interrupt $02 }
- SaveInt1B: Pointer; { Saved interrupt $1B }
- SaveInt21: Pointer; { Saved interrupt $21 }
- SaveInt23: Pointer; { Saved interrupt $23 }
- SaveInt24: Pointer; { Saved interrupt $24 }
- SaveInt34: Pointer; { Saved interrupt $34 }
- SaveInt35: Pointer; { Saved interrupt $35 }
- SaveInt36: Pointer; { Saved interrupt $36 }
- SaveInt37: Pointer; { Saved interrupt $37 }
- SaveInt38: Pointer; { Saved interrupt $38 }
- SaveInt39: Pointer; { Saved interrupt $39 }
- SaveInt3A: Pointer; { Saved interrupt $3A }
- SaveInt3B: Pointer; { Saved interrupt $3B }
- SaveInt3C: Pointer; { Saved interrupt $3C }
- SaveInt3D: Pointer; { Saved interrupt $3D }
- SaveInt3E: Pointer; { Saved interrupt $3E }
- SaveInt3F: Pointer; { Saved interrupt $3F }
- SaveInt75: Pointer; { Saved interrupt $75 }
-
- {$ENDIF}
-
- {$IFDEF DPMI}
-
- SaveInt00: Pointer; { Saved exception $00 }
- SaveInt02: Pointer; { Saved interrupt $02 }
- SaveInt0C: Pointer; { Saved exception $0C }
- SaveInt0D: Pointer; { Saved exception $0D }
- SaveInt1B: Pointer; { Saved interrupt $1B }
- SaveInt21: Pointer; { Saved interrupt $21 }
- SaveInt23: Pointer; { Saved real mode interrupt $23 }
- SaveInt24: Pointer; { Saved real mode interrupt $24 }
- SaveInt34: Pointer; { Saved interrupt $34 }
- SaveInt35: Pointer; { Saved interrupt $35 }
- SaveInt36: Pointer; { Saved interrupt $36 }
- SaveInt37: Pointer; { Saved interrupt $37 }
- SaveInt38: Pointer; { Saved interrupt $38 }
- SaveInt39: Pointer; { Saved interrupt $39 }
- SaveInt3A: Pointer; { Saved interrupt $3A }
- SaveInt3B: Pointer; { Saved interrupt $3B }
- SaveInt3C: Pointer; { Saved interrupt $3C }
- SaveInt3D: Pointer; { Saved interrupt $3D }
- SaveInt3E: Pointer; { Saved interrupt $3E }
- SaveInt3F: Pointer; { Saved interrupt $3F }
- SaveInt75: Pointer; { Saved interrupt $75 }
-
- RealModeRegs: array[0..49] of Byte; { Real mode call-back registers }
-
- {$ENDIF}
-
- { Public procedures and functions. The compiler depends upon the order
- of declaration of the following procedures and functions, so it must not
- be changed. In addition, no other procedures or functions can be declared
- in the interface part. }
-
- procedure FSafeDivide;
- procedure FSafeDivideR;
-
- implementation
-