DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦2531433f9⟧ TextFile

    Length: 17439 (0x441f)
    Types: TextFile
    Names: »B«

Derivation

└─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13
    └─ ⟦124ff5788⟧ »DATA« 
        └─⟦this⟧ 
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 
└─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16
    └─ ⟦6f12a12be⟧ »DATA« 
        └─⟦this⟧ 
└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
    └─ ⟦d65440be7⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Text_Io;
with Constant_String, Text_Float;
package body Slot is

    function Value (I : Integer) return Object is
    begin
        return Object'(Kind => Integer_Value, I_Val => I);
    end Value;


    function Value (F : Float) return Object is
    begin
        return Object'(Kind => Float_Value, F_Val => F);
    end Value;

    function Value (B : Boolean) return Object is
    begin
        return Object'(Kind => Boolean_Value, B_Val => B);
    end Value;

    function Value (C : Character) return Object is
    begin
        return (Object'(Kind => Character_Value, C_Val => C));
    end Value;

    function Value (S : String) return Object is
    begin
        return (Object'(Kind => String_Value,
                        S_Val => Constant_String.Value (S)));
    end Value;

    function Value (O : Instance.Reference) return Object is
    begin
        return (Kind => Class_Value, O_Val => O);
    end Value;

    ------------------------------------------------------------
    function Get (O : Object) return Integer is
    begin  
        case O.Kind is
            when Integer_Value =>
                return O.I_Val;
            when Boolean_Value =>
                return Boolean'Pos (O.B_Val);
            when Unchecked_Enumeration_Value =>
                return O.Ue_Val;
            when Float_Value =>
                return Integer (O.F_Val);
            when others =>
                raise Integer_Object_Waited_Error;
        end case;
    end Get;


    function Get (O : Object) return Boolean is
    begin  
        case O.Kind is
            when Boolean_Value =>
                return O.B_Val;
            when others =>
                raise Boolean_Object_Waited_Error;
        end case;
    end Get;

    function Get (O : Object) return Float is
    begin
        case O.Kind is
            when Float_Value =>
                return O.F_Val;
            when Integer_Value =>
                return Float (O.I_Val);
            when Boolean_Value =>
                return Float (Boolean'Pos (O.B_Val));
            when Unchecked_Enumeration_Value =>
                return Float (O.Ue_Val);
            when others =>
                raise Float_Object_Waited_Error;
        end case;
    end Get;

    function Get (O : Object) return Character is
    begin  
        case O.Kind is
            when Character_Value =>
                return O.C_Val;
            when String_Value =>
                if Constant_String.Image (O.S_Val)'Length = 1 then
                    return Constant_String.Image (O.S_Val) (1);
                else
                    raise Char_Object_Waited_Error;
                end if;
            when others =>
                raise Char_Object_Waited_Error;
        end case;

    end Get;

    function Get (O : Object) return String is
    begin
        case O.Kind is
            when String_Value =>
                return Constant_String.Image (O.S_Val);
            when Character_Value =>
                return ("" & O.C_Val);
            when Integer_Value =>
                return Integer'Image (O.I_Val);
            when Unchecked_Enumeration_Value =>
                return Integer'Image (O.Ue_Val);
            when Checked_Enumeration_Value =>
                return Constant_String.Image (O.S_Val);
            when Boolean_Value =>
                return Boolean'Image (O.B_Val);
            when others =>
                raise String_Object_Waited_Error;

        end case;
    end Get;

    function Get (O : Object) return Instance.Reference is
    begin  
        if O.Kind = Class_Value then
            return O.O_Val;
        else
            raise Reference_Object_Waited_Error;
        end if;
    end Get;
    ------------------------------------------------------------

    procedure Set (O : in out Object;
                   To : Integer;
                   Is_Mutable : Boolean := False) is
        Done : Boolean := False;
    begin  
        case O.Kind is
            when Integer_Value =>
                O.I_Val := To;
                Done := True;
            when Unchecked_Enumeration_Value =>  
                O.Ue_Val := To;
            when others =>
                null;
        end case;
        if not Done and then Is_Mutable then
            O := Object'(Kind => Integer_Value, I_Val => To);
            Done := True;
        end if;
        if not Done then
            raise Incompatible_Integer_And_Object;
        end if;
    end Set;
    ----------
    procedure Set (O : in out Object;
                   To : Boolean;
                   Is_Mutable : Boolean := False) is
    begin  
        if O.Kind = Boolean_Value then
            O.B_Val := To;
        elsif Is_Mutable then
            O := Object'(Kind => Boolean_Value, B_Val => To);
        else
            raise Incompatible_Boolean_And_Object;
        end if;
    end Set;
    ----------

    procedure Set (O : in out Object;
                   To : Float;
                   Is_Mutable : Boolean := False) is
    begin
        if O.Kind = Float_Value then
            O.F_Val := To;
        elsif Is_Mutable then
            O := Object'(Kind => Float_Value, F_Val => To);
        else
            raise Incompatible_Float_And_Object;

        end if;
    end Set;

    ----------
    procedure Set (O : in out Object;
                   To : Character;
                   Is_Mutable : Boolean := False) is
    begin  
        if O.Kind = Character_Value then
            O.C_Val := To;
        elsif O.Kind = String_Value then
            O.S_Val := Constant_String.Value ("" & To);
        elsif Is_Mutable then
            O := Object'(Kind => Character_Value, C_Val => To);
        else
            raise Incompatible_Char_And_Object;
        end if;
    end Set;

    ----------

    procedure Set (O : in out Object;
                   To : String;
                   Is_Mutable : Boolean := False) is
    begin  
        if O.Kind = String_Value then
            O.S_Val := Constant_String.Value (To);
        elsif Is_Mutable then
            O := Object'(Kind => String_Value,
                         S_Val => Constant_String.Value (To));
        else
            raise Incompatible_String_And_Object;
        end if;
    end Set;

    ----------

    procedure Set (O : in out Object;
                   To : Instance.Reference;
                   Is_Mutable : Boolean := False) is
    begin  
        if O.Kind = Class_Value then
            O.O_Val := To;
        elsif Is_Mutable then
            O := Object'(Kind => Class_Value, O_Val => To);
        else
            raise Incompatible_Reference_And_Object;
        end if;
    end Set;

    function Is_Same_Type (Left, Right : Object) return Boolean is
    begin
        return Left.Kind = Right.Kind;
    end Is_Same_Type;



    --============================================================

    package body Operators is

        package String_Operators renames Constant_String.Operators;
        function "<" (Left, Right : Object) return Boolean is
        begin  
            if Left.Kind = Right.Kind then
                case Left.Kind is
                    when Integer_Value =>
                        return Left.I_Val < Right.I_Val;
                    when Boolean_Value =>
                        return Left.B_Val < Right.B_Val;
                    when Float_Value =>
                        return Left.F_Val < Right.F_Val;
                    when Character_Value =>
                        return Left.C_Val < Right.C_Val;
                    when String_Value =>
                        return String_Operators."<" (Left.S_Val, Right.S_Val);
                    when Unchecked_Enumeration_Value =>
                        return Left.C_Val < Right.C_Val;
                    when others =>
                        raise Less_Operator_Error;
                end case;
            else
                raise Less_Operator_Error;
            end if;
        end "<";
        ---------------------

        function "<=" (Left, Right : Object) return Boolean is
        begin  
            if Left.Kind = Right.Kind then
                case Left.Kind is
                    when Integer_Value =>
                        return Left.I_Val <= Right.I_Val;
                    when Boolean_Value =>
                        return Left.B_Val <= Right.B_Val;
                    when Float_Value =>
                        return Left.F_Val <= Right.F_Val;
                    when Character_Value =>
                        return Left.C_Val <= Right.C_Val;
                    when String_Value =>
                        return String_Operators."<=" (Left.S_Val, Right.S_Val);
                    when Unchecked_Enumeration_Value =>
                        return Left.C_Val <= Right.C_Val;
                    when others =>
                        raise Less_Equal_Operator_Error;
                end case;
            else
                raise Less_Equal_Operator_Error;
            end if;
        end "<=";
        ---------------------

        function ">" (Left, Right : Object) return Boolean is
        begin  
            if Left.Kind = Right.Kind then
                case Left.Kind is
                    when Integer_Value =>
                        return Left.I_Val > Right.I_Val;
                    when Boolean_Value =>
                        return Left.B_Val > Right.B_Val;
                    when Float_Value =>
                        return Left.F_Val > Right.F_Val;
                    when Character_Value =>
                        return Left.C_Val > Right.C_Val;
                    when String_Value =>
                        return String_Operators.">" (Left.S_Val, Right.S_Val);
                    when Unchecked_Enumeration_Value =>
                        return Left.C_Val > Right.C_Val;
                    when others =>
                        raise Great_Operator_Error;
                end case;
            else
                raise Great_Operator_Error;
            end if;
        end ">";
        ---------------------

        function ">=" (Left, Right : Object) return Boolean is
        begin  
            if Left.Kind = Right.Kind then
                case Left.Kind is
                    when Integer_Value =>
                        return Left.I_Val >= Right.I_Val;
                    when Boolean_Value =>
                        return Left.B_Val >= Right.B_Val;
                    when Float_Value =>
                        return Left.F_Val >= Right.F_Val;
                    when Character_Value =>
                        return Left.C_Val >= Right.C_Val;
                    when String_Value =>
                        return String_Operators.">=" (Left.S_Val, Right.S_Val);
                    when Unchecked_Enumeration_Value =>
                        return Left.C_Val >= Right.C_Val;
                    when others =>
                        raise Great_Equal_Operator_Error;
                end case;
            else
                raise Great_Equal_Operator_Error;
            end if;
        end ">=";


    end Operators;
    --============================================================

    function Image (O : Object) return String is
    begin
        case O.Kind is
            when Integer_Value =>
                return Integer'Image (O.I_Val);
            when Float_Value =>
                return Text_Float (O.F_Val);
            when Boolean_Value =>
                return Boolean'Image (O.B_Val);
            when Character_Value =>
                return Character'Image (O.C_Val);
            when String_Value =>
                return Constant_String.Image (O.S_Val);
            when Class_Value =>
                return Instance.Image (O.O_Val);
            when Checked_Enumeration_Value =>
                return Constant_String.Image (O.S_Val);  
            when Unchecked_Enumeration_Value =>
                return Integer'Image (O.Ue_Val);
        end case;

    end Image;

    --============================================================
    package body Enumeration_Facilities is

        function Value (E : Values) return Object is
        begin
            if Checked then
                return Object'(Kind => Checked_Enumeration_Value,
                               Ce_Val => Constant_String.Value
                                            (Values'Image (E)));
            else
                return Object'(Kind => Unchecked_Enumeration_Value,
                               Ue_Val => Values'Pos (E));
            end if;
        end Value;


        function Image (E : Values) return String is
        begin
            return Constant_String.Image
                      (Constant_String.Value (Values'Image (E)));
        end Image;



        function Get (O : Object) return Values is
        begin
            if O.Kind = Checked_Enumeration_Value then
                return Values'Value (Constant_String.Image (O.Ce_Val));
            elsif O.Kind = Unchecked_Enumeration_Value then
                return Values'Val (O.Ue_Val);
            else
                raise Illegal_Enumeration_Object;
            end if;
        end Get;

        function Image (O : Object) return String is
        begin
            return Constant_String.Image
                      (Constant_String.Value
                          (Values'Image (Enumeration_Facilities.Get (O))));
        end Image;

        procedure Set (O : in out Object;
                       To : Values;
                       Is_Mutable : Boolean := False) is
        begin  
            if Checked then
                begin
                    if O.Kind = Checked_Enumeration_Value then
                        O.Ce_Val := Constant_String.Value (Values'Image (To));
                    elsif Is_Mutable then
                        O := Object'(Kind => Checked_Enumeration_Value,
                                     Ce_Val => Constant_String.Value
                                                  (Values'Image (To)));
                    else
                        raise Enumeration_Object_Error;

                    end if;
                end;
            else
                begin
                    if O.Kind = Unchecked_Enumeration_Value then
                        O.Ue_Val := Values'Pos (To);
                    elsif Is_Mutable then
                        O := Object'(Kind => Unchecked_Enumeration_Value,
                                     Ue_Val => Values'Pos (To));
                    else
                        raise Enumeration_Object_Error;
                    end if;
                end;

            end if;  
        end Set;

        function "<" (Left, Right : Object) return Boolean is
        begin  
            if Left.Kind = Right.Kind then
                case Left.Kind is
                    when Unchecked_Enumeration_Value =>
                        return Left.C_Val < Right.C_Val;
                    when Checked_Enumeration_Value =>
                        return Values'Pos (Get (Left)) <
                                  Values'Pos (Get (Right));
                    when others =>
                        raise Enumeration_Less_Error;
                end case;
            else
                raise Enumeration_Less_Error;
            end if;
        end "<";
        ---------------------

        function "<=" (Left, Right : Object) return Boolean is
        begin  
            if Left.Kind = Right.Kind then
                case Left.Kind is
                    when Unchecked_Enumeration_Value =>
                        return Left.C_Val <= Right.C_Val;
                    when Checked_Enumeration_Value =>
                        return Values'Pos (Get (Left)) <=
                                  Values'Pos (Get (Right));
                    when others =>
                        raise Enumeration_Less_Equal_Error;
                end case;
            else
                raise Enumeration_Less_Equal_Error;
            end if;
        end "<=";
        ---------------------

        function ">" (Left, Right : Object) return Boolean is
        begin
            if Left.Kind = Right.Kind then
                case Left.Kind is
                    when Unchecked_Enumeration_Value =>
                        return Left.C_Val > Right.C_Val;
                    when Checked_Enumeration_Value =>
                        return Values'Pos (Get (Left)) >
                                  Values'Pos (Get (Right));
                    when others =>
                        raise Enumeration_Great_Error;
                end case;
            else
                raise Enumeration_Great_Error;
            end if;

        end ">";
        ---------------------

        function ">=" (Left, Right : Object) return Boolean is
        begin  
            if Left.Kind = Right.Kind then
                case Left.Kind is
                    when Unchecked_Enumeration_Value =>
                        return Left.C_Val >= Right.C_Val;
                    when Checked_Enumeration_Value =>
                        return Values'Pos (Get (Left)) >=
                                  Values'Pos (Get (Right));
                    when others =>
                        raise Enumeration_Great_Equal_Error;
                end case;
            else
                raise Enumeration_Great_Equal_Error;
            end if;
        end ">=";

    end Enumeration_Facilities;
end Slot;