XMesa5a:
PROCEDURE = {
-- STRING's
stringMax: INTEGER = 128;
someExtra: INTEGER = 0;
currentLine: LONG STRING ← [256];
nowLine: LONG STRING ← [256];
funnyStuff: LONG STRING = "ha";
stringBuffer: LONG STRING ← [stringMax + someExtra];
laugh: LONG STRING ← funnyStuff;
joke: LONG STRING = "ha";
s1: LONG STRING ← "I know where its at";
s1[7] ← 't;
XMesaProcs.Ischarequal[s1[7], 't, 2700, filename];
laugh[1] ← 'e;
XMesaProcs.Ischarequal[funnyStuff[1], 'e, 2710, filename]; AR1150
XMesaProcs.Isequal[currentLine.maxlength, 256, 2720, filename];
XMesaProcs.Isequal[stringBuffer.maxlength, 128, 2730, filename];
XMesaProcs.Isnotequal[stringBuffer.maxlength, 256, 2740, filename];
currentLine ← "I know what it takes";
nowLine ← "I know where its at";
IF currentLine = nowLine THEN XMesaProcs.PutFailMessage[2750, filename];
nowLine ← currentLine;
IF currentLine # nowLine THEN XMesaProcs.PutFailMessage[2770, filename];
};
XMesa5b:
PROCEDURE = {
-- ARRAY DESCRIPTOR's
n: INTEGER;
signalRaised: BOOLEAN ← FALSE;
dd: LONG DESCRIPTOR FOR ARRAY OF INTEGER;
NFS: Declared type of referent of pp for allocation.
PpT: TYPE = ARRAY [0..10) OF INTEGER;
pp: LONG POINTER TO PpT;
Table: TYPE = DESCRIPTOR FOR ARRAY OF INTEGER;
this: INTEGER = 10;
thisArray: ARRAY [0..this) OF INTEGER ← ALL[5];
anyTable: Table ← DESCRIPTOR[thisArray];
Randomize:
PROCEDURE [input: Table] = {
--randomize first 10 elements
i, j: INTEGER ← 0;
i ← input.LENGTH;
FOR j IN [0..i) DO input[j] ← j; ENDLOOP;
};
NFS: Added initialization, of pp, and decallocation of its referent.
uz: UNCOUNTED ZONE ← OSOps.GetSystemUZone[];
pp ← uz.NEW[PpT];
Randomize[anyTable];
XMesaProcs.Isequal[thisArray[0], 0, 2780, filename];
XMesaProcs.Isequal[thisArray[1], anyTable[1], 2790, filename];
dd ← DESCRIPTOR[pp];
dd[0] ← 100;
dd[5] ← 100;
dd[9] ← 100;
BEGIN
ENABLE ANY => {XMesaProcs.PutFailMessage[2792, filename]; CONTINUE};
XMesaProcs.Isequal[dd[5], 100, 2794, filename];
XMesaProcs.Isequal[dd[9], 100, 2796, filename];
END;
dd ← DESCRIPTOR[pp, 5];
BEGIN
ENABLE ANY => {signalRaised ← TRUE; CONTINUE};
XMesaProcs.Isequal[dd[9], 100, 2799, filename]; --this is here to check bounds checking
NFS: Added initialization, of pp, and decallocation of its referent.
uz.FREE[@pp];
END;
XMesaProcs.Isboolequal[signalRaised, TRUE, 2798, filename];
signalRaised ← FALSE;
n ← LENGTH[dd];
XMesaProcs.Isequal[n, 5, 2810, filename];
};
XMesa5d:
PROCEDURE = {
-- VARIANT RECORDs
z: UNCOUNTED ZONE = OSOps.GetSystemUZone[];
declaring variant records
StreamType: TYPE = {disk, display, keyboard};
StreamHandle: TYPE = POINTER TO Stream;
Stream:
TYPE =
RECORD [
Get: INTEGER,
Put: INTEGER,
body:
SELECT type: StreamType
FROM
disk => [
fileid: INTEGER,
buffer:
SELECT size: *
FROM
short => [b: CARDINAL], long => [b: INTEGER], ENDCASE],
display => [first: BOOL, last: INTEGER, nlines: [0..100]],
keyboard => [keys: INTEGER],
ENDCASE];
overlaid records
overlayrec:
TYPE =
RECORD [
SELECT OVERLAID * FROM
one => [c: CHAR, i: INTEGER, next: LONG POINTER TO overlayrec],
two => [b: BOOL, next: LONG POINTER TO overlayrec ← NIL],
three => [s: STRING],
ENDCASE];
VRec:
TYPE =
RECORD [
common: INTEGER ← 0,
variant:
SELECT tag: *
FROM
red => [r1: BOOL ← FALSE],
green => [g1: INTEGER ← 0]
ENDCASE ← red[TRUE] |
NULL];
v1: VRec ← [common: 10];
v2: VRec ← [variant: NULL];
overlyexample: overlayrec;
otherPtr: LONG POINTER TO overlayrec.two ← NIL;
clearexample: two overlayrec;
bound variant types
r: Stream;
rDisk: disk Stream;
rDisplay: display Stream;
rKeyb: keyboard Stream;
rShort: short disk Stream;
rLong: long disk Stream;
rDisk.fileid ← 0;
rDisplay.first ← FALSE;
rShort ← [5, 10, disk[-1, short[65535]]];
XMesaProcs.Isequal[rShort.Get, 5, 2900, filename];
XMesaProcs.Isequal[rShort.Put, 10, 2910, filename];
XMesaProcs.Isequal[rShort.fileid, -1, 2920, filename];
XMesaProcs.IsCardequal[rShort.b, 65535, 2930, filename];
rLong ← [6, 11, disk[-2, long[-5]]];
XMesaProcs.Isequal[rLong.Get, 6, 2900, filename];
XMesaProcs.Isequal[rLong.Put, 11, 2910, filename];
XMesaProcs.Isequal[rLong.fileid, -2, 2920, filename];
XMesaProcs.Isequal[rLong.b, -5, 2930, filename];
rKeyb ← [1, 2, keyboard[3]];
XMesaProcs.Isequal[rKeyb.Get, 1, 2940, filename];
XMesaProcs.Isequal[rKeyb.Put, 2, 2950, filename];
XMesaProcs.Isequal[rKeyb.keys, 3, 2960, filename];
accessing components of unbound variant types
r.body ← keyboard[10];
WITH strm: r
SELECT
FROM
display => BEGIN strm.first ← FALSE; strm.last ← -2; strm.nlines ← 8; END;
disk => WITH strm SELECT FROM short => b ← 65535; long => b ← -2; ENDCASE;
keyboard =>
IF strm.keys # 10 THEN XMesaProcs.PutFailMessage[2965, filename];
ENDCASE => strm.body ← disk[-5, short[65535]];
IF r.type # keyboard THEN XMesaProcs.PutFailMessage[2983, filename];
r.body ← display[TRUE, -1, 99];
IF r.type # display THEN XMesaProcs.PutFailMessage[2987, filename];
WITH strm: r
SELECT
FROM
display =>
BEGIN
IF strm.first # TRUE THEN XMesaProcs.PutFailMessage[2995, filename];
IF strm.last # -1 THEN XMesaProcs.PutFailMessage[3005, filename];
IF strm.nlines # 99 THEN XMesaProcs.PutFailMessage[3015, filename];
END;
ENDCASE => XMesaProcs.PutFailMessage[3020, filename];
overlaid records
overlyexample.b ← FALSE;
XMesaProcs.Isboolequal[overlyexample.b, FALSE, 3030, filename];
overlyexample.c ← 'A;
XMesaProcs.Ischarequal[overlyexample.c, 'A, 3040, filename];
clearexample.b ← TRUE;
clearexample.next ← otherPtr;
XMesaProcs.Isboolequal[clearexample.b, TRUE, 3050, filename];
XMesaProcs.Ispointerequal[clearexample.next, otherPtr, 3060, filename];
otherPtr ← @clearexample;
XMesaProcs.Isboolequal[otherPtr.b, TRUE, 3070, filename];
XMesaProcs.Ispointerequal[otherPtr.next, NIL, 3080, filename];
XMesaProcs.Isequal[SIZE[disk Stream], 6, 3090, filename]; moved to XMesaCmplr9