-- LupineErrorTest.mesa.
-- Copyright (C) 1985 by Xerox Corporation. All rights reserved.
-- Last edited by BZM on February 25, 1982 11:41 AM.
-- Bob Hagmann February 8, 1985 5:09:38 pm PST

DIRECTORY
Rope USING [ROPE];


LupineErrorTest: DEFINITIONS = BEGIN

ROPE: TYPE = Rope.ROPE;


-- Error[AnonymousIdentifier] due to nameless nonparameter record component:

AnonRecord: TYPE = RECORD [--anon:-- STRING];

AnonRecordTest: ERROR [stringPair: AnonRecord];


-- Error[ComputedSequence] because of length-unknown sequence:

ComputedSequence: TYPE = RECORD [s: SEQUENCE COMPUTED [0..10) OF WORD];

CompSeqTest: PROC [seqPtr: POINTER TO ComputedSequence];


-- Error[ComputedVariant] because the pointer cases cannot be determined:

ComputedVariant: TYPE = RECORD [
SELECT COMPUTED * FROM
 impossible => [s: LONG STRING],
 okay => [a: ARRAY [-10..0] OF INTEGER],
 ENDCASE ] ← [okay[NULL]];

OverlaidVariant: TYPE = RECORD [
SELECT OVERLAID * FROM
 impossible => [s: LONG STRING],
 okay => [a: ARRAY [-10..0] OF INTEGER],
 ENDCASE ] ← [okay[NULL]];

StaticComputed: TYPE = RECORD [
SELECT COMPUTED * FROM
 okayNow => [w: WORD],
 okay => [a: ARRAY [-10..0] OF INTEGER],
 ENDCASE ] ← [okay[NULL]];

VariantTest: PROCEDURE [computed: ComputedVariant, overlaid: OverlaidVariant]
RETURNS [okay: StaticComputed];


-- Error[EmbeddedRESULT] due to address-containing VAR and RESULT parameters:

RESULTStringArray: TYPE = LONG POINTER TO ARRAY [-10..-5] OF LONG STRING;
VARCharDesc: TYPE = DESCRIPTOR FOR PACKED ARRAY OF POINTER TO CHARACTER;
RESULTBoolDescPtr: TYPE = POINTER TO DESCRIPTOR FOR PACKED ARRAY OF BOOLEAN;

VARStringOrText: TYPE = REF StringOrText;
VARStringOrTextSequence: TYPE = REF StringOrTextSequence;
StringOrTextSequence: TYPE = RECORD [SEQUENCE max: [0..200] OF StringOrText];

StringOrText: TYPE = RECORD [SELECT tag: * FROM
string => [s: STRING], text => [t: REF TEXT], ENDCASE] ← [text[NIL]];

IllegalVarResultTest: PROCEDURE [
 arrayPtr: RESULTStringArray,
 charDesc: VARCharDesc,
 boolDescPtr: RESULTBoolDescPtr,
 refVariant: VARStringOrText,
 seqVariant: VARStringOrTextSequence ];


-- Error[EmptyArray] due to this obsolete SEQUENCE idiom:

EmbeddedEmptyArray: TYPE = RECORD [
 empty: ARRAY [0..0) OF BOOLEAN, nonempty: REAL ];

EmptyArrayTest: SIGNAL [empty: EmbeddedEmptyArray];


-- Warning[HandleREF] when a REF-containing type is passed as a handle:

HANDLERef: TYPE = REF INTEGER;
HANDLERope: TYPE = ROPE;
HANDLEAtom: TYPE = ATOM;
HANDLEList: TYPE = LIST OF HANDLEAtom;
HANDLEProc: TYPE = PROCEDURE;

HandleRefTest: PROC [ref: HANDLERef, list: HANDLEList]
RETURNS [rope: HANDLERope, atom: HANDLEAtom, proc: HANDLEProc];


-- Warning[ImproperPassingMethod, ImproperReadonlyRESULTs, ImproperRESULTResults]
-- on all these types:

RESULTInt, HANDLEInt: TYPE = INTEGER;
VARText: TYPE = REF TEXT;
VARString: TYPE = LONG STRING;
RESULTPointer: TYPE = POINTER TO BOOLEAN;
RESULTReadonlyString: TYPE = LONG POINTER TO READONLY StringBody;
VARReadonlyDescriptor: TYPE = DESCRIPTOR FOR READONLY ARRAY OF WORD;
RESULTAtom: TYPE = ATOM;
VARList, RESULTList: TYPE = LIST OF INTEGER;
VARRope: TYPE = ROPE;
VARProc: TYPE = PROC;
VALUEZone: TYPE = MDSZone;

PassingTest: PROC [
-- Non AC types can only be called by Value:
INTEGER, RESULTInt, HANDLEInt, VARText,
-- Readonly referents cannot be called by VAR or RESULT:
STRING, RESULTReadonlyString, VARReadonlyDescriptor, RESULTAtom, VARRope,
-- Lists can only be called by VALUE and HANDLE:
VARList, RESULTList,
-- Transfers are called by value unless explicitly as handles:
PROC, VARProc,
-- Zones must be explicitly called as handles:
UNCOUNTED ZONE, VALUEZone, LONG POINTER TO ZONE,
-- Error message should have this type name truncated properly:
PROC [
 DESCRIPTOR FOR READONLY ARRAY OF LONG INTEGER,
 DESCRIPTOR FOR READONLY ARRAY OF LONG INTEGER,
 DESCRIPTOR FOR READONLY ARRAY OF LONG INTEGER,
 DESCRIPTOR FOR READONLY ARRAY OF LONG INTEGER,
 DESCRIPTOR FOR READONLY ARRAY OF LONG INTEGER] ]
RETURNS [
--There are only VAR and RESULT arguments, not results:
VARString, RESULTPointer ];


-- Error[InterfaceVariables] because interface variables are not marshaled:

interfaceInt: INTEGER;
interfacePointer: POINTER;
interfaceRecord: RECORD[p: PROCEDURE];


-- Warning[InvalidHandle] when the referent is unknown:

UnknownOpaque: TYPE;
KnownOpaque: TYPE [300];

HandleTest1: PROC [ptr: POINTER] RETURNS [longPtr: LONG POINTER];
HandleTest2: PROC RETURNS [unknownPtr: POINTER TO UnknownOpaque];
HandleTest3: PROC RETURNS [ref: REF, refAny: REF ANY];
HandleTest4: PROC RETURNS [knownPtr: LONG POINTER TO KnownOpaque];
HandleTest5: PROC RETURNS [i: POINTER TO LONG INTEGER, b: REF BOOLEAN];


-- Error[ProbablePointerRecursion] because only LIST lists are supported:

PtrRecursion: TYPE = LONG POINTER TO RecursionRecord;
RecursionRecord: TYPE = RECORD [ptr: PtrRecursion];

RecursionTest: PROC RETURNS [ptr: PtrRecursion];


-- Error[SequenceInsideVariant] because they are not supported:

SequenceInsideVariant: TYPE = RECORD [
SELECT tag: * FROM seq => [SEQUENCE max: [0..10] OF BOOLEAN], ENDCASE ];

SequenceTest: PROC [variant: LONG POINTER TO SequenceInsideVariant];


-- Error[UnimplementedMarshaling] for these unlikely types:

MonitoredRecord: TYPE = MONITORED RECORD [queue: INTEGER];

MonRecordTest: PROC [monRecord: MonitoredRecord];
MonitorTest: ERROR [lock: MONITORLOCK];
ConditionTest: SIGNAL RETURNS [POINTER TO CONDITION];


-- Error[UnsupportedTransfers] for these routine types:

process: PROCESS;
program: PROGRAM;
port: PORT;


END. -- LupineErrorTest.

Bob Hagmann February 8, 1985 5:09:39 pm PST
changes to: DIRECTORY