DIRECTORY FS, IO, SymTab, Rope, IP, IPToolBox, IPTypeDict; IPTypeDictImpl: CEDAR PROGRAM IMPORTS FS, IO, SymTab, IPToolBox EXPORTS IPTypeDict = BEGIN OPEN TB: IPToolBox, IPTypeDict; CreateFailure: PUBLIC ERROR[why: Reason, what: ATOM] = CODE; Create: PUBLIC PROC[file: Rope.ROPE] RETURNS [r: Ref] ={ stream: IO.STREAM _ FS.StreamOpen[file]; r _ NEW[Rep _ [SymTab.Create[]]]; DO ENABLE IO.EndOfStream => EXIT; type: Rope.ROPE _ TB.GetIdRope[stream]; def: REF TypeEntryRep _ GetTypeEntry[stream]; [] _ r.types.Store[type, def]; ENDLOOP; }; --Create-- LookUp: PUBLIC PROC[r: Ref, type: Rope.ROPE] RETURNS [found: BOOL, val: REF TypeEntryRep] ={ aVal: REF; [found, aVal] _ r.types.Fetch[type]; val _ NARROW[aVal]; }; --LookUp-- TypeEntries: PUBLIC PROC[r: Ref, action: EachTypeEntryAction] ={ typeEntryAction: SymTab.EachPairAction ={ RETURN [action[key, NARROW[val]]]};--typeEntryAction [] _ r.types.Pairs[typeEntryAction]; }; --TypeEntries GetTypeEntry: PROC[stream: IO.STREAM] RETURNS [typeEntry:REF TypeEntryRep] ={ TB.EnterBlock[stream]; typeEntry _ NEW[TypeEntryRep]; UNTIL TB.ExitBlock[stream] DO token: ATOM _ TB.GetIdAtom[stream]; SELECT token FROM $origin => typeEntry.origin _ TB.GetIntVector[stream]^; --$origin $shape => typeEntry.shape _ TB.GetShape[stream];--$shape $pins => typeEntry.pins _ GetPins[stream]; --$pins $shapeFn, $restriction => { TB.EnterBlock[stream]; [] _ TB.ExitBlock[stream];}; ENDCASE => ERROR CreateFailure[badToken, token]; ENDLOOP; }; --GetTypeEntry-- GetPins: PROC [stream: IO.STREAM] RETURNS [pins: LIST OF REF IP.PinRep _ NIL] = { getPin: PROC RETURNS [pin: REF IP.PinRep] = { getAuxInfo: PROC RETURNS [REF _ NIL] = { TB.EnterBlock[stream]; [] _ TB.ExitBlock[stream] }; --getAuxInfo getPhysicalPins: PROC RETURNS [physicalPins: LIST OF REF IP.PhysicalPinRep _ NIL] ={ TB.EnterBlock[stream]; UNTIL TB.ExitBlock[stream] DO physicalPins _ CONS[NEW [IP.PhysicalPinRep _ [TB.GetIntVector[stream]^]], physicalPins]; ENDLOOP; }; --getPhysicalPins pin _ NEW[IP.PinRep _ [name: TB.GetIdRope[stream]]]; TB.EnterBlock[stream]; UNTIL TB.ExitBlock[stream] DO token: ATOM _ TB.GetIdAtom[stream]; SELECT token FROM $auxInfo => pin.auxInfo _ getAuxInfo[]; $physicalPins => pin.physicalPins _ getPhysicalPins[]; ENDCASE => ERROR CreateFailure[badToken, token]; ENDLOOP; }; --getPin TB.EnterBlock[stream]; UNTIL TB.ExitBlock[stream] DO pins _ CONS[getPin[], pins]; ENDLOOP; }; --GetPins END. Z--File: IPTypeDictImpl.mesa Last Edited by: CSChow, January 1, 1985 3:21:55 am PST ΚI˜J™J™6J™šΟk ˜ Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜J˜ Jšœ ˜ —J˜J˜šœœœ˜Jšœœœ˜!Jšœœœœ˜:J˜J˜Icodeš œœœœœ˜