CoreMapFunctionImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Louis Monier September 18, 1985 5:15:26 pm PDT
Bertrand Serlet October 2, 1985 12:29:48 pm PDT
DIRECTORY Core, CoreMapFunction, CoreOps, CoreProperties, CoreSequence, IO;
CoreMapFunctionImpl:
CEDAR
PROGRAM
IMPORTS CoreOps, CoreProperties, IO
EXPORTS CoreMapFunction =
BEGIN OPEN Core, CoreMapFunction;
mapFnCellClass: PUBLIC CellClass ← NEW[CellClassRec ← [name: "MapFn", recast: Recast, write: Write, read: Read, properties: CoreProperties.Props[[CoreOps.printClassProcProp, NEW[CoreOps.PrintClassProc ← PropPrintClass]]]]];
Start:
PROC = {
CoreOps.RegisterCellClass[mapFnCellClass];
};
Recast: RecastProc = {
};
Create:
PUBLIC
PROC [name:
ROPE ←
NIL, publicWire: Wire, args: MapFnCellType]
RETURNS [cellType: CellType] = {
cellType ←
NEW[CellTypeRec ← [
name: name,
class: mapFnCellClass,
publicWire: publicWire,
data: args]];
FOR i:NAT IN [0..args.length) DO
wire: Wire ← cellType.publicWire.elements[args.sequence[i]];
newWire: Wire ← CoreOps.CreateSequenceWire[name: wire.name, base: wire, count: args.count];
cellType.publicWire.elements[args.sequence[i]] ← newWire;
ENDLOOP;
};
PropPrintClass: CoreOps.PrintClassProc = {Print[NARROW[data], out]};
Print:
PUBLIC
PROC [cell: MapFnCellType, out:
IO.
STREAM] = {
IO.PutF[out, "\n\nBase cell type: %g", IO.rope[cell.cells[0].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.