numcode.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand        --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------


partial class NUM_CODE

partial class NUM_CODE is -- This partial class contains those constants and routines which are -- common not only to both the CARD class and the FIELD class of exact -- numbers, but also code classes which cannot, of course, use arithmetic -- operations. -- Version 1.0 Sep 97. Copyright K Hopper, U of Waikato -- Development History -- ------------------- -- Date Who By Detail -- ---- ------ ------ -- 16 Sep 97 kh Original extracted from CARD_COMMON include AVAL{BIT} asize -> ; include BINARY ; include COMPARABLE; private const asize : CARD := NUM_BITS::Num_Bits ; const Num_Bits : CARD := asize ; -- This is a portable (for this class) definition of the size in bits. -- Two routines giving max and min values (see $NFE). maxval : SAME is loc_qbits : QUADBITS := QUADBITS::create(NUM_BITS::Num_Max) ; return create(loc_qbits) end ; minval : SAME is return create(QUADBITS::create(0)) end ; private do_build( cursor : BIN_CURSOR ) : SAME pre ~void(cursor) and ~cursor.is_done post true is -- This routine is the private version of build - the one which -- actually does the work. It takes up to four octets from the string -- attached to the cursor and returns the code value indicated. return create(QUADBITS::build(cursor)) end ; build( cursor : BIN_CURSOR ) : SAME pre ~void(cursor) and ~cursor.is_done post true is -- This routine takes up to four octets from the string attached to -- the cursor and returns the code value indicated. return do_build(cursor) end ; create( val : QUADBITS ) : SAME is -- This routine creates from a cardinal value. builtin CARD_QUAD end ; create( val : CARD ) : SAME is -- This routine creates from a cardinal value. builtin CARD_QUAD end ; binstr : BINSTR pre true post create(result) = self is -- This routine is provided to convert from a numeric code class to -- a binary string. return QUADBITS::create(card).binstr end ; card : CARD pre true post result.binstr = self.binstr is -- This routine is provided to convert from an implementation class -- using this partial class to a cardinal number. The built-in -- implementation is implementation-dependent. builtin CARD_CARD end ; is_eq( other : SAME ) : BOOL is -- This predicate returns true if and only if self and other represent -- the same value. builtin CARD_IS_EQ end ; is_lt( other : SAME ) : BOOL is -- This predicate returns true if and only if self is less than other. -- Built-in. builtin CARD_IS_LT end ; end ; -- NUM_CODE