cse.machineDep, cse.packed =>
GO
TO bailOut;
We can't dictate that C put things in the right place
ENDCASE => {
fieldCtx: Symbols.CTXIndex = cse.fieldCtx;
firstSei: Symbols.ISEIndex =
SymbolOps.FirstCtxSe[SymbolOps.own, fieldCtx];
ros: STREAM ¬ IO.ROS[];
oldDepth: NAT ¬ depth;
i: NAT ¬ 0;
During the first pass we ensure that all of the component types make sense to generate code for. If anything is to weird, then we bail out.
FOR eachSei: Symbols.ISEIndex
¬ firstSei, SymbolOps.NextSe[SymbolOps.own, eachSei]
WHILE eachSei # Symbols.ISENull
DO
ese: Symbols.ISEPointer = @seb[eachSei];
eSei: Symbols.Type = ese.idType;
bits: CARD = SymbolOps.DecodeBitAddr[ese.idInfo];
IF bits
MOD bitsPerWord # 0
THEN
GO
TO bailOut;
We can't ensure that C will understand
SELECT
TRUE
FROM
ese.constant => GO TO bailOut;
ese.linkSpace => GO TO bailOut;
ENDCASE => [] ¬ inner[eSei];
ENDLOOP;
IO.PutRope[ros, "struct "];
IO.PutRope[ros, "{"];
depth ¬ depth + depthIncr;
newLine[ros];
FOR eachSei: Symbols.ISEIndex
¬ firstSei, SymbolOps.NextSe[SymbolOps.own, eachSei]
WHILE eachSei # Symbols.ISENull
DO
ese: Symbols.ISEPointer = @seb[eachSei];
typeSei: Symbols.Type = ese.idType;
eUnder: Symbols.CSEIndex =
SymbolOps.UnderType[SymbolOps.own, typeSei];
subDefn: ROPE ¬ NIL;
subName: ROPE ¬ RopeForName[ese.hash];
addr: CARD = SymbolOps.DecodeBitAddr[ese.idValue];
bits: CARD = SymbolOps.DecodeBitAddr[ese.idInfo];
At this point we should have a valid record field for declarations
IO.PutRope[ros, inner[typeSei]];
IO.PutRope[ros, " "];
IF subName =
NIL
THEN {
No name, so invent one unique to this structure
IO.PutF1[ros, "𡤎mpty←%g", [integer[i]]];
i ¬ i + 1;
}
ELSE IO.PutRope[ros, subName];
IF Rope.Equal[inner[eUnder], "CHAR"]
THEN
Force this to be the right width
IO.PutF1[ros, ": %g", [integer[bits]]];
IO.PutRope[ros, ";"];
newLine[ros];
ENDLOOP;
IO.PutRope[ros, "} "];
IO.PutRope[ros, name];
depth ¬ oldDepth;
defn ¬ IO.RopeFromROS[ros];
};