DIRECTORY Core, CoreOps, CoreProperties, CoreRecord, CoreSequence, IO; CoreSequenceImpl: CEDAR PROGRAM IMPORTS CoreOps, CoreProperties, CoreRecord, IO EXPORTS CoreSequence = BEGIN OPEN Core, CoreSequence; sequenceCellClass: PUBLIC CellClass _ NEW[CellClassRec _ [name: "Sequence", recast: Recast, write: Write, read: Read, properties: CoreProperties.Props[[CoreOps.printClassProcProp, NEW[CoreOps.PrintClassProc _ PropPrintClass]]]]]; Start: PROC = { CoreOps.RegisterCellClass[sequenceCellClass]; }; Write: WriteProc = { }; Read: ReadProc = { }; Recast: RecastProc = { seqCell: SequenceCellType _ NARROW[me.data]; recCell: CoreRecord.RecordCellType _ NEW[CoreRecord.RecordCellTypeRec]; new _ NEW[CellTypeRec _ [ name: me.name, class: CoreRecord.recordCellClass, publicWire: CoreOps.CopyWire[wire: me.publicWire], data: recCell, properties: CoreProperties.CopyProps[propList: me.properties]]]; recCell.internalWire _ NEW[WireRec _ [ structure: sequence]]; recCell.internalWire.elements _ NEW[WireSequenceRec[new.publicWire.elements.size + seqCell.stitches.length]]; FOR w: NAT IN [0..new.publicWire.elements.size) DO recCell.internalWire.elements[w] _ new.publicWire.elements[w]; ENDLOOP; FOR w: NAT IN [new.publicWire.elements.size..recCell.internalWire.elements.size) DO recCell.internalWire.elements[w] _ NEW[WireRec _ [structure: sequence]]; recCell.internalWire.elements[w].elements _ NEW[WireSequenceRec[ seqCell.count]]; ENDLOOP; FOR cell: NAT IN [0..seqCell.count) DO newWire: Wire _ NEW[WireRec _ new.publicWire^]; newWire.elements _ NEW[WireSequenceRec[new.publicWire.elements.size] _ new.publicWire.elements^]; FOR seqWire:NAT IN [0..seqCell.length) DO newWire.elements[seqCell.sequence[seqWire]] _ newWire.elements[seqCell.sequence[seqWire]].elements[cell]; ENDLOOP; FOR stitchWire: NAT IN [0..seqCell.stitches.length) DO internal: Wire; IF cell < seqCell.count -1 THEN { internal _ CoreOps.CopyWire[wire: seqCell.base.publicWire.elements[seqCell.stitches[stitchWire].source]]; recCell.internalWire.elements[stitchWire + new.publicWire.elements.size].elements[cell] _ internal; newWire.elements[seqCell.stitches[stitchWire].source] _ internal; }; IF cell > 0 THEN newWire.elements[seqCell.stitches[stitchWire].sink] _ recCell.internalWire.elements[stitchWire + new.publicWire.elements.size].elements[cell-1]; ENDLOOP; recCell.instances _ CONS[NEW[CoreRecord.CellInstanceRec _ [ name: IF seqCell.base.name=NIL THEN NIL ELSE IO.PutFR["%g%g", IO.rope[seqCell.base.name], IO.int[cell]], actualWire: newWire, type: seqCell.base]], recCell.instances]; ENDLOOP; }; Create: PUBLIC PROC [design: Design, name: ROPE _ NIL, args: SequenceCellType] RETURNS [cellType: CellType] = { cellType _ NEW[CellTypeRec _ [ name: name, class: sequenceCellClass, publicWire: CoreOps.CopyWire[wire: args.base.publicWire], data: args]]; FOR i:NAT IN [0..args.length) DO wire: Wire _ cellType.publicWire.elements[args.sequence[i]]; IF wire.structure=sequence THEN { newSeqLength: NAT _ args.count * wire.elements.size; newSeq: WireSequence _ NEW[WireSequenceRec[newSeqLength]]; base: Wire _ wire.elements[0]; FOR i: NAT IN [0..newSeqLength) DO newSeq[i] _ CoreOps.CopyWire[wire: base]; ENDLOOP; cellType.publicWire.elements[args.sequence[i]].elements _ newSeq; } ELSE { newWire: Wire _ NEW[WireRec _ [ name: wire.name, structure: sequence, elements: NEW[WireSequenceRec[args.count]]]]; FOR i: NAT IN [0..args.count) DO wire.elements[i] _ CoreOps.CopyWire[wire: wire]; ENDLOOP; cellType.publicWire.elements[args.sequence[i]] _ newWire; }; ENDLOOP; }; PropPrintClass: CoreOps.PrintClassProc = {Print[NARROW[data], out]}; Print: PUBLIC PROC [cell: SequenceCellType, out: IO.STREAM] = { IO.PutF[out, "\n\nBase cell type: %g", IO.rope[cell.base.name]]; IO.PutF[out, ", count: %g", IO.int[cell.count]]; IO.PutRope[out, "\nstitch wires:"]; IF cell.stitches#NIL THEN FOR stitch: NAT IN [0..cell.stitches.length) DO IO.PutF[out, " (%g, %g)", IO.rope[cell.base.publicWire.elements[cell.stitches[stitch].source].name], IO.rope[cell.base.publicWire.elements[cell.stitches[stitch].sink].name]]; ENDLOOP; IO.PutRope[out, "\nsequence wires:"]; FOR seq: NAT IN [0..cell.length) DO IO.PutF[out, " %g", IO.rope[cell.base.publicWire.elements[cell[seq]].name]]; ENDLOOP; }; Start[]; END. ÞCoreSequenceImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Barth, September 30, 1985 4:03:07 pm PDT Spreitzer, August 12, 1985 5:22:30 pm PDT Bertrand Serlet October 2, 1985 12:28:42 pm PDT ÊÌ– "cedar" style˜codešœ™Kšœ Ïmœ1™˜>Kšžœ˜—šžœžœžœDž˜SKšœ#žœ"˜HKšœ,žœ"˜QKšžœ˜—šžœžœžœž˜&Jšœžœ˜/JšœžœK˜ašžœ žœžœž˜)Kšœi˜iKšžœ˜—šžœ žœžœž˜6Kšœ˜šžœžœ˜!Kšœi˜iKšœc˜cKšœA˜AK˜—Kšžœ žœ‘˜¡Kšžœ˜—šœžœžœ˜;Kšœžœžœžœžœžœžœžœžœ ˜hKšœ˜Kšœ˜Kšœ˜—Kšžœ˜—Kšœ˜K˜—š Ÿœžœžœžœžœžœ˜ošœ žœ˜Kšœ ˜ Kšœ˜Kšœ9˜9Kšœ ˜ —šžœžœžœž˜ Kšœ<˜<šžœžœ˜!Kšœžœ#˜4Kšœžœ ˜:K˜šžœžœžœž˜"Kšœ)˜)Kšžœ˜—KšœA˜AKšœ˜—šžœ˜šœžœ ˜Kšœ˜Kšœ˜Kšœ žœ ˜-—šžœžœžœž˜ Kšœ0˜0Kšžœ˜—Kšœ9˜9K˜—Kšžœ˜—Kšœ˜K˜—JšÏbœ"žœ˜DK˜š Ÿœžœžœžœžœ˜?Kšžœ%žœ˜@Kšžœžœ˜0Kšžœ!˜#š žœžœžœžœ žœžœž˜IKšžœžœIžœG˜®Kšžœ˜—Kšžœ#˜%šžœžœžœž˜#Kšžœžœ6˜LKšžœ˜—Kšœ˜K˜—Kšœ˜K˜Kšžœ˜K˜—…—¬V