|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 18432 (0x4800)
Types: Ada Source
Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Discrete, package body Interchange, package body Operations, package body Vector, seg_0009ca
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
└─⟦5a81ac88f⟧ »Space Info Vol 1«
└─⟦this⟧
with Interchange_Float;
package body Interchange is
Radix : constant Long_Integer := Long_Integer (Byte'Last) + 1;
subtype Signed_Byte_Range is
Long_Integer range
-(Radix / 2) .. (Radix / 2) - 1;
Scale : constant Standard.Integer
:= Interchange_Defs.Duration_Magnitude;
Unscale : constant Standard.Integer := (10 ** 9) / Scale;
pragma Assert (Scale = (10 ** 9) / Unscale);
subtype Padding_Type is Byte_String (1 .. 1);
Padding : constant Padding_Type := (others => 0);
function Convert (X : Standard.Duration) return Interchange.Duration is
Seconds : Interchange.Integer;
Nanoseconds : Interchange.Nanosecond_Count;
Temp : Standard.Integer;
Temp1 : Standard.Duration;
begin
Seconds := Interchange.Integer (X);
if (X - Standard.Duration (Seconds)) < 0.0 then
Seconds := Seconds - 1;
end if;
pragma Assert ((X - Standard.Duration (Seconds)) >= 0.0);
pragma Assert ((X - Standard.Duration (Seconds)) < 1.0);
Temp1 := (X - Standard.Duration (Seconds)) * Scale;
Temp := Standard.Integer (Temp1);
Temp := Temp * Unscale;
Nanoseconds := Interchange.Nanosecond_Count (Temp);
if Nanoseconds >= 10 ** 9 then
-- duration'delta < 10 ** -9
Seconds := Seconds + 1;
Nanoseconds := 0;
end if;
return Interchange.Duration'(Seconds, Nanoseconds);
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Convert;
function Convert (X : Interchange.Duration) return Standard.Duration is
begin
return Standard.Duration (X.Seconds) +
(Standard.Duration
(Standard.Integer (X.Nanoseconds) / Unscale) / Scale);
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Convert;
function Convert (X : Calendar.Time) return Interchange.Time is
Seconds : Calendar.Day_Duration;
Y : Time;
begin
Calendar.Split
(X, Calendar.Year_Number (Y.Year), Calendar.Month_Number (Y.Month),
Calendar.Day_Number (Y.Day),
Seconds);
Y.Seconds := Convert (Seconds);
return Y;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Convert;
function Convert (X : Interchange.Time) return Calendar.Time is
begin
return Calendar.Time_Of
(Calendar.Year_Number (X.Year),
Calendar.Month_Number (X.Month),
Calendar.Day_Number (X.Day),
Convert (X.Seconds));
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Convert;
package body Operations is
procedure Put (Into : Stream_Id;
Data : Long_Integer;
Bytes : Interchange.Natural) is
Data_Copy : Long_Integer := Data;
Data_Byte : Byte_String (1 .. Standard.Natural (Bytes));
Temp : Long_Integer;
begin
if Bytes <= 0 then
if Data /= 0 then
raise Interchange.Constraint_Error;
end if;
else
for I in reverse 2 .. Data_Byte'Last loop
Temp := Data_Copy mod Radix;
Data_Byte (I) := Byte (Temp);
Data_Copy := (Data_Copy - Temp) / Radix;
end loop;
Data_Byte (1) := Byte (Signed_Byte_Range (Data_Copy) mod Radix);
Put (Into, Data_Byte);
end if;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Put;
procedure Get (From : Stream_Id;
Data : out Long_Integer;
Bytes : Interchange.Natural) is
Data_Byte : Byte_String (1 .. Standard.Natural (Bytes));
Data_Copy : Long_Integer;
begin
if Bytes <= 0 then
Data := 0;
else
Get (From, Data_Byte);
Data_Copy := Long_Integer (Data_Byte (1));
if Data_Copy > Signed_Byte_Range'Last then
Data_Copy := Data_Copy - Radix;
end if;
for I in 2 .. Data_Byte'Last loop
Data_Copy := (Data_Copy * Radix)
+ Long_Integer (Data_Byte (I));
end loop;
Data := Data_Copy;
end if;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get;
procedure Put (Into : Stream_Id; Data : Interchange.Short_Integer) is
begin
Put (Into, Long_Integer (Data), 2);
end Put;
procedure Get (From : Stream_Id;
Data : out Interchange.Short_Integer) is
begin
Get (From, Long_Integer (Data), 2);
end Get;
procedure Put (Into : Stream_Id; Data : Interchange.Integer) is
begin
Put (Into, Long_Integer (Data), 4);
end Put;
procedure Get (From : Stream_Id;
Data : out Interchange.Integer) is
begin
Get (From, Long_Integer (Data), 4);
end Get;
procedure Put (Into : Stream_Id; Data : Long_Integer) is
Data_Copy : Long_Integer := Data;
Bytes : Interchange.Natural;
begin
if Data_Copy = 0 then
Bytes := 0;
else
Bytes := 1;
while not (Data_Copy in Signed_Byte_Range) loop
Bytes := Bytes + 1;
Data_Copy := Data_Copy / Radix;
end loop;
end if;
Put (Into, Bytes);
Put (Into, Data, Bytes);
if Bytes mod 2 /= 0 then
Put (Into, Padding);
end if;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Put;
procedure Get (From : Stream_Id; Data : out Interchange.Long_Integer) is
Bytes : Interchange.Natural; -- JMK 7/14/86
Padding : Padding_Type;
begin
Get (From, Bytes);
Get (From, Data, Bytes);
if Bytes mod 2 /= 0 then
Get (From, Padding);
end if;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get;
procedure Put (Into : Stream_Id; Data : Interchange.Float) is
begin
Put (Into, Byte_String (Interchange_Float.Convert
(Interchange_Defs.Float (Data))));
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Put;
procedure Put (Into : Stream_Id; Data : Interchange.Long_Float) is
begin
Put (Into, Byte_String (Interchange_Float.Convert
(Interchange_Defs.Long_Float (Data))));
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Put;
procedure Get (From : Stream_Id; Data : out Interchange.Float) is
Bytes : Interchange_Float.Float;
begin
Get (From, Byte_String (Bytes));
Data := Interchange.Float (Interchange_Float.Convert (Bytes));
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get;
procedure Get (From : Stream_Id; Data : out Interchange.Long_Float) is
Bytes : Interchange_Float.Long_Float;
begin
Get (From, Byte_String (Bytes));
Data := Interchange.Long_Float (Interchange_Float.Convert (Bytes));
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get;
procedure Put (Into : Stream_Id; Data : Interchange.Duration) is
begin
Put (Into, Data.Seconds);
Put (Into, Data.Nanoseconds);
end Put;
procedure Get (From : Stream_Id; Data : out Interchange.Duration) is
begin
Get (From, Data.Seconds);
Get (From, Data.Nanoseconds);
end Get;
procedure Put (Into : Stream_Id; Data : Interchange.Time) is
begin
Put (Into, Data.Year);
Put (Into, Data.Month);
Put (Into, Data.Day);
Put (Into, Data.Seconds);
end Put;
procedure Get (From : Stream_Id; Data : out Interchange.Time) is
begin
Get (From, Data.Year);
Get (From, Data.Month);
Get (From, Data.Day);
Get (From, Data.Seconds);
end Get;
procedure Put (Into : Stream_Id; Data : Standard.Boolean) is
begin
if Data then
Put (Into, Interchange.Short_Natural (1));
else
Put (Into, Interchange.Short_Natural (0));
end if;
end Put;
procedure Get (From : Stream_Id; Data : out Standard.Boolean) is
Temp : Interchange.Short_Natural;
begin
Get (From, Temp);
Data := (Temp /= 0);
end Get;
procedure Put (Into : Stream_Id; Data : Standard.Character) is
begin
Put (Into, Interchange.Short_Natural
(Standard.Character'Pos (Data)));
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Put;
procedure Get (From : Stream_Id; Data : out Standard.Character) is
Temp : Interchange.Short_Natural;
begin
Get (From, Temp);
Data := Standard.Character'Val (Temp);
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get;
procedure Put_Byte_String (Into : Stream_Id;
Data : Interchange.Byte_String) is
begin
Put (Into, Interchange.Natural (Data'Length));
Put (Into, Data);
if Data'Length mod 2 /= 0 then
Put (Into, Padding);
end if;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Put_Byte_String;
function Get_Byte_String (From : Stream_Id)
return Interchange.Byte_String is
Length : Interchange.Natural;
Padding : Padding_Type;
begin
Get (From, Length);
declare
Answer : Interchange.Byte_String
(1 .. Standard.Natural (Length));
begin
Get (From, Answer);
if Answer'Length mod 2 /= 0 then
Get (From, Padding);
end if;
return Answer;
end;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get_Byte_String;
procedure Put_String (Into : Stream_Id; Data : Standard.String) is
Bytes : Interchange.Byte_String (Data'First .. Data'Last);
begin
for I in Data'Range loop
Bytes (I) := Interchange.Byte (Character'Pos (Data (I)));
end loop;
Put_Byte_String (Into, Bytes);
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Put_String;
function Get_String (From : Stream_Id) return Standard.String is
Bytes : constant Interchange.Byte_String
:= Get_Byte_String (From);
Answer : Standard.String (Bytes'First .. Bytes'Last);
begin
for I in Answer'Range loop
Answer (I) := Standard.Character'Val (Bytes (I));
end loop;
return Answer;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get_String;
procedure Put (Into : Stream_Id; Data : Interchange.Byte) is
begin
Put (Into, Interchange.Short_Natural (Data));
end Put;
procedure Get (From : Stream_Id; Data : out Interchange.Byte) is
begin
Get (From, Interchange.Short_Integer (Data));
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get;
package body Discrete is
procedure Put (Into : Stream_Id; Data : Discrete_Type) is
begin
Put (Into, Interchange.Short_Natural
(Discrete_Type'Pos (Data)));
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Put;
procedure Get (From : Stream_Id; Data : out Discrete_Type) is
Pos : Interchange.Short_Natural;
begin
Get (From, Pos);
Data := Discrete_Type'Val (Pos);
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get;
end Discrete;
package body Vector is
procedure Put (Into : Stream_Id; Data : Vector_Type) is
begin
Put (Into, Interchange.Natural (Data'Length));
for I in Data'Range loop
Put (Into, Data (I));
end loop;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Put;
function Get (From : Stream_Id) return Vector_Type is
Length : Interchange.Natural;
begin
Get (From, Length);
declare
Data :
Vector_Type
(Index_Type'First ..
Index_Type'Val
(Index_Type'Pos (Index_Type'First) + Length -
1));
begin
for I in Data'Range loop
Get (From, Data (I));
end loop;
return Data;
end;
exception
when Standard.Constraint_Error | Standard.Numeric_Error =>
raise Interchange.Constraint_Error;
end Get;
end Vector;
end Operations;
end Interchange;
nblk1=11
nid=0
hdr6=22
[0x00] rec0=1f rec1=00 rec2=01 rec3=006
[0x01] rec0=1a rec1=00 rec2=02 rec3=070
[0x02] rec0=1a rec1=00 rec2=03 rec3=044
[0x03] rec0=19 rec1=00 rec2=04 rec3=012
[0x04] rec0=1a rec1=00 rec2=05 rec3=04a
[0x05] rec0=1d rec1=00 rec2=06 rec3=012
[0x06] rec0=1d rec1=00 rec2=07 rec3=00e
[0x07] rec0=1a rec1=00 rec2=08 rec3=040
[0x08] rec0=16 rec1=00 rec2=09 rec3=032
[0x09] rec0=1b rec1=00 rec2=0a rec3=060
[0x0a] rec0=1d rec1=00 rec2=0b rec3=00c
[0x0b] rec0=19 rec1=00 rec2=0c rec3=006
[0x0c] rec0=1c rec1=00 rec2=0d rec3=00e
[0x0d] rec0=18 rec1=00 rec2=0e rec3=026
[0x0e] rec0=1a rec1=00 rec2=0f rec3=000
[0x0f] rec0=1b rec1=00 rec2=10 rec3=05c
[0x10] rec0=1c rec1=00 rec2=11 rec3=000
tail 0x2050015e47bac64a3bb22 0x42a00088462060003