Sather Home Page

Section 8.2.2.4:
QUADBITS

immutable class QUADBITS < $BIT_PATTERN
$BIT_PATTERN

Inheritance map

Formal Types

types

SAME = QUADBITS ;

QUADBITS = seq of BIT
   inv oct ==
      len oct = 32

This class is the primitive immutable class which has thirty-two bits, but otherwise may have any meaning. Operations for creation, conversion and individual bit testing and manipulation are provided in addition to equality testing (which is solely a test of identical bit-patterns).

External specifications

The following feature is required to be implemented for this class in accordance with the specification given in $IS_EQ of which $BIT_PATTERN is a sub-type :-


The following features are required to be implemented for this class in accordance with the specifications given by inheritance in $STR of which $BIT_PATTERN is a sub-type :-


The following feature is required to be implemented for this class in accordance with the specification given in $HASH of which $BIT_PATTERN is a sub-type :-


The following features are required to be implemented for this class in accordance with the specifications given in $BINARY of which $BIT_PATTERN is a sub-type :-


The following features are required to be implemented for this class in accordance with the specifications given in the abstract class $BIT_PATTERNS of which $BIT_PATTERN is a sub-type:-


The following features are required to be implemented for this class in accordance with the specifications given in the abstract class $BIT_PATTERN :-


Quad_Bits

This reader routine provides the same value as asize - for a four octet object!

Quad_Bits : CARD
Formal Signature
Quad_Bits() : res : CARD
Pre-condition

Since this is a reader routine, the pre-condition is vacuously true.

Post-condition
post (res = asize(self))

This reader routine returns the number of bits contained in a four octet object.


Quad_Max

This reader routine returns the maximum unsigned value which can be represented in a bit-pattern of four octets.

Quad_Max : CARD
Formal Signature
Quad_Max() : res : CARD
Pre-condition

Since this is a reader routine, the pre-condition is vacuously true.

Post-condition
post (res = 2 ** asize(self) - 1)

This reader routine returns the maximum numeric value representable as an exact unsigned number in the four octet bit-pattern.


Octets_per_Quad

This reader routine returns the number of octets in this class of object.

Octets_per_Quad : CARD
Formal Signature
Octets_per_Quad() : res : CARD
Pre-condition

Since this is a reader routine, the pre-condition is vacuously true.

Post-condition
post res = asize div OCTET.asize

This reader routine returns the number of octets in an object of this class.


create

This creation feature returns a new object all the bits of which are clear (ie having the value clearbit.

create : SAME
Formal Signature
create() res : SAME
Pre-condition

Because there are no arguments to this feature, the pre-condition is vacuously true.

Post-condition
post let resbits : seq of BIT be st resbits = res in
   resbits = [clearbit, clearbit, clearbit, clearbit, clearbit, clearbit, clearbit, clearbit,
         clearbit, clearbit, clearbit, clearbit, clearbit, clearbit, clearbit, clearbit,
         clearbit, clearbit, clearbit, clearbit, clearbit, clearbit, clearbit, clearbit,
         clearbit, clearbit, clearbit, clearbit, clearbit, clearbit, clearbit, clearbit]

This routine creates a new value all the components of which are clear.


create

This second creation routine returns a new object in which the bit-pattern is the representation of val as an exact number.

create (
val : CARD
) : SAME
Formal Signature

Note that the name of this feature in vdm has been changed since there is no name overloading in vdm.

create2(val : CARD) res : SAME
Pre-condition
pre val <= Quad_Max
Post-condition
post card(res) = val

This routine returns a new object which takes the value val as a bit-pattern.


create

This third creation routine returns a new object in which the bit-pattern is the representation of the character val.

create (
val : CHAR
) : SAME
Formal Signature

Note that the name of this feature in vdm has been changed since there is no name overloading in vdm.

create3(val : CHAR) res : SAME
Pre-condition
pre let extra = tl tl tl tl CHAR.binstr(val) in
      forall idx | idx in inds extra & extra(idx) = null
Post-condition
post char(res) = val

This routine returns a new object which takes the value val as a bit-pattern.


octet!

This iter, which is not relevant to all classes sub-typing from $BIT_PATTERN, yields in sequence the individual octets which make up self - from the least significant group of eight upwards.

octet! : OCTET
Formal Signature

Note that the formal name of the iter has been changed to replace the exclamation mark iter symbol to a name acceptable to vdm tools.

octet_iter(self : SAME) res : OCTET
Pre-condition
pre len history mod 8 = 0
Post-condition

This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).

post let loc_res : seq of BIT be st
         (res = loc_res
            and len loc_res = 8) in
      ((history~ = []
         and (history = loc_res))
      or (history = history ^ loc_res))
         and loc_res = self((len history + 1), ..., (len history + 8))
Quit condition

For quit actions see the specification of the quit statement.

errs QUIT : len history~ = len self -> quit

This iter yields in turn the sequence of octets making up self, st\rting with the least significant group of eight bits.


Language Index Library Index Binary Index
Comments or enquiries should be made toKeith Hopper.
Page last modified: Monday, 28 May 2001.
Produced with Amaya