DIRECTORY BasicTime, CD, CDDesignCache, CDEnvironment, CDIO, CDOps, CDPrivate, CDProperties, CDValue, FileNames, FS, IO, RefTab, Rope, SymTab, TerminalIO, TokenIO, UserProfile; CDDesignCacheImpl: CEDAR PROGRAM IMPORTS CD, CDEnvironment, CDIO, CDOps, CDPrivate, CDProperties, CDValue, FileNames, FS, IO, RefTab, Rope, SymTab, TerminalIO, UserProfile EXPORTS CDDesignCache = BEGIN GetSymTab: PROC [for: CD.Design] RETURNS [SymTab.Ref] = { x: REF ~ CDValue.Fetch[for, $CDDesignCachePrivate]; WITH x SELECT FROM t: SymTab.Ref => RETURN [t]; ENDCASE => IF x=NIL THEN [] _ CDValue.StoreConditional[for, $CDDesignCachePrivate, SymTab.Create[5]] ELSE [] _ CDValue.Store[for, $CDDesignCachePrivate, SymTab.Create[5]]; RETURN [GetSymTab[for]] }; Set: PUBLIC PROC [for: CD.Design, remote: CD.Design] = { tab: SymTab.Ref ~ GetSymTab[for]; IF for.technology#remote.technology OR for=remote THEN ERROR CD.Error[calling]; IF remote.mutability#readonly THEN ERROR CD.Error[designMutability]; [] _ SymTab.Store[tab, remote.name, remote]; }; Fetch: PUBLIC PROC [for: CD.Design, remoteName: Rope.ROPE] RETURNS [remote: CD.Design _ NIL] = { tab: SymTab.Ref ~ GetSymTab[for]; WITH SymTab.Fetch[tab, remoteName].val SELECT FROM d: CD.Design => IF d.mutability=readonly THEN RETURN [d]; ENDCASE => NULL; }; IsCached: PUBLIC PROC [for: CD.Design, remoteName: Rope.ROPE] RETURNS [BOOL] = { RETURN [Fetch[for, remoteName]#NIL] }; Forget: PUBLIC PROC [for: CD.Design, remoteName: Rope.ROPE] = { tab: SymTab.Ref ~ GetSymTab[for]; [] _ SymTab.Delete[tab, remoteName] }; CameFile: PROC [d: CD.Design] RETURNS [Rope.ROPE_NIL] = { IF d#NIL THEN WITH CDValue.Fetch[d, $CDxCachedFile, design] SELECT FROM r: Rope.ROPE => RETURN [r]; ENDCASE => NULL; }; CameTime: PROC [d: CD.Design] RETURNS [BasicTime.GMT_BasicTime.nullGMT] = { IF d#NIL THEN WITH CDValue.Fetch[d, $CDxCachedCreated, design] SELECT FROM t: REF INT => RETURN [LOOPHOLE[t^, BasicTime.GMT]]; ENDCASE => NULL; }; Search: PUBLIC PROC [remoteName: Rope.ROPE, fileName: Rope.ROPE_NIL, createdTime: BasicTime.GMT _ BasicTime.nullGMT, check: CDDesignCache.CheckProc_NIL, data: REF_NIL] RETURNS [found: CD.Design_NIL] = { Check: PROC [d: CD.Design] RETURNS [ok: BOOL_FALSE] = { IF d#NIL AND d.mutability=readonly THEN IF fileName=NIL OR Rope.Equal[CameFile[d], fileName, FALSE] THEN IF createdTime=BasicTime.nullGMT OR CameTime[d]=createdTime THEN IF check=NIL OR check[d, data] THEN { ok _ TRUE; found _ d; }; }; EachDesign: CDPrivate.DesignEnumerator = { cache: CD.Design; IF ~RefTab.Insert[seen, design, NIL] THEN RETURN; IF design.mutability=readonly AND Rope.Equal[design.name, remoteName] THEN { IF Check[design].ok THEN RETURN [quit_TRUE]; RETURN; }; cache _ Fetch[for: design, remoteName: remoteName]; IF cache#NIL AND RefTab.Insert[seen, cache, NIL] THEN IF Check[cache].ok THEN RETURN [quit_TRUE]; }; seen: RefTab.Ref _ RefTab.Create[5]; IF fileName#NIL THEN fileName _ FileNames.ConvertToSlashFormat[fileName]; [] _ CDPrivate.EnumDesigns[EachDesign]; }; GetOrRead: PUBLIC PROC [for: CD.Design, remoteName: Rope.ROPE, remoteFile: Rope.ROPE _ NIL, reload: BOOL _ FALSE, checkFile: BOOL _ TRUE, check: CDDesignCache.CheckProc_NIL, data: REF_NIL] RETURNS [remote: CD.Design_NIL, different: BOOL_FALSE] = { remote _ Fetch[for, remoteName]; IF remote=NIL OR reload THEN { d: CD.Design _ DoLoad[for, remoteName, remoteFile, checkFile, check, data]; IF different _ (d#NIL AND remote#d) THEN Set[for, remote_d]; }; }; DoLoad: PROC [for: CD.Design, remoteName: Rope.ROPE, fileName: Rope.ROPE_NIL, checkFile: BOOL, check: CDDesignCache.CheckProc, data: REF] RETURNS [design: CD.Design_NIL] = { IOCheck: PROC [h: TokenIO.Handle] RETURNS [ok: BOOL] = { design: CD.Design _ CDIO.DesignInReadOperation[h]; IF design.technology#for.technology THEN { TerminalIO.PutF["**technology missmatch: remote design is %g", IO.rope[design.technology.name] ]; RETURN [FALSE] }; ok _ Rope.Equal[remoteName, design.name]; IF ~ok THEN TerminalIO.PutF["file %g has different design: %g\n", IO.rope[fileName], IO.rope[CD.DesignName[design]] ]; }; SearchCheck: CDDesignCache.CheckProc = { ok _ design.technology=for.technology; IF ok AND check#NIL THEN ok _ check[design, data]; }; foundFile: Rope.ROPE _ NIL; x: REF; time: BasicTime.GMT _ BasicTime.nullGMT; TerminalIO.PutRopes["load remote design ", remoteName, "\n"]; IF Rope.IsEmpty[fileName] THEN fileName _ MakeUpFile[for, remoteName]; IF checkFile THEN { foundFile _ CDEnvironment.FindFile[fileName, ".dale", for]; IF Rope.IsEmpty[foundFile] THEN { TerminalIO.PutRopes[" not done; file ", fileName, " not found\n"]; RETURN }; time _ FS.FileInfo[name: foundFile, remoteCheck: FALSE ! FS.Error => CONTINUE].created; }; design _ Search[remoteName, foundFile, time, SearchCheck, data]; IF design#NIL THEN RETURN [design]; IF foundFile#NIL THEN fileName _ foundFile; design _ CDIO.ReadDesign[fileName, IOCheck]; IF design#NIL THEN { CDOps.SetMutability[design, readonly]; x _ CDValue.Fetch[design, $CDxFromFile, design]; CDValue.Store[design, $CDxCachedFile, x]; x _ CDValue.Fetch[design, $CDxFileCreated, design]; CDValue.Store[design, $CDxCachedCreated, x]; TerminalIO.PutRopes[" ", remoteName, " loaded\n"]; }; }; MakeUpFile: PUBLIC PROC [for: CD.Design, remoteName: Rope.ROPE] RETURNS [fileName: Rope.ROPE_NIL] = { GetHintList: PROC [for: CD.Design] RETURNS [LIST OF Rope.ROPE_NIL] = { IF for#NIL THEN WITH CDProperties.GetDesignProp[for, $ImportHints] SELECT FROM rL: LIST OF Rope.ROPE => RETURN [rL]; ENDCASE => NULL; }; RemSpaces: PROC [r: Rope.ROPE] RETURNS [Rope.ROPE_NIL] = { leng: INT _ Rope.Length[r]; start: INT _ 0; WHILE startstart THEN RETURN [Rope.Substr[r, start, leng-start]]; }; rl: LIST OF Rope.ROPE _ GetHintList[for]; key, rest: Rope.ROPE _ NIL; FOR list: LIST OF Rope.ROPE _ rl, list.rest WHILE list#NIL DO [key, rest] _ CDEnvironment.SplitLine[list.first]; IF Rope.Equal[remoteName, key] THEN RETURN [RemSpaces[rest]]; ENDLOOP; fileName _ UserProfile.Token[Rope.Cat["ChipNDale.ImportFor.", remoteName], remoteName]; }; END. μCDDesignCacheImpl.mesa (part of ChipNDale) Copyright c 1987 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, April 9, 1987 12:29:43 pm PDT Last edited by: Christian Jacobi, October 19, 1987 10:49:30 am PDT Κ ˜codešœ*™*Kšœ Οmœ1™Kš œžœžœžœžœ˜%Kšžœžœ˜——K˜—š Ÿ œžœ žœžœžœžœ˜:Kšœžœ˜Kšœžœ˜Kšžœ žœžœžœ˜HKšžœ žœžœžœ˜GKšžœ žœžœ%˜>Kšœ˜—Kšœžœžœžœ˜)Kšœžœžœ˜š žœžœžœžœžœžœž˜=Kšœ2˜2Kšžœžœžœ˜=Kšžœ˜—KšœY˜YKšœ˜—K˜Kšžœ˜K˜K˜—…—$",