PWDescr.mesa
Copyright © 1984 by Xerox Corporation. All rights reversed.
Created by Louis Monier, July 19, 1985 11:55:35 am PDT
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: ROPE ← NIL, -- name of the field, e.g. cAdr
data: REF ← NIL, -- think of it as a property
specificRef: REF ← NIL];
-- Specific refs
-- A single bit (clock)
BitRef: TYPE = REF BitRec; -- coded on one wire
BitRec: TYPE = RECORD[val: BOOL ← FALSE];
-- 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: REF ← NIL] 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: BOOL ← FALSE, data: REF ← NIL];
SetTypeBool: PUBLIC PROC [descr: Descriptor, name: ROPE, initVal: BOOL ← FALSE, complement: BOOL ← FALSE, data: REF ← NIL];
SetTypeInt: PUBLIC PROC [descr: Descriptor, name: ROPE, nbBits: INT, initVal: INT ← 0, complement: INT ← 0, data: REF ← NIL];
SetTypePad: PUBLIC PROC [descr: Descriptor, name: ROPE, padRef: PadRef, data: REF ← NIL];
-- 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: BOOL ← TRUE];
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];