PreviousUpNext

15.4.612  src/lib/compiler/front/typer-stuff/modules/stamppath.pkg

## stamppath.pkg

# Compiled by:
#     src/lib/compiler/front/typer-stuff/typecheckdata.sublib

stipulate
    package sta =  stamp;               # stamp         is from   src/lib/compiler/front/typer-stuff/basics/stamp.pkg
herein

    api Stamppath {

        Stamppath  =  List( sta::Stamp );

        Reverse_Stamppath;

        null_stamppath:          Stamppath;
        null_reverse_stamppath:  Reverse_Stamppath;
        prepend_to_reverse_stamppath2: (sta::Stamp, Reverse_Stamppath) -> Reverse_Stamppath;

        reverse_and_prepend_to_reverse_stamppath:  (Stamppath, Reverse_Stamppath) -> Reverse_Stamppath;
        reverse_stamppath_to_stamppath:  Reverse_Stamppath -> Stamppath;

        same_module_stamp:  (sta::Stamp, sta::Stamp) -> Bool;
        same_stamppath:   (Stamppath, Stamppath)  -> Bool;

        compare_generics_expansion_variables: (sta::Stamp, sta::Stamp) -> Order;
        compare_stamppaths:                   (Stamppath, Stamppath)  -> Order;

        stamppath_is_null:       Stamppath -> Bool;

        module_stamp_to_string:    sta::Stamp -> String;
        stamppath_to_string:     Stamppath  -> String;

        bogus_typechecked_package_variable:     sta::Stamp;

        package module_stamp_map:  Map          # Map   is from   src/lib/src/map.api
                                   where
                                        key::Key == sta::Stamp;

    };                                                  # Api Stamppath 
end;


stipulate
    package sta =  stamp;                               # stamp         is from   src/lib/compiler/front/typer-stuff/basics/stamp.pkg
herein


    package   stamppath
    :         Stamppath                         # Stamppath     is from   src/lib/compiler/front/typer-stuff/modules/stamppath.pkg
    {
        Stamppath  =   List( sta::Stamp );              # Stamppath has generics expansion stamps in direct order, outer first 

        Reverse_Stamppath = List( sta::Stamp ); # reversed order; abstract 

        null_stamppath         =  [];
        null_reverse_stamppath =  [];

        prepend_to_reverse_stamppath2
            =
            (!);


        reverse_and_prepend_to_reverse_stamppath
            =
            list::reverse_and_prepend;


        reverse_stamppath_to_stamppath
            =
            reverse;


        same_module_stamp
            =
            sta::same_stamp;


        fun same_stamppath (ep1, ep2)
            =
            all (ep1, ep2)
            where
                fun all (v ! l, u ! m) =>  same_module_stamp (v, u) and all (l, m);
                    all (NIL, NIL)     =>  TRUE;
                    all _              =>  FALSE;
                end;
            end;

        compare_generics_expansion_variables
            =
            sta::compare;

        fun compare_stamppaths (ep1, ep2)
            = 
            {   fun f (a ! ar, b ! br)
                    =>
                    case (sta::compare (a, b))
                        #                     
                        EQUAL => f (ar, br);
                        z     => z;
                    esac;

                    f (a ! ar, NIL  )  =>   GREATER;
                    f (NIL,   b ! br)  =>   LESS;
                    f (NIL,   NIL  )   =>   EQUAL;
                end;
            
                f (ep1, ep2);
            };

        package module_stamp_map
            =
            red_black_map_g (                                           # red_black_map_g               is from   src/lib/src/red-black-map-g.pkg

                Key = sta::Stamp; 

                compare = compare_generics_expansion_variables;

            );

        # paired_lists::all didn't cut it because it doesn't require lists of equal length
        #  length ep1 = length ep2 and
        #  paired_lists::all generics expansion stamps are equal (ep1, ep2)
        #
        fun stamppath_is_null (ep: Stamppath)
            =
            list::null ep;


        fun module_stamp_to_string (v: sta::Stamp)
            =
            sta::to_short_string v;


        fun stamppath_to_string ([]: Stamppath)
                =>
                "[]";

            stamppath_to_string (x ! xs)
                =>
                {   rest
                        =
                        fold_backward
                            (\\ (y, l) =  ", " ! (sta::to_short_string y) ! l)
                            ["]"]
                            xs;

                    string::cat("[" ! (sta::to_short_string x) ! rest);
                };
        end;


        bogus_typechecked_package_variable
            =
            sta::make_static_stamp "bogus generics expansion variable";


    };          # package stamppath 
end;            # stipulate


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext