PWDescr.mesa 
Copyright © 1984 by Xerox Corporation. All rights reversed.
Created by Louis Monier, July 19, 1985 11:55:35 am PDT
Last Edited by: Monier, May 29, 1985 9:58:30 am PDT
Bertrand Serlet November 26, 1985 11:47:40 am PST
DIRECTORY
CD, Rope;
PWDescr: CEDAR DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
allOnes: INT = LAST[INT]; -- same as 2B10-1=2147483647
-- Types for describing control parts
Descriptor: TYPE = REF DescriptorRec;
DescriptorRec: TYPE = RECORD[
genRef: REF,
items: SEQUENCE size: CARDINAL OF Item];     -- which generator to use
Item: TYPE = REF ItemRec;
ItemRec: TYPE = RECORD [
name: ROPENIL,  -- name of the field, e.g. cAdr
data: REFNIL,  -- think of it as a property
specificRef: REFNIL];
-- Specific refs
-- A single bit (clock)
BitRef: TYPE = REF BitRec;  -- coded on one wire
BitRec: TYPE = RECORD[val: BOOLFALSE];
-- A pair of bits (usually complementary values)
BoolRef: TYPE = REF BoolRec; -- coded on two wires
BoolRec: TYPE = RECORD[val0, val1: BOOL];
-- A sequence of booleans, high order bit=0 "on the left"
IntRef: TYPE = REF IntRec;  -- every bit is coded as a boolean
IntRec: TYPE = RECORD[val, mask: INT, bools: SEQUENCE nbBits: CARDINAL OF BoolRef];
-- A set of "things"
PadRef: TYPE = REF PadRec;  -- no value, but positions
PadRec: TYPE = RECORD[SEQUENCE size: CARDINAL OF INT];
--Turn a list of ropes in a vanilla descriptor of the appropriate size
RopesToDescr: PUBLIC PROC [names: LIST OF ROPE, genRef: REFNIL] RETURNS [descr: Descriptor];
-- Set the type of an item, with an initial value if you wish and a data (usually an atom)
SetTypeBit: PUBLIC PROC [descr: Descriptor, name: ROPE, initVal: BOOLFALSE, data: REFNIL];
SetTypeBool: PUBLIC PROC [descr: Descriptor, name: ROPE, initVal: BOOLFALSE, complement: BOOLFALSE, data: REFNIL];
SetTypeInt: PUBLIC PROC [descr: Descriptor, name: ROPE, nbBits: INT, initVal: INT ← 0, complement: INT ← 0, data: REFNIL];
SetTypePad: PUBLIC PROC [descr: Descriptor, name: ROPE, padRef: PadRef, data: REFNIL];
-- Set the value of an item; complement has to be interpeted bitwise as follows: if set to TRUE, then [val0, val1] ← [val, ~val], otherwise [val0, val1] ← [val, val]
SetBit: PUBLIC PROC [descr: Descriptor, name: ROPE, val: BOOL];
SetBool: PUBLIC PROC [descr: Descriptor, name: ROPE, val: BOOL, complement: BOOLTRUE];
SetInt: PUBLIC PROC [descr: Descriptor, name: ROPE, val: INT, complement: INT ← allOnes];
SetMask: PUBLIC PROC [descr: Descriptor, name: ROPE, mask: INT];
SetData: PUBLIC PROC [descr: Descriptor, name: ROPE, data: REF];
-- Find an item by name
NameToItem: PUBLIC PROC [descr: Descriptor, name: ROPE] RETURNS [item: Item];
IsInDescr: PUBLIC PROC [descr: Descriptor, name: ROPE] RETURNS [yes: BOOL];
-- Enumeration procs (the order matters)
ForEachItemProc: TYPE = PROC [item: Item];
EnumerateItems: PUBLIC PROC [descr: Descriptor, forEachItemDo: ForEachItemProc];
END.