2020-05-22 00:01:43 +02:00
|
|
|
(*
|
2020-06-07 18:39:30 +02:00
|
|
|
KolibriOS RTL System unit
|
2020-05-22 00:01:43 +02:00
|
|
|
*)
|
|
|
|
|
|
|
|
unit System;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
type
|
|
|
|
PPAnsiChar = ^PAnsiChar;
|
|
|
|
|
2020-06-12 10:51:31 +02:00
|
|
|
KolibriChar = AnsiChar;
|
|
|
|
PKolibriChar = PAnsiChar;
|
|
|
|
PPKolibriChar = PPAnsiChar;
|
|
|
|
|
|
|
|
{$IF CompilerVersion < 15}
|
|
|
|
UInt64 = Int64;
|
|
|
|
{$IFEND}
|
|
|
|
|
2020-05-24 00:32:23 +02:00
|
|
|
THandle = LongWord;
|
|
|
|
|
2020-06-09 02:30:39 +02:00
|
|
|
PByte = ^Byte;
|
|
|
|
PWord = ^Word;
|
|
|
|
PLongWord = ^LongWord;
|
|
|
|
PLongInt = ^LongInt;
|
|
|
|
PInt64 = ^Int64;
|
2020-06-09 22:03:10 +02:00
|
|
|
{$IF CompilerVersion >= 15}
|
|
|
|
PUInt64 = ^UInt64;
|
2020-06-09 02:30:39 +02:00
|
|
|
{$IFEND}
|
|
|
|
|
|
|
|
PCardinal = ^Cardinal;
|
|
|
|
PInteger = ^Integer;
|
|
|
|
|
|
|
|
PExtended = ^Extended;
|
|
|
|
PCurrency = ^Currency;
|
|
|
|
|
|
|
|
PShortString = ^ShortString;
|
|
|
|
|
|
|
|
PVariant = ^Variant;
|
|
|
|
|
2020-05-22 00:01:43 +02:00
|
|
|
TGUID = record
|
|
|
|
D1: LongWord;
|
|
|
|
D2: Word;
|
|
|
|
D3: Word;
|
|
|
|
D4: array [0..7] of Byte;
|
|
|
|
end;
|
|
|
|
|
2020-06-07 18:39:30 +02:00
|
|
|
PProcedure = procedure;
|
|
|
|
|
|
|
|
TPackageUnitEntry = packed record
|
|
|
|
Init, Finalize: PProcedure;
|
|
|
|
end;
|
|
|
|
|
|
|
|
PUnitEntryTable = ^TUnitEntryTable;
|
|
|
|
TUnitEntryTable = array [0..99999999] of TPackageUnitEntry;
|
|
|
|
|
|
|
|
PPackageInfo = ^TPackageInfo;
|
|
|
|
TPackageInfo = packed record
|
|
|
|
UnitCount: Integer;
|
|
|
|
UnitInfo: PUnitEntryTable;
|
|
|
|
end;
|
|
|
|
|
2020-05-22 00:01:43 +02:00
|
|
|
PInitContext = ^TInitContext;
|
|
|
|
TInitContext = record
|
2020-06-07 18:39:30 +02:00
|
|
|
InitTable: PPackageInfo;
|
|
|
|
InitCount: Integer;
|
2020-05-22 00:01:43 +02:00
|
|
|
OuterContext: PInitContext;
|
|
|
|
end;
|
|
|
|
|
2020-06-18 20:28:45 +02:00
|
|
|
const
|
|
|
|
vtInteger = 0;
|
|
|
|
vtBoolean = 1;
|
|
|
|
vtChar = 2;
|
|
|
|
vtExtended = 3;
|
|
|
|
vtString = 4;
|
|
|
|
vtPointer = 5;
|
|
|
|
vtPChar = 6;
|
|
|
|
vtObject = 7;
|
|
|
|
vtClass = 8;
|
|
|
|
vtWideChar = 9;
|
|
|
|
vtPWideChar = 10;
|
|
|
|
vtAnsiString = 11;
|
|
|
|
vtCurrency = 12;
|
|
|
|
vtVariant = 13;
|
|
|
|
vtInterface = 14;
|
|
|
|
vtWideString = 15;
|
|
|
|
vtInt64 = 16;
|
2020-06-09 22:03:10 +02:00
|
|
|
|
2020-06-18 20:28:45 +02:00
|
|
|
type
|
2020-06-09 02:30:39 +02:00
|
|
|
PVarRec = ^TVarRec;
|
2020-06-18 20:28:45 +02:00
|
|
|
TVarRec = record
|
|
|
|
case Byte of
|
|
|
|
vtInteger: (VInteger: Integer; VType: Byte);
|
|
|
|
vtBoolean: (VBoolean: Boolean);
|
|
|
|
vtChar: (VChar: AnsiChar);
|
|
|
|
vtExtended: (VExtended: PExtended);
|
|
|
|
vtString: (VString: PShortString);
|
|
|
|
vtPointer: (VPointer: Pointer);
|
|
|
|
vtPChar: (VPChar: PAnsiChar);
|
|
|
|
vtObject: (VObject: Pointer);
|
|
|
|
vtClass: (VClass: Pointer);
|
|
|
|
vtWideChar: (VWideChar: WideChar);
|
|
|
|
vtPWideChar: (VPWideChar: PWideChar);
|
|
|
|
vtAnsiString: (VAnsiString: Pointer);
|
|
|
|
vtCurrency: (VCurrency: PCurrency);
|
|
|
|
vtVariant: (VVariant: PVariant);
|
|
|
|
vtInterface: (VInterface: Pointer);
|
|
|
|
vtWideString: (VWideString: Pointer);
|
|
|
|
vtInt64: (VInt64: PInt64);
|
2020-06-09 02:30:39 +02:00
|
|
|
end;
|
|
|
|
|
2020-06-07 20:55:00 +02:00
|
|
|
procedure _Halt0;
|
2020-05-22 00:01:43 +02:00
|
|
|
procedure _HandleFinally;
|
2020-06-07 18:39:30 +02:00
|
|
|
procedure _StartExe(InitTable: PPackageInfo);
|
2020-05-22 00:01:43 +02:00
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
SysInit;
|
|
|
|
|
2020-06-07 18:39:30 +02:00
|
|
|
var
|
|
|
|
InitContext: TInitContext;
|
2020-06-07 20:55:00 +02:00
|
|
|
|
2020-05-22 00:01:43 +02:00
|
|
|
procedure _HandleFinally;
|
|
|
|
asm
|
|
|
|
end;
|
|
|
|
|
2020-06-07 18:39:30 +02:00
|
|
|
procedure InitUnits;
|
|
|
|
var
|
|
|
|
Idx: Integer;
|
|
|
|
begin
|
|
|
|
if InitContext.InitTable <> nil then
|
|
|
|
with InitContext.InitTable^ do
|
|
|
|
begin
|
|
|
|
Idx := 0;
|
|
|
|
while Idx < UnitCount do
|
|
|
|
begin
|
|
|
|
with UnitInfo[Idx] do
|
|
|
|
begin
|
|
|
|
if Assigned(Init) then
|
|
|
|
Init;
|
|
|
|
end;
|
|
|
|
Inc(Idx);
|
|
|
|
InitContext.InitCount := Idx;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure FinalizeUnits;
|
|
|
|
begin
|
|
|
|
if InitContext.InitTable <> nil then
|
|
|
|
begin
|
|
|
|
with InitContext do
|
|
|
|
begin
|
|
|
|
while InitCount > 0 do
|
|
|
|
begin
|
|
|
|
Dec(InitCount);
|
|
|
|
with InitTable.UnitInfo[InitCount] do
|
|
|
|
if Assigned(Finalize) then
|
|
|
|
Finalize;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure _StartExe(InitTable: PPackageInfo);
|
|
|
|
begin
|
|
|
|
InitContext.InitTable := InitTable;
|
|
|
|
InitContext.InitCount := 0;
|
|
|
|
InitUnits;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure _Halt0;
|
|
|
|
begin
|
|
|
|
FinalizeUnits;
|
|
|
|
asm
|
|
|
|
OR EAX, -1
|
|
|
|
INT $40
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2020-05-24 00:32:23 +02:00
|
|
|
end.
|