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

⟦d34c553ce⟧ TextFile

    Length: 13232 (0x33b0)
    Types: TextFile
    Names: »B«

Derivation

└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
    └─ ⟦129cab021⟧ »DATA« 
        └─⟦this⟧ 

TextFile

with Arguments;
with Block_Class;
with Boolean_Class;
with Message;
with Msg_Report;
with Object;
with Random;
with String_Class;
with String_Utilities;

package body Integer_Class is

    Random_Handle : Random.Handle;

    function Is_Equal_String
                (Str1 : String; Str2 : String; Ignore_Case : Boolean := True)
                return Boolean renames String_Utilities.Equal;


    function Create (Value : Integer) return Object.Reference is  
    begin
        return Object.Create (Object.C_Integer, Value);
    end Create;

    function Delete (The_Integer : Object.Reference) return Object.Reference is  
    begin
        return Object.Void_Reference;
    end Delete;


    function In_Text (The_Integer : Object.Reference) return String is

    begin
        return Integer'Image (Object.Identificator (The_Integer));
    end In_Text;


    function Square (The_Integer : Object.Reference) return Object.Reference is
        Op_Result : Integer;
    begin
        Op_Result := Object.Identificator (The_Integer);
        Op_Result := Op_Result * Op_Result;
        return Object.Create (Object.C_Integer, Op_Result);

    end Square;


    function Cubic (The_Integer : Object.Reference) return Object.Reference is
        Op_Result : Integer;  
    begin  
        Op_Result := Object.Identificator (The_Integer);
        Op_Result := Op_Result * Op_Result * Op_Result;
        return Object.Create (Object.C_Integer, Op_Result);  
    end Cubic;


    function Repeat_To_Limit (The_Start : Object.Reference;
                              The_Limit : Object.Reference;
                              The_Block : Object.Reference)
                             return Object.Reference is

        Args_List : Arguments.List;  
        Argument, Result : Object.Reference;
        Msg : Message.Selector;

    begin  
        Message.Copy (Msg, Block_Class.Keyword_Evaluate_Msg);
        for I in Object.Identificator (The_Start) ..
                    Object.Identificator (The_Limit) loop
            Argument := Create (I);
            Args_List := Arguments.Void_Arguments;
            Arguments.Write (Args_List, Argument);

            Msg_Report.Information ("The_block is ");
            Msg_Report.Continue
               ("class = " & Object.Class'Image (Object.The_Class (The_Block)) &
                " ident = " & Integer'Image (Object.Identificator (The_Block)));  
            Msg_Report.Information ("Message is " & Message.Image (Msg));

            Arguments.Image (Args_List);

            Result := Block_Class.Send (The_Block, Msg, Args_List);
        end loop;

        return Result;
    end Repeat_To_Limit;


    function N_Time (Nb_Time : Object.Reference; The_Block : Object.Reference)
                    return Object.Reference is

        Msg : Message.Selector := Message.Void_Selector;  
        Result : Object.Reference;

    begin

        Message.Copy (Msg, Block_Class.Evaluate_Msg);

        for I in 1 .. Object.Identificator (Nb_Time) loop  
            Result := Block_Class.Send (The_Block, Msg);
        end loop;

        return Result;

    end N_Time;


    function "+" (First_Integer : Object.Reference;
                  Second_Integer : Object.Reference) return Object.Reference is
        Op_Result : Integer;
    begin
        Op_Result := Object.Identificator (First_Integer) +
                        Object.Identificator (Second_Integer);
        return Object.Create (Object.C_Integer, Op_Result);
    end "+";


    function "-" (First_Integer : Object.Reference;
                  Second_Integer : Object.Reference) return Object.Reference is
        Op_Result : Integer;
    begin
        Op_Result := Object.Identificator (First_Integer) -
                        Object.Identificator (Second_Integer);
        return Object.Create (Object.C_Integer, Op_Result);
    end "-";


    function "*" (First_Integer : Object.Reference;
                  Second_Integer : Object.Reference) return Object.Reference is  
        Op_Result : Integer;
    begin
        Op_Result := Object.Identificator (First_Integer) *
                        Object.Identificator (Second_Integer);
        return Object.Create (Object.C_Integer, Op_Result);  
    end "*";


    function "/" (First_Integer : Object.Reference;
                  Second_Integer : Object.Reference) return Object.Reference is  
        Op_Result : Integer;
    begin
        Op_Result := Object.Identificator (First_Integer) /
                        Object.Identificator (Second_Integer);
        return Object.Create (Object.C_Integer, Op_Result);
    end "/";


    function "<" (First_Integer : Object.Reference;
                  Second_Integer : Object.Reference) return Object.Reference is
        Result : Object.Reference := Object.Void_Reference;

    begin  
        if Object.Identificator (First_Integer) <
           Object.Identificator (Second_Integer) then
            Result := Boolean_Class.Create (True);
        else
            Result := Boolean_Class.Create (False);
        end if;
        return Result;
    end "<";


    function ">" (First_Integer : Object.Reference;
                  Second_Integer : Object.Reference) return Object.Reference is  
        Result : Object.Reference := Object.Void_Reference;

    begin  
        if Object.Identificator (First_Integer) >
           Object.Identificator (Second_Integer) then
            Result := Boolean_Class.Create (True);
        else
            Result := Boolean_Class.Create (False);
        end if;
        return Result;
    end ">";


    function Is_Less_Or_Equal (First_Integer : Object.Reference;
                               Second_Integer : Object.Reference)
                              return Object.Reference is  
        Result : Object.Reference := Object.Void_Reference;

    begin  
        if Object.Identificator (First_Integer) <=
           Object.Identificator (Second_Integer) then
            Result := Boolean_Class.Create (True);
        else
            Result := Boolean_Class.Create (False);
        end if;
        return Result;
    end Is_Less_Or_Equal;


    function Is_Great_Or_Equal
                (First_Integer : Object.Reference;
                 Second_Integer : Object.Reference) return Object.Reference is  
        Result : Object.Reference := Object.Void_Reference;

    begin  
        if Object.Identificator (First_Integer) >=
           Object.Identificator (Second_Integer) then
            Result := Boolean_Class.Create (True);
        else
            Result := Boolean_Class.Create (False);
        end if;
        return Result;  
    end Is_Great_Or_Equal;


    function Is_Equal (First_Integer : Object.Reference;
                       Second_Integer : Object.Reference)
                      return Object.Reference is
        Result : Object.Reference := Object.Void_Reference;

    begin  
        if Object.Identificator (First_Integer) =
           Object.Identificator (Second_Integer) then
            Result := Boolean_Class.Create (True);
        else
            Result := Boolean_Class.Create (False);
        end if;
        return Result;  
    end Is_Equal;


    function Is_Not_Equal (First_Integer : Object.Reference;
                           Second_Integer : Object.Reference)
                          return Object.Reference is  
        Result : Object.Reference := Object.Void_Reference;

    begin  
        if Object.Identificator (First_Integer) /=
           Object.Identificator (Second_Integer) then
            Result := Boolean_Class.Create (True);
        else
            Result := Boolean_Class.Create (False);
        end if;
        return Result;  
    end Is_Not_Equal;


    function My_Random (Max : Object.Reference) return Object.Reference is
        Op_Result : Integer;  
    begin  
        Op_Result := Object.Identificator (Max);
        Op_Result := Random.Natural_Value (Random_Handle, Natural (Op_Result));
        return Object.Create (Object.C_Integer, Op_Result);  
    end My_Random;


    function Send (To_Object : Object.Reference;
                   The_Message : Message.Selector;
                   With_Arguments : Arguments.List := Arguments.Void_Arguments)
                  return Object.Reference is

        Result, Object1, Object2, Object3 : Object.Reference;

        Args : Arguments.List;

    begin  
        Object1 := To_Object;

        Args := With_Arguments;

        case Arguments.How_Many (Args) is

            when 0 =>

                if Is_Equal_String (Message.Image (The_Message), "AuCarre") then

                    Msg_Report.Information ("Message is AuCarre ");
                    Result := Square (Object1);

                elsif Is_Equal_String
                         (Message.Image (The_Message), "AuCube") then

                    Msg_Report.Information ("Message is AuCube ");
                    Result := Cubic (Object1);

                elsif Is_Equal_String
                         (Message.Image (The_Message), "EnTexte") then

                    Msg_Report.Information ("Message is EnTexte ");
                    Result := String_Class.Create (In_Text (Object1));

                elsif Is_Equal_String
                         (Message.Image (The_Message), "AuHasard") then

                    Msg_Report.Information ("Message is AuHasard ");
                    Result := My_Random (Object1);

                else

                    Msg_Report.Interpret_Error
                       ("Incorrect unary method " &
                        Message.Image (The_Message) &
                        " for object " & In_Text (Object1));

                    raise Incorrect_Method;
                end if;


            when 1 =>

                Arguments.First (Args);
                Arguments.Read (Args, Object2);

                if Message.Image (The_Message) = "+" then

                    Msg_Report.Information ("Message is +");  
                    Result := Object1 + Object2;

                elsif Message.Image (The_Message) = "-" then

                    Msg_Report.Information ("Message is -");  
                    Result := Object1 - Object2;


                elsif Message.Image (The_Message) = "*" then

                    Msg_Report.Information ("Message is *");  
                    Result := Object1 * Object2;

                elsif Message.Image (The_Message) = "/" then

                    Msg_Report.Information ("Message is / ");  
                    Result := Object1 / Object2;

                elsif Message.Image (The_Message) = "<" then

                    Msg_Report.Information ("Message is <");  
                    Result := Object1 < Object2;  
                elsif Message.Image (The_Message) = ">" then

                    Msg_Report.Information ("Message is >");  
                    Result := Object1 > Object2;

                elsif Message.Image (The_Message) = "<=" then

                    Msg_Report.Information ("Message is <=");  
                    Result := Is_Less_Or_Equal (Object1, Object2);

                elsif Message.Image (The_Message) = ">=" then

                    Msg_Report.Information ("Message is >=");  
                    Result := Is_Great_Or_Equal (Object1, Object2);

                elsif Message.Image (The_Message) = "<>" then

                    Msg_Report.Information ("Message is <>");  
                    Result := Is_Not_Equal (Object1, Object2);

                elsif Message.Image (The_Message) = "=" then

                    Msg_Report.Information ("Message is =");  
                    Result := Is_Equal (Object1, Object2);

                elsif Is_Equal_String
                         (Message.Format (The_Message), "Fois") then

                    Msg_Report.Information ("Message is Fois:");  
                    Result := N_Time (Object1, Object2);

                else  
                    Msg_Report.Interpret_Error
                       ("Incorrect method " & Message.Image (The_Message) &
                        " for object " & In_Text (Object1));

                    raise Incorrect_Method;

                end if;


            when 2 =>

                Arguments.First (Args);
                Arguments.Read (Args, Object2);
                Arguments.Read (Args, Object3);

                if Is_Equal_String
                      (Message.Format (The_Message), "Arepeter") then
                    Msg_Report.Information ("Message is A: Repeter:");
                    Result := Repeat_To_Limit (Object1, Object2, Object3);

                else
                    Msg_Report.Interpret_Error
                       ("Incorrect method " & Message.Image (The_Message) &
                        " for object " & In_Text (Object1));

                    raise Incorrect_Method;
                end if;


            when others =>

                Msg_Report.Interpret_Error
                   ("Incorrect nb of arguments for method " &
                    Message.Image (The_Message) &
                    " to object " & In_Text (Object1));
                raise Incorrect_Nb_Args;

        end case;

        return Result;
    end Send;

begin
    Random.Initialize (Random_Handle);
end Integer_Class;