| 123456789101112131415161718192021222324252627282930313233343536373839 |
- program t64_arrays;
- { t64 -- array TYPES and array typed constants: the 2-D sheet and XPOS.
- CALC.PAS:133 and :137:
- Cells = array['A'..'G',1..FYMax] of CellRec; (FYMax = 21)
- XPOS : array['A'..'G'] of Integer = (3,14,25,36,47,58,68);
- Ranges are row-major with the LAST varying fastest, and both ranges are
- stored in an ArrRec the symbol points at, so the shape survives for
- indexing. `Sheet' is 7 * 21 * 80 = 11760 bytes; `XPOS' is 7 * 2 = 14.
- An array TYPED CONSTANT cannot fold to a word, so - like a set - its bytes
- are emitted in the code stream behind a JMP and the name becomes an
- addressable value; each element is written little-endian in the element's
- bytes. So XPOS does NOT appear in the data area: data=11764 is Sheet
- (11760) + the two @@T temporaries, and XPOS's 14 bytes are in the code
- stream (code=67). That is the storage decision showing up in the numbers.
- Array ELEMENT ACCESS (`Sheet[fx,fy]', `XPOS['C']') is the next increment: an
- element's width is not the array's, so a subscript is a LOUD error today
- rather than a store of the whole array. }
- type
- Attributes = (Constant, Formula, Txt, OverWritten, Locked, Calculated);
- CellRec = record
- CellStatus : set of Attributes;
- Contents : String[70];
- Value : Real;
- DEC, FW : 0..20;
- end;
- Cells = array ['A'..'G', 1..21] of CellRec;
- const
- XPOS : array ['A'..'G'] of Integer = (3, 14, 25, 36, 47, 58, 68);
- var
- Sheet : Cells;
- begin
- writeln ('arrays declared')
- end.
|