SELECT class
FROM
definition => {
mod: REF ROPE ← NEW[ROPE ← NIL];
name: ROPE ← TypeToName[type, mod];
length: INT = mod^.Length[];
IF length # 0
THEN
-- put out module name unless type name is all caps.
FOR i: INT IN [0..Rope.Length[name]) DO
IF Rope.Fetch[name, i] NOT IN ['A..'Z] THEN {put.PutRope[Rope.Cat[mod^, "."]]; EXIT};
REPEAT
FINISHED =>
IF Rope.Equal[name, "LORA"]
THEN {
-- sorry Russ.
BasicPrintType[UnderType[type], put, depth, width, verbose];
RETURN;
};
ENDLOOP;
put.PutRope[name];
IF
NOT name.IsEmpty[]
AND verbose
THEN
FOR l:
LIST
OF
ROPE ← everybodyKnowsThese, l.rest
UNTIL l =
NIL
DO
IF Rope.Equal[l.first, name] THEN EXIT;
REPEAT
FINISHED =>
{put.PutRope[": TYPE = "];
BasicPrintType[UnderType[type], put, depth, width, verbose];
};
ENDLOOP;
};
cardinal => put.PutRope["CARDINAL"];
longCardinal => put.PutRope["LONG CARDINAL"];
integer => put.PutRope["INTEGER"];
longInteger => put.PutRope["INT"];
real => put.PutRope["REAL"];
character => put.PutRope["CHAR"];
atom => put.PutRope["ATOM"];
rope => put.PutRope["ROPE"];
list => {
put.PutRope["LIST OF "];
BasicPrintType[IndexToType[Range[type], 1], put, depth, width];
};
ref => {
range: Type ← Range[type];
put.PutRope["REF "];
PutReadonly[type];
IF range # nullType THEN {BasicPrintType[range, put, depth, width]};
IF verbose
THEN
SELECT TypeClass[UnderType[range]]
FROM
record, structure =>
{put.PutRope["; \n"];
BasicPrintType[range, put, depth, width];
put.PutRope[": TYPE = "];
BasicPrintType[UnderType[range], put, depth, width]};
ENDCASE;
};
pointer, longPointer, basePointer, relativePointer => {
range: Type ← Range[type];
SELECT class
FROM
longPointer => put.PutRope["LONG "];
relativePointer => put.PutRope["RELATIVE "];
basePointer => put.PutRope["LONG BASE "];
ENDCASE;
SELECT
TRUE
FROM
range = nullType OR TypeClass[range] = unspecified => put.PutRope["POINTER"];
EquivalentTypes[range, CODE[StringBody]] => put.PutRope["STRING"];
ENDCASE =>
{put.PutRope["POINTER TO "];
SELECT class
FROM
longPointer, pointer => PutReadonly[type];
ENDCASE;
BasicPrintType[range, put, depth, width]};
};
descriptor, longDescriptor => {
range: Type ← nullType;
IF class = longPointer THEN put.PutRope["LONG "];
put.PutRope["DESCRIPTOR"];
range ← Range[type];
IF range # nullType
AND TypeClass[range] # unspecified
THEN
{put.PutRope[" TO "];
PutReadonly[type];
BasicPrintType[range, put, depth, width]};
};
procedure, signal, error, program, port => {
argsType, rtnsType: Type ← nullType;
prefix:
ROPE ←
SELECT class
FROM
procedure => "PROC", signal => "SIGNAL", error => "ERROR",
program => "PROGRAM" , port => "PORT", ENDCASE => "??";
put.PutRope[prefix];
argsType ← Domain[type];
IF argsType # nullType
THEN {
put.PutChar[' ];
BasicPrintType[argsType, put, depth-1, width]};
SELECT class
FROM
procedure, signal => {
rtnsType ← Range[type];
IF rtnsType # nullType
THEN
{put.PutRope[" RETURNS "];
BasicPrintType[rtnsType, put, depth-1, width];
};
};
ENDCASE;
};
enumerated => {
n: INT ← 0;
md: BOOL ← IsMachineDependent[type];
IF type = UnderBoolean THEN {put.PutRope["BOOL"]; RETURN};
IF IsMachineDependent[type] THEN put.PutRope["MACHINE DEPENDENT "];
put.PutRope["{"];
FOR i:
INT
IN [1..NValues[type]]
DO
IF i > 1 THEN {put.PutChar[', ]; put.PutChar[' ]};
IF i > width THEN {put.PutRope["..."]; EXIT};
now fetch and print the element (if possible)
PrintTV.Print[Value[type, i], put];
ENDLOOP;
put.PutRope["}"];
};
subrange => {
ENABLE Error =>
IF reason = rangeFault
THEN {put.PutRope["0..0)"];
CONTINUE};
empty subrange causes First to raise a RangeFault.
IF verbose AND depth > 1 THEN BasicPrintType[Ground[type], put, depth-1, width];
put.PutChar['[];
PrintTV.Print[First[type], put, depth, width];
put.PutRope[".."];
PrintTV.Print[Last[type], put, depth, width];
put.PutChar[']];
};
union =>
put.PutRope["UNION??"];
sequence => {
IF IsComputed[type] THEN put.PutRope["COMPUTED "];
IF IsPacked[type] THEN put.PutRope["PACKED "];
put.PutRope["SEQUENCE "];
BasicPrintType[Domain[type], put, depth-1, width];
put.PutRope[" OF "];
BasicPrintType[Range[type], put, depth-1, width];
};
record, structure => {
IF class = record THEN put.PutRope["RECORD"];
IF depth < 2 THEN {put.PutRope["[...]"]; RETURN};
put.PutChar['[];
PutInnards[type];
put.PutChar[']];
};
array => {
IF IsPacked[type] THEN put.PutRope["PACKED "];
put.PutRope["ARRAY "];
BasicPrintType[Domain[type], put, depth-1, width];
put.PutRope[" OF "];
BasicPrintType[Range[type], put, depth-1, width];
};
countedZone => put.PutRope["ZONE"];
uncountedZone => put.PutRope["UNCOUNTED ZONE"];
nil => put.PutRope["nullType"];
unspecified => put.PutRope["UNSPECIFIED"];
process => put.PutRope["PROCESS"];
type => put.PutRope["TYPE"];
opaque => put.PutRope["OPAQUE"];
any => put.PutRope["ANY"];
globalFrame => put.PutRope["GF??"];
localFrame => put.PutRope["LF??"];
ENDCASE => put.PutRope["??"];
};