PreviousUpNext

15.4.1110  src/lib/std/src/one-word-unt-guts.pkg

## one-word-unt-guts.pkg
#
# One-word unt ("unsigned int") -- 32-bit unt on 32-bit architectures, 64-bit unt on 64-bit architectures.

# Compiled by:
#     src/lib/std/src/standard-core.sublib

###             "Words, words. They're all we have to go on."
###
###                -- Tom Stoppard, "Rosencrantz and Guildenstern Are Dead"



package one_word_unt_guts: (weak)  Unt {        # Unt           is from   src/lib/std/src/unt.api
    #                                           # inline_t      is from   src/lib/core/init/built-in.pkg
    #
    package w32 = inline_t::u1;                 # "u1" == "one-word unsigned int" -- 32 bits on 32-bit architectures, 64 bits on 64-bit architectures.

    Unt = one_word_unt::Unt;

    unt_size = 32;                                                                              # 64-bit issue.

    my to_large_unt:     Unt -> large_unt::Unt   =   w32::to_large_unt;
    my to_large_unt_x:   Unt -> large_unt::Unt   =   w32::to_large_unt_x;
    my from_large_unt:   large_unt::Unt -> Unt   =   w32::from_large_unt;

    to_multiword_int    =   w32::to_large_int;
    to_multiword_int_x  =   w32::to_large_int_x;
    from_multiword_int  =   w32::from_large_int;

    my to_int:     Unt -> Int   =   w32::to_int;
    my to_int_x:   Unt -> Int   =   w32::to_int_x;
    my from_int:   Int -> Unt   =   w32::from_int;

    my bitwise_or:   (Unt, Unt) -> Unt   =   w32::bitwise_or;
    my bitwise_xor:  (Unt, Unt) -> Unt   =   w32::bitwise_xor;
    my bitwise_and:  (Unt, Unt) -> Unt   =   w32::bitwise_and;
    my bitwise_not:  Unt        -> Unt   =   w32::bitwise_not;

    my (*) : (Unt, Unt) -> Unt   =   w32::(*);
    my (+) : (Unt, Unt) -> Unt   =   w32::(+);
    my (-) : (Unt, Unt) -> Unt   =   w32::(-);
    my (/) : (Unt, Unt) -> Unt   =   w32::div ;
    my (%) : (Unt, Unt) -> Unt   =   w32::mod ;

    fun compare (w1, w2)
        =
        if   (w32::(<) (w1, w2))  LESS;
        elif (w32::(>) (w1, w2))  GREATER;
        else                      EQUAL;
        fi;

    my (>)  : (Unt, Unt) -> Bool   =   w32::(>);
    my (>=) : (Unt, Unt) -> Bool   =   w32::(>=);
    my (<)  : (Unt, Unt) -> Bool   =   w32::(<);
    my (<=) : (Unt, Unt) -> Bool   =   w32::(<=);

    my (<<)   =   w32::check_lshift;
    my (>>)   =   w32::check_rshiftl;
    my (>>>)  =   w32::check_rshift; 

    my (-_)  : Unt -> Unt = (-_);
    my min:  (Unt, Unt) -> Unt = w32::min;
    my max:  (Unt, Unt) -> Unt = w32::max;

    format = num_format::format_unt;
    to_string = format number_string::HEX;

    scan = num_scan::scan_word;
    from_string = pre_basis::scan_string (scan number_string::HEX);


};      #  package one_word_unt_guts 





## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2012,
## released under Gnu Public Licence version 3.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext