DIRECTORY Commander, Core, CoreClasses, CoreOps, CoreProperties, RefTab, IO, ProcessProps, RProperties; CorePropertiesImpl: CEDAR PROGRAM IMPORTS CoreOps, RefTab, IO, ProcessProps, ImplementationProperties: RProperties EXPORTS CoreProperties SHARES Core = BEGIN OPEN CoreProperties; CellClass: TYPE = Core.CellClass; CellType: TYPE = Core.CellType; Wire: TYPE = Core.Wire; ROPE: TYPE = Core.ROPE; Properties: TYPE = Core.Properties; propTable: RefTab.Ref _ RefTab.Create[]; GetProp: PUBLIC PROC [from: Properties, prop: ATOM] RETURNS [value: REF ANY _ NIL] = { value _ ImplementationProperties.GetProp[from, prop]; }; PutProp: PUBLIC PROC [on: Properties, prop: ATOM, value: REF ANY _ NIL] RETURNS [new: Properties] = { new _ ImplementationProperties.PutProp[on, prop, value]; }; Enumerate: PUBLIC PROC [props: Properties, consume: PROC [ATOM, REF ANY]] = { FOR pl: Properties _ props, pl.rest WHILE pl # NIL DO consume[NARROW [pl.first.key], pl.first.val]; ENDLOOP; }; PrintProperties: PUBLIC PROC [props: Properties, out: IO.STREAM _ NIL, indent: NAT _ 0, cr: BOOL _ TRUE, level: NAT _ 2] = { PrintIt: PROC [prop: ATOM, val: REF ANY _ NIL] = { PP: PropPrintProc ~ GetPropPrintProc[prop, val]; PP[to: out, prop: prop, val: val, indent: indent, level: level, cr: cr]; }; IF out=NIL THEN out _ NARROW[ProcessProps.GetProp[$CommanderHandle], Commander.Handle].out; Enumerate[props, PrintIt]; }; GetPropPrintProc: PUBLIC PROC [prop: ATOM, val: REF ANY] RETURNS [PropPrintProc] ~ { propprops: Properties ~ FetchProperties[prop]; IF propprops#NIL THEN { pp: REF PropPrintProc ~ NARROW[GetProp[propprops, propPrint]]; IF pp # NIL THEN RETURN [pp^]; }; RETURN [WITH val SELECT FROM x: ATOM => PrintByValue, x: ROPE => PrintByValue, x: LIST OF ROPE => PrintByValue, x: LIST OF REF TEXT => PrintByValue, x: REF TEXT => PrintByValue, x: REF INT => PrintByValue, x: REF REAL => PrintByValue, ENDCASE => PropDontPrint^]; }; PrintByValue: PROC [to: IO.STREAM, prop: ATOM, val: REF ANY, indent, level: NAT, cr: BOOL] --PropPrintProc-- ~ { CoreOps.PrintIndent[indent, to, cr]; IO.PutF[to, "%g: ", IO.atom[prop]]; WITH val SELECT FROM atom: ATOM => IO.PutF[to, "$%g", IO.atom[atom]]; rope: ROPE => IO.PutF[to, "%g", IO.rope[rope]]; refText: REF TEXT => IO.PutF[to, "%g", IO.text[refText]]; lor: LIST OF ROPE => FOR l: LIST OF ROPE _ lor, l.rest UNTIL l=NIL DO IO.PutF[to, "%g ", IO.rope[l.first]]; ENDLOOP; lor: LIST OF REF TEXT => FOR l: LIST OF REF TEXT _ lor, l.rest UNTIL l=NIL DO IO.PutF[to, "%g ", IO.text[l.first]]; ENDLOOP; refInt: REF INT => IO.PutF[to, "%g", IO.int[refInt^]]; refReal: REF REAL => IO.PutF[to, "%g", IO.real[refReal^]]; ENDCASE => ERROR; }; RegisterProperty: PUBLIC PROC [prop: ATOM, properties: Properties _ NIL] RETURNS [sameProp: ATOM] = { [] _ RefTab.Store[propTable, prop, properties]; sameProp _ prop; }; RegisterUnprintableProperty: PUBLIC PROC [prop: ATOM, properties: Properties _ NIL] RETURNS [sameProp: ATOM] ~ { sameProp _ RegisterProperty[prop, PutProp[properties, propPrint, PropDontPrint]]; }; StoreProperties: PUBLIC PROC [prop: ATOM, properties: Properties] = { [] _ RefTab.Store[propTable, prop, properties]; }; FetchProperties: PUBLIC PROC [prop: ATOM] RETURNS [properties: Properties] = { found: BOOL; value: RefTab.Val; [found, value] _ RefTab.Fetch[propTable, prop]; IF NOT found THEN RETURN[NIL]; properties _ NARROW [value, Properties]; }; propPrint: PUBLIC ATOM _ $PropPrint; DontPrint: PropPrintProc = {}; PropDontPrint: PUBLIC REF PropPrintProc _ NEW [PropPrintProc _ DontPrint]; InheritCellTypeProp: PUBLIC PROC [from: CellType, prop: ATOM] RETURNS [value: REF ANY _ NIL] = { DO value _ GetProp[from: from.properties, prop: prop]; IF value=NIL THEN value _ GetProp[from: from.class.properties, prop: prop]; IF value#NIL OR NOT from.class.layersProps THEN EXIT; from _ CoreOps.Recast[from]; ENDLOOP; }; InheritPublicProp: PUBLIC PROC [cellType: CellType, from: Wire, prop: ATOM] RETURNS [value: REF ANY _ NIL] = { table: RefTab.Ref _ NIL; DO value _ GetProp[from: from.properties, prop: prop]; IF value#NIL OR NOT cellType.class.layersProps THEN EXIT; table _ CoreOps.RecastBindingTable[cellType]; IF table=NIL THEN LOOP; from _ NARROW [RefTab.Fetch[table, from].val]; cellType _ CoreOps.Recast[cellType]; ENDLOOP; }; Props: PUBLIC PROC [lit1, lit2, lit3, lit4, lit5, lit6: PropertyLiteral _ []] RETURNS [properties: Properties] = { properties _ PutProp[on: NIL, prop: lit1.key, value: lit1.val]; properties _ PutProp[on: properties, prop: lit2.key, value: lit2.val]; properties _ PutProp[on: properties, prop: lit3.key, value: lit3.val]; properties _ PutProp[on: properties, prop: lit4.key, value: lit4.val]; properties _ PutProp[on: properties, prop: lit5.key, value: lit5.val]; properties _ PutProp[on: properties, prop: lit6.key, value: lit6.val]; }; GetWireProp: PUBLIC PROC [from: Wire, prop: ATOM] RETURNS [value: REF ANY _ NIL] = { value _ GetProp[from: from.properties, prop: prop]; }; PutWireProp: PUBLIC PROC [on: Wire, prop: ATOM, value: REF ANY _ NIL] = { on.properties _ PutProp[on: on.properties, prop: prop, value: value]; }; GetCellClassProp: PUBLIC PROC [from: CellClass, prop: ATOM] RETURNS [value: REF ANY _ NIL] = { value _ GetProp[from: from.properties, prop: prop]; }; PutCellClassProp: PUBLIC PROC [on: CellClass, prop: ATOM, value: REF ANY _ NIL] = { on.properties _ PutProp[on: on.properties, prop: prop, value: value]; }; GetCellTypeProp: PUBLIC PROC [from: CellType, prop: ATOM] RETURNS [value: REF ANY _ NIL] = { value _ GetProp[from: from.properties, prop: prop]; }; PutCellTypeProp: PUBLIC PROC [on: CellType, prop: ATOM, value: REF ANY _ NIL] = { on.properties _ PutProp[on: on.properties, prop: prop, value: value]; }; GetCellInstanceProp: PUBLIC PROC [from: CoreClasses.CellInstance, prop: ATOM] RETURNS [value: REF ANY _ NIL] = { value _ GetProp[from: from.properties, prop: prop]; }; PutCellInstanceProp: PUBLIC PROC [on: CoreClasses.CellInstance, prop: ATOM, value: REF ANY _ NIL] = { on.properties _ PutProp[on: on.properties, prop: prop, value: value]; }; END. θCorePropertiesImpl.mesa Copyright Σ 1985, 1987 by Xerox Corporation. All rights reserved. Bertrand Serlet, March 28, 1987 11:16:05 pm PST Barth, September 24, 1986 9:49:13 am PDT Spreitzer, August 8, 1985 3:12:59 pm PDT Pradeep Sindhu February 7, 1986 5:06:44 pm PST Last Edited by: Louis Monier January 16, 1987 1:13:09 pm PST Mike Spreitzer March 6, 1987 1:51:08 pm PST Global table for putting property properties. Operations Registration Inheritance of Properties Short Cuts Κξ˜codešœ™KšœB™BKšœ/™/Kšœ%Οk™(Kšœ%™(Kšœ+™.Kšœ9™Kšœœœœ˜K˜—šœœœ˜Kšœœ˜Kšœœ˜Kšœœœœ˜ Kš œœœœœ˜$Kšœœœ˜Kšœœœ˜Kšœœœ˜Kšœ˜—K˜K˜—šŸ œœœœœœœœœΟcœ˜pKšœ$˜$Kšœœ ˜#šœœ˜Kšœœœœ ˜1Kšœœœœ ˜0Kš œ œœœœ˜:šœœœœœœœœœœ˜FKšœœ˜%Kšœ˜—šœœœœœœœœœœœœ˜MKšœœ˜%Kšœ˜—Kš œœœœœ˜6Kš œ œœœœ˜:Kšœœ˜—K˜K˜——™ šŸœœœœœœ œ˜eKšœ0˜0Kšœ˜Kšœ˜J˜—šŸœœœœœœ œ˜pKšœQ˜QK˜K˜—šŸœœœœ˜EKšœ0˜0K˜K˜—š Ÿœœœœœ˜NKšœœ˜Kšœ/˜/Kš œœœœœ˜Kšœ œ˜(K˜K˜—Kšœ œœ˜$K˜Kšž œ˜Kšž œœœœ˜JK˜—™šŸœœœœœ œœœ˜`š˜Kšœ3˜3Jšœœœ:˜KKš œœœœœœ˜5Kšœ˜Jšœ˜—K˜K™—šŸœœœ(œœ œœœ˜nKšœœ˜š˜Kšœ3˜3Kš œœœœœœ˜9Kšœ-˜-Kšœœœœ˜Kšœœ!˜.Kšœ$˜$Jšœ˜—K˜K˜——™ šŸœœœ<œ˜rKšœœ#˜?KšœF˜FKšœF˜FKšœF˜FKšœF˜FKšœF˜FKšœ˜K˜—šŸ œœœœœ œœœ˜TKšœ4˜4Kšœ˜J˜—šŸ œœœœ œœœ˜IKšœF˜FKšœ˜J˜—šŸœœœœœ œœœ˜^Kšœ4˜4Kšœ˜J˜—šŸœœœœ œœœ˜SKšœF˜FKšœ˜J˜—šŸœœœœœ œœœ˜\Kšœ4˜4Kšœ˜J˜—šŸœœœœ œœœ˜QKšœF˜FKšœ˜J˜—šŸœœœ(œœ œœœ˜pKšœ4˜4Kšœ˜J˜—šŸœœœ&œ œœœ˜eKšœF˜FKšœ˜J˜——šœ˜K˜K˜——…—Θ"ž