DIRECTORY CD, CDDirectory, CDGenerate, CDGenerateBackdoor, CDGenerateImports, CDImports, FileNames, RefTab, Rope, SymTab, TerminalIO; CDGenerateImportsImpl: CEDAR PROGRAM IMPORTS CDDirectory, CDGenerate, CDGenerateBackdoor, CDImports, FileNames, RefTab, Rope, SymTab, TerminalIO EXPORTS CDGenerateImports SHARES CDImports = BEGIN DirectorySelector: CDGenerateBackdoor.SelectorProc = { key _ TerminalIO.RequestRope[" from directory>"]; }; DirectoryIndirector: CDGenerateBackdoor.IGeneratorProc = { IF Rope.IsEmpty[key] THEN key _ TerminalIO.RequestRope["type name >"]; RETURN [CDDirectory.Fetch[design, key].object] }; dummy: CDGenerate.Context _ CDGenerate.Create[]; contextToName: RefTab.Ref _ RefTab.Create[]; nameToContext: SymTab.Ref _ SymTab.Create[]; UnspecSelector: CDGenerateBackdoor.SelectorProc = { key _ TerminalIO.RequestRope[" import [design.object] >"]; }; Selector: CDGenerateBackdoor.SelectorProc = { dName: Rope.ROPE = ImporteeName[context]; key _ TerminalIO.RequestRope[Rope.Cat[label, " import object from ", dName, " >"]]; }; ImportIGenerator: CDGenerateBackdoor.IGeneratorProc = { importeeName: Rope.ROPE _ ImporteeName[realContext]; IF Rope.IsEmpty[importeeName] THEN { TerminalIO.PutRope["**generate with bad importee name\n"]; RETURN }; IF Rope.Equal[importeeName, design.name] THEN { ob _ CDDirectory.Fetch[design, key].object; RETURN }; [] _ CDImports.GetCache[design, importeeName, true]; ob _ CDImports.CreateImportFromCache[design, key, importeeName]; }; UnspecImportIGenerator: CDGenerateBackdoor.IGeneratorProc = { dotIndex: INT; importeeName, objectName: Rope.ROPE _ NIL; name: Rope.ROPE _ FileNames.GetShortName[key]; dotIndex _ Rope.Index[name, 0, "."]; --the first dot! multiple dots belong to the object name IF dotIndex r _ n ENDCASE => { context _ CDGenerateBackdoor.Indiretee[context]; IF context#NIL THEN RETURN[ImporteeName[context]] }; }; GetImportContext: PUBLIC PROC [designName: Rope.ROPE] RETURNS [context: CDGenerate.Context_NIL] = { WITH nameToContext.Fetch[designName].val SELECT FROM t: CDGenerate.Context => RETURN [t] ENDCASE => NULL; context _ CDGenerateBackdoor.CreateIndirect[onTopOf: dummy, iGenerator: ImportIGenerator, selector: Selector, cache: TRUE, flushThrough: FALSE, clearThrough: FALSE, registerThrough: FALSE]; [] _ contextToName.Insert[context, designName]; IF nameToContext.Insert[designName, context] THEN RETURN; RETURN [GetImportContext[designName]] --indirection for concurrency problems }; fromDirectory: CDGenerate.Context _ CDGenerateBackdoor.CreateIndirect[ onTopOf: CDGenerate.Create[], iGenerator: DirectoryIndirector, selector: DirectorySelector ]; unspecImportContext: CDGenerate.Context _ CDGenerateBackdoor.CreateIndirect[ onTopOf: dummy, iGenerator: UnspecImportIGenerator, selector: UnspecSelector ]; [] _ SymTab.Insert[CDGenerateBackdoor.publicContexts, "IMPORT", unspecImportContext]; [] _ SymTab.Insert[CDGenerateBackdoor.publicContexts, "DIRECTORY", fromDirectory]; END.  CDGenerateImportsImpl.mesa (part of ChipNDale) Copyright c 1985, 1987 by Xerox Corporation. All rights reserved. Created by Christian Jacobi, June 5, 1985 8:02:35 pm PDT Last edited by: Christian Jacobi, February 10, 1987 3:22:51 pm PST --directory --imports ΚΒ˜codešœ.™.Kšœ Οmœ7™BKšœ8™8K™B—K˜šΟk œ˜ Kšžœ˜Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ K˜—šΟnœžœž˜$Kšžœd˜kKšžœ˜Kšžœ ˜—Kšž˜K˜KšΟb ™ K™šΠbnœ%˜6Kšœ1˜1Kšœ˜K˜—š‘œ'˜:Kšžœžœ-˜FKšžœ)˜/Kšœ˜—K™Kš  ™ K˜Kšœ0˜0Kšœ,˜,Kšœ,˜,K˜š œ%˜3Kšœ:˜:Kšœ˜K˜—š œ%˜-Kšœ žœ˜)KšœS˜SKšœ˜K˜—š‘œ'˜7Kšœžœ˜4šžœžœ˜$Kšœ:˜:Kšž˜Kšœ˜—šžœ'žœ˜/Kšœ+˜+Kšž˜K˜—Kšœ4˜4Kšœ@˜@Kšœ˜—K˜š œ'˜=Kšœ žœ!žœžœ˜9Kšœ žœ˜.Kšœ&Οc8˜^šžœžœ˜$Kšœ+˜+Kšœ-˜-K˜—šžœžœžœ˜CKšœ=˜=Kšœ8˜8K˜—KšžœJ˜NKšœ˜—K˜š Ÿ œžœžœžœ žœžœ˜Všžœ"žœž˜1Kšœžœ ˜šžœ˜ Kšœ0˜0Kšžœ žœžœžœ˜1Kšœ˜——Kšœ˜—K˜š Ÿœž œžœžœžœ˜cšžœ%žœž˜4Kšœžœ˜#Kšžœžœ˜—šœZ˜ZKš œžœžœžœžœ˜c—Kšœ/˜/Kšžœ+žœžœ˜9Kšžœ ’&˜LKšœ˜—K˜Kšœ¦˜¦šœL˜LKšœ˜Kšœ$˜$Kšœ˜Kšœ˜—KšœU˜UKšœR˜RKšžœ˜K˜—…— Δ’