19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

40.6 <strong>The</strong> Trait <strong>Fortress</strong>.Core.BinaryEndianWord<br />

<strong>The</strong> type BinaryEndianWordb,bigEndianBytes,bigEndianBits is exactly like BinaryWordb but bears two<br />

kinds of endianness information. A BinaryEndianWord may be split into a sequence of smaller words; the result is of<br />

type BinaryLinearEndianSequence. <strong>The</strong> flag bigEndianBytes indicates whether subword 0 is the most significant<br />

subword (if bigEndianBytes is true) or least significant subword (if bigEndianBytes is false) of the original binary<br />

word. A BinaryEndianWord may also be subscripted to extract a bit or a bit field; the flag bigEndianBits indicates<br />

whether bit 0 is the most significant bit (if bigEndianBits is true) or least significant bit (if bigEndianBits is false)<br />

of the original binary word. (Yes, it may seem strange for the bit ordering to differ from the subword ordering, but they<br />

do differ on a number of architectures, including SPARC.) Extracting a bit produces a Bit, that is, a BinaryWord0 .<br />

Extracting a bit field of width k produces a BinaryEndianLinearEndianSequence with n = k and b = 0 ; the<br />

endianness of the sequence matches the bit-endianness of the original BinaryEndianWord.<br />

trait BinaryEndianWordnat b,bool bigEndianBytes,bool bigEndianBits<br />

extends { BasicBinaryWordOperationsBinaryEndianWordb,bigEndianBytes,bigEndianBits, b}<br />

comprises {}<br />

where { b ≤ maxBinaryWordBitLog }<br />

coercion int r(x:IntegerStaticr) where { −2 b−1 ≤ r < 2 b }<br />

opr [j: IndexInt] : BinaryEndianWord1,bigEndianBytes,bigEndianBits<br />

throws { IndexOutOfBoundsException }<br />

opr nat k[j: IntegerStatick] : BinaryEndianWord1,bigEndianBytes,bigEndianBits<br />

where { k < 2 b }<br />

opr nat m[r: RangeOfStaticSizeIndexInt, m] :<br />

BinaryEndianLinearEndianSequence1,bigEndianBytes,bigEndianBits, m,bigEndianBits<br />

throws { IndexOutOfBoundsException }<br />

opr int a,nat m,int c[r:StaticRangea, m, c] :<br />

BinaryEndianLinearEndianSequence1,bigEndianBytes,bigEndianBits, m,bigEndianBits<br />

where { 0 ≤ a < 2 b , 0 ≤ a + m · c < 2 b }<br />

opr [j: IndexInt] := (v: Bit):<br />

BinaryEndianWordb,bigEndianBytes,bigEndianBits<br />

throws { IndexOutOfBoundsException }<br />

opr nat k[j: IntegerStatick] := (v: Bit):<br />

BinaryEndianWordb,bigEndianBytes,bigEndianBits<br />

where { k < 2 b }<br />

opr nat m[r: RangeOfStaticSizeIndexInt, m] := (v: BinaryLinearSequence1, m):<br />

BinaryEndianWordb,bigEndianBytes,bigEndianBits<br />

throws { IndexOutOfBoundsException }<br />

opr int a,nat m,int c[r:StaticRangea, m, c] := (v: BinaryLinearSequence1, k):<br />

BinaryEndianWordb,bigEndianBytes,bigEndianBits<br />

where { 0 ≤ a < 2 b , 0 ≤ a + m · c < 2 b }<br />

update(j:IndexInt, v: Bit):<br />

BinaryEndianWordb,bigEndianBytes,bigEndianBits<br />

throws { IndexOutOfBoundsException }<br />

updatenat k(j: IntegerStatick, v: Bit):<br />

BinaryEndianWordb,bigEndianBytes,bigEndianBits<br />

where { k < 2 b }<br />

updatenat m(r:RangeOfStaticSizeIndexInt, m, v: BinaryLinearSequence1, m):<br />

BinaryEndianWordb,bigEndianBytes,bigEndianBits<br />

throws { IndexOutOfBoundsException }<br />

updateint a,nat m,int c(r:StaticRangea, m, c, v:BinaryLinearSequence1, m):<br />

BinaryEndianWordb,bigEndianBytes,bigEndianBits<br />

where { 0 ≤ a < 2 b , 0 ≤ a + m · c < 2 b }<br />

283

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!