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

⟦5e1dbb3b6⟧ TextFile

    Length: 21645 (0x548d)
    Types: TextFile
    Names: »B«

Derivation

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

TextFile

with Class_Integer;
with Class_Printer;
with Class_Window;
with Block;
with Bounded_String;
with Easy_Y;
with Elementary_Functions;
with Message;
with String_Utilities;
with Bug_Report;

package body Class_Turtle is
    function Send (This_Message : Message.Unary; To : Object.Reference)
                  return Object.Reference is
        type E_Message is (Tafenetre, Rentrecheztoi, Levetaplume,
                           Baissetaplume, Tonx, Tony, Tonangle,
                           Tonepaisseur, Dupliquetoi, Detruistoi, Entexte);

        Token : E_Message;

        package Bs renames Bounded_String;
    begin
        Token := E_Message'Value (Bs.Image
                                     (Message.Get (Name_From => This_Message)));
        case Token is
            when Tafenetre =>
                return Object.Create
                          (Object.Window_Class,
                           Table (Object.Get (Index_From => To)).Fenetre);

            when Rentrecheztoi =>
                Table (Object.Get (To)).X := 0;
                Table (Object.Get (To)).Y := 0;
                Table (Object.Get (To)).Angle := 0;
                Table (Object.Get (To)).Epaisseur := 1;
                Table (Object.Get (To)).Plume := Etat'(Baissee);
                return To;

            when Levetaplume =>
                Table (Object.Get (To)).Plume := Etat'(Levee);
                return To;

            when Baissetaplume =>
                Table (Object.Get (To)).Plume := Etat'(Baissee);
                return To;

            when Tonx =>
                return Class_Integer.Create (Object.Index
                                                (Table (Object.Get (To)).X));

            when Tony =>
                return Class_Integer.Create (Object.Index
                                                (Table (Object.Get (To)).Y));

            when Tonangle =>
                return Class_Integer.Create
                          (Object.Index (Table (Object.Get (To)).Angle));

            when Tonepaisseur =>
                return Class_Integer.Create
                          (Object.Index (Table (Object.Get (To)).Epaisseur));

            when Dupliquetoi =>
                return Create (To);

            when Detruistoi =>
                return Object.Void_Reference;

            when Entexte =>
                Put (To);
                return To;
        end case;
    exception
        when Constraint_Error =>
            raise Bug_Report.Unknown_Unary_Message;
    end Send;


    function Send (This_Message : Message.Binary; To : Object.Reference)
                  return Object.Reference is
    begin
        raise Bug_Report.Unknown_Binary_Message;
        return Object.Void_Reference;
    end Send;


    function Send (This_Message : Message.Keyword; To : Object.Reference)
                  return Object.Reference is
        type E_Message is (Tonx, Tony, Tafenetre, Avance, Recule, Tonepaisseur,
                           Tonangle, Agauche, Adroite, Vaenx, Y);

        Token : E_Message;

        package Bs renames Bounded_String;

        use Elementary_Functions;
        use Object;

        Pi : Float := 3.141592654;  
        Mess : Message.Keyword := This_Message;
        Dx, Dy : Object.Index;

    begin
        Message.Init (This => Mess);

        while not Message.Is_Done_Name (Mess) loop

            Token := E_Message'Value (Bs.Image
                                         (Message.Get (Name_From => Mess)));
            case Token is
                when Tafenetre =>
                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Window_Class then
                        Table (Object.Get (Index_From => To)).Fenetre :=
                           Object.Get (Index_From =>
                                          Message.Get (Argument_From => Mess));
                    else
                        raise Bug_Report.Turtle_Bad_Type;
                    end if;

                when Tonx =>
                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class then
                        Table (Object.Get (Index_From => To)).X :=
                           Object.Get (Index_From =>
                                          Message.Get (Argument_From => Mess));
                    else
                        raise Bug_Report.Turtle_Bad_Type;
                    end if;

                when Tony =>
                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class then
                        Table (Object.Get (Index_From => To)).Y :=
                           Object.Get (Index_From =>
                                          Message.Get (Argument_From => Mess));
                    else
                        raise Bug_Report.Turtle_Bad_Type;
                    end if;

                when Avance =>
                    Easy_Y.Set_Display
                       (Class_Window.Get
                           (Index => Table (Object.Get (Index_From => To)).
                                        Fenetre));
                    Dx := Object.Index
                             (Table (Object.Get (Index_From => To)).X);
                    Dy := Object.Index
                             (Table (Object.Get (Index_From => To)).Y);

                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class then

                        Table (Object.Get (Index_From => To)).X :=
                           Table (Object.Get (Index_From => To)).X +
                              Object.Index
                                 (Float (Object.Get
                                            (Index_From =>
                                                Message.Get
                                                   (Argument_From => Mess))) *
                                  Elementary_Functions.Cos
                                     (Float (Table
                                                (Object.Get (Index_From => To)).
                                             Angle) /
                                      180.0 * Pi));

                        Table (Object.Get (Index_From => To)).Y :=
                           Table (Object.Get (Index_From => To)).Y +
                              Object.Index
                                 (Float (Object.Get
                                            (Index_From =>
                                                Message.Get
                                                   (Argument_From => Mess))) *
                                  Elementary_Functions.Sin
                                     (Float (Table
                                                (Object.Get (Index_From => To)).
                                             Angle) /
                                      180.0 * Pi));

                        if Table (Object.Get (Index_From => To)).Plume =
                           Etat'(Baissee) then
                            Easy_Y.Put_Size
                               (Size => Table (Object.Get (Index_From => To)).
                                           Epaisseur);

                            Easy_Y.Line (Dx, Dy,
                                         Object.Index
                                            (Table (Object.Get
                                                       (Index_From => To)).X),
                                         Object.Index
                                            (Table (Object.Get
                                                       (Index_From => To)).Y));
                        end if;
                    else
                        raise Bug_Report.Turtle_Bad_Type;  
                    end if;

                when Recule =>

                    Easy_Y.Set_Display
                       (Class_Window.Get
                           (Index => Table (Object.Get (Index_From => To)).
                                        Fenetre));  
                    Dx := Object.Index
                             (Table (Object.Get (Index_From => To)).X);
                    Dy := Object.Index
                             (Table (Object.Get (Index_From => To)).Y);

                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class then

                        Table (Object.Get (Index_From => To)).X :=
                           Table (Object.Get (Index_From => To)).X -
                              Object.Index
                                 (Float (Object.Get
                                            (Index_From =>
                                                Message.Get
                                                   (Argument_From => Mess))) *
                                  Elementary_Functions.Cos
                                     (Float (Table
                                                (Object.Get (Index_From => To)).
                                             Angle) /
                                      180.0 * Pi));

                        Table (Object.Get (Index_From => To)).Y :=
                           Table (Object.Get (Index_From => To)).Y -
                              Object.Index
                                 (Float (Object.Get
                                            (Index_From =>
                                                Message.Get
                                                   (Argument_From => Mess))) *
                                  Elementary_Functions.Sin
                                     (Float (Table
                                                (Object.Get (Index_From => To)).
                                             Angle) /
                                      180.0 * Pi));


                        if Table (Object.Get (Index_From => To)).Plume =
                           Etat'(Baissee) then
                            Easy_Y.Put_Size
                               (Size => Table (Object.Get (Index_From => To)).
                                           Epaisseur);

                            Easy_Y.Line (Dx, Dy,
                                         Object.Index
                                            (Table (Object.Get
                                                       (Index_From => To)).X),
                                         Object.Index
                                            (Table (Object.Get
                                                       (Index_From => To)).Y));
                        end if;
                    else
                        raise Bug_Report.Turtle_Bad_Type;
                    end if;

                when Tonepaisseur =>
                    if Object.Get
                          (Class_From => Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class and then
                       Object.Get
                          (Index_From => Message.Get (Argument_From => Mess)) >
                       0 then
                        Table (Object.Get (Index_From => To)).Epaisseur :=
                           Object.Get (Index_From =>
                                          Message.Get (Argument_From => Mess));
                    else
                        raise Bug_Report.Turtle_Bad_Type;
                    end if;

                when Tonangle =>
                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class then
                        Table (Object.Get (Index_From => To)).Angle :=
                           Object.Get (Index_From =>
                                          Message.Get (Argument_From => Mess));
                    else
                        raise Bug_Report.Turtle_Bad_Type;
                    end if;

                when Adroite =>
                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class then
                        Table (Object.Get (Index_From => To)).Angle :=
                           Table (Object.Get (Index_From => To)).Angle +
                              Object.Get (Index_From =>
                                             Message.Get
                                                (Argument_From => Mess));
                    else
                        raise Bug_Report.Turtle_Bad_Type;
                    end if;

                when Agauche =>
                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class then
                        Table (Object.Get (Index_From => To)).Angle :=
                           Table (Object.Get (Index_From => To)).Angle -
                              Object.Get (Index_From =>
                                             Message.Get
                                                (Argument_From => Mess));
                    else
                        raise Bug_Report.Turtle_Bad_Type;
                    end if;

                when Vaenx =>
                    Easy_Y.Set_Display
                       (Class_Window.Get
                           (Index => Table (Object.Get (Index_From => To)).
                                        Fenetre));
                    Dx := Object.Index
                             (Table (Object.Get (Index_From => To)).X);
                    Dy := Object.Index
                             (Table (Object.Get (Index_From => To)).Y);
                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class then

                        Table (Object.Get (Index_From => To)).X :=
                           Object.Get (Index_From =>
                                          Message.Get (Argument_From => Mess));

                        Message.Next (Mess);
                        if not Message.Is_Done (Mess) then

                            if Bs.Image (Message.Get (Name_From => Mess)) =
                               "Y" then
                                if Object.Get
                                      (Class_From =>
                                          Message.Get (Argument_From => Mess)) =
                                   Object.Integer_Class then

                                    Table (Object.Get (Index_From => To)).Y :=
                                       Object.Get
                                          (Index_From =>
                                              Message.Get
                                                 (Argument_From => Mess));

                                    if Table (Object.Get (Index_From => To)).
                                       Plume = Etat'(Baissee) then
                                        Easy_Y.Line
                                           (Dx, Dy,
                                            Object.Index
                                               (Table (Object.Get
                                                          (Index_From => To)).
                                                X),
                                            Object.Index
                                               (Table (Object.Get
                                                          (Index_From => To)).
                                                Y));
                                    end if;

                                else
                                    raise Bug_Report.Turtle_Bad_Type;
                                end if;
                            end if;
                        else
                            raise Bug_Report.Turtle_Bad_Type;
                        end if;
                    end if;

                when Y =>
                    Easy_Y.Set_Display
                       (Class_Window.Get
                           (Index => Table (Object.Get (Index_From => To)).
                                        Fenetre));
                    Dx := Object.Index
                             (Table (Object.Get (Index_From => To)).X);
                    Dy := Object.Index
                             (Table (Object.Get (Index_From => To)).Y);

                    if Object.Get (Class_From =>
                                      Message.Get (Argument_From => Mess)) =
                       Object.Integer_Class then

                        Table (Object.Get (Index_From => To)).Y :=
                           Object.Get (Index_From =>
                                          Message.Get (Argument_From => Mess));

                        Message.Next (Mess);
                        if not Message.Is_Done (Mess) then

                            if Bs.Image (Message.Get (Name_From => Mess)) =
                               "VaEnX" then
                                if Object.Get
                                      (Class_From =>
                                          Message.Get (Argument_From => Mess)) =
                                   Object.Integer_Class then

                                    Table (Object.Get (Index_From => To)).X :=
                                       Object.Get
                                          (Index_From =>
                                              Message.Get
                                                 (Argument_From => Mess));

                                    if Table (Object.Get (Index_From => To)).
                                       Plume = Etat'(Baissee) then
                                        Easy_Y.Line
                                           (Dx, Dy,
                                            Object.Index
                                               (Table (Object.Get
                                                          (Index_From => To)).
                                                X),
                                            Object.Index
                                               (Table (Object.Get
                                                          (Index_From => To)).
                                                Y));
                                    end if;
                                else
                                    raise Bug_Report.Turtle_Bad_Type;
                                end if;
                            end if;
                        else
                            raise Bug_Report.Turtle_Bad_Type;
                        end if;
                    end if;
            end case;
            Message.Next (Mess);
        end loop;  
        return To;
    exception
        when Constraint_Error =>
            raise Bug_Report.Unknown_Keyword_Message;
    end Send;

    function Create (From : Object.Reference) return Object.Reference is
        use Object;
    begin
        Last := Last + 1;
        Table (Last) := Table (Object.Get (From));
        return Object.Create (Class => Object.Turtle_Class, Object => Last);
    exception
        when Constraint_Error =>
            raise Bug_Report.Full_Turtle_Table;
    end Create;

    procedure Create is
        use Object;
        Node : Block.Node := Block.Get_Current_Node;
    begin
        Last := Last + 1;
        Block.Put_Into_Table
           (This_Object => Object.Create
                              (Class => Object.Turtle_Class, Object => Last),
            Named => Bounded_String.Value ("tortue", 80),
            Into_Block => Node);
    exception
        when Constraint_Error =>
            raise Bug_Report.Full_Turtle_Table;
    end Create;

    procedure Put (An_Object : Object.Reference) is
    begin
        Class_Printer.Put ("Objet Tortue {");
        Class_Printer.Forward (4);
        Class_Printer.New_Line;
        Class_Printer.Put ("Numero => " &
                           Object.Index'Image (Object.Get (An_Object)));
        Class_Printer.New_Line;
        Class_Printer.Put ("X => " & Object.Index'Image
                                        (Table (Object.Get (An_Object)).X));
        Class_Printer.New_Line;
        Class_Printer.Put ("Y => " & Object.Index'Image
                                        (Table (Object.Get (An_Object)).Y));
        Class_Printer.New_Line;
        Class_Printer.Put ("Angle => " &
                           Object.Index'Image
                              (Table (Object.Get (An_Object)).Angle));
        Class_Printer.New_Line;
        Class_Printer.Put ("Plume => " &
                           Class_Turtle.Etat'Image
                              (Table (Object.Get (An_Object)).Plume));
        Class_Printer.New_Line;
        Class_Printer.Put ("Fenetre => ");
        Class_Printer.New_Line;
        Class_Printer.Forward (4);
        Class_Window.Put (Object.Create
                             (Object.Window_Class,
                              Table (Object.Get (An_Object)).Fenetre));
        Class_Printer.Backward (8);
        Class_Printer.Put ("}");
        Class_Printer.New_Line (2);
    end Put;

    function How_Many return Object.Index is
    begin
        return Last;
    end How_Many;

end Class_Turtle;