LichenHacks.Mesa
Last tweaked by Mike Spreitzer on August 30, 1988 2:53:21 pm PDT
DIRECTORY AMBridge, AbSets, BiRels, Interpreter, InterpreterOps, InterpreterPrivate, LichenDataStructure, List, ProcessProps, Rope, SymTab;
LichenHacks: CEDAR PROGRAM
IMPORTS AMBridge, AbSets, BiRels, InterpreterOps, InterpreterPrivate, LichenDataStructure, List, ProcessProps, SymTab
=
BEGIN OPEN LichenDataStructure;
SymbolsList: TYPE ~ Interpreter.SymbolsList;
OpenDesign: PROC [d: Design] ~ {
syms: SymbolsList ~ GetSyms[];
[] ← syms.first.Store[" design ", TVForRef[d]];
RETURN};
Names: PROC [e: REF ANY] RETURNS [Set] ~ {
d: Design ~ NARROW[GetVal[" design "]];
RETURN d.ENames[e]};
LookupCellType: PROC [name: REF ANY] RETURNS [CellType] ~ {
d: Design ~ NARROW[GetVal[" design "]];
RETURN [NARROW[Lookup[d, name, NIL]]]};
LookupCellTypes: PROC [namePattern: AbSets.RopePattern] RETURNS [Set] ~ {
d: Design ~ NARROW[GetVal[" design "]];
nameSet: Set ~ namePattern.RopesMatching[];
RETURN d.ctName.Image[nameSet, rightToLeft]};
EasyLookup: PROC [name: REF ANY, type: REF ANYNIL] RETURNS [REF ANY] ~ {
ct: CellType ~ NARROW[GetVal[" cell type "]];
RETURN Lookup[ct, name, type]};
EasyLookupP: PROC [name: REF ANY] RETURNS [Port] ~ {
ct: CellType ~ NARROW[GetVal[" cell type "]];
RETURN [NARROW[Lookup[ct, name, $p]]]};
EasyLookupW: PROC [name: REF ANY] RETURNS [Wire] ~ {
ct: CellType ~ NARROW[GetVal[" cell type "]];
RETURN [NARROW[Lookup[ct, name, $w]]]};
EasyLookupI: PROC [name: REF ANY] RETURNS [CellInstance] ~ {
ct: CellType ~ NARROW[GetVal[" cell type "]];
RETURN [NARROW[Lookup[ct, name, $i]]]};
ContextdLookup: PROC [context, name: REF ANY, type: REF ANYNIL] RETURNS [REF ANY] ~ {
RETURN Lookup[context, name, type]};
ContextdLookupI: PROC [context, name: REF ANY] RETURNS [CellInstance] ~ {
RETURN [NARROW[Lookup[context, name, $i]]]};
ContextdLookupW: PROC [context, name: REF ANY] RETURNS [Wire] ~ {
RETURN [NARROW[Lookup[context, name, $w]]]};
ContextdLookupP: PROC [context, name: REF ANY] RETURNS [Port] ~ {
RETURN [NARROW[Lookup[context, name, $p]]]};
SetCellContext: PROC [ct: CellType] ~ {
syms: SymbolsList ~ GetSyms[];
[] ← syms.first.Store[" cell type ", TVForRef[ct]];
RETURN};
FriendlySubcells: PROC [cct: CellType, icts: Set ← nilSet, inames: Set ← nilSet] RETURNS [cis: Set] ~ {
d: Design ~ cct.d;
cis ← cct.CTParts[i];
IF icts#nilSet THEN {
x: Set ~ d.ciType.Image[icts, rightToLeft];
cis ← cis.Intersection[x]};
IF inames#nilSet THEN {
x: Set ~ cct.fullName[i].Image[inames, rightToLeft];
cis ← cis.Intersection[x]};
RETURN};
GetSyms: PROC RETURNS [SymbolsList] ~ {
eh: InterpreterOps.EvalHead ~ NARROW[List.Assoc[$EvalHead, ProcessProps.GetPropList[]]];
RETURN [eh.specials]};
GetVal: PROC [name: ROPE] RETURNS [REF ANY] ~ TRUSTED {
syms: SymbolsList ~ GetSyms[];
tv: AMBridge.TV ~ InterpreterOps.SearchSymbolsList[syms, name].val;
rr: REF REF ANY ~ NARROW[AMBridge.RefFromTV[tv]];
RETURN [rr^]};
TVForRef: PROC [ref: REF ANY] RETURNS [AMBridge.TV] ~ TRUSTED {
RETURN AMBridge.TVForReferent[NEW [REF ANY ← ref], mutable]};
Start: PROC ~ {
globs: SymbolsList ~ InterpreterPrivate.GetGlobalSymbolsList[];
Reg: PROC [name: ROPE, proc: PROC ANY RETURNS ANY, doc: ROPE] ~ TRUSTED {
InterpreterOps.RegisterTV[name, AMBridge.TVForProc[proc], doc, globs];
RETURN};
Reg["&od", OpenDesign, "lichen open design"];
Reg["&ln", Names, "lichen names"];
Reg["&lut", LookupCellType, "lichen lookup cell type"];
Reg["&luts", LookupCellTypes, "lichen lookup cell types"];
Reg["&elu", EasyLookup, "lichen easy lookup"];
Reg["&elup", EasyLookupP, "lichen easy lookup port"];
Reg["&eluw", EasyLookupW, "lichen easy lookup wire"];
Reg["&elui", EasyLookupI, "lichen easy lookup inst"];
Reg["&clu", ContextdLookup, "lichen contextd lookup"];
Reg["&clui", ContextdLookupI, "lichen contextd lookup inst"];
Reg["&cluw", ContextdLookupW, "lichen contextd lookup wire"];
Reg["&clup", ContextdLookupP, "lichen contextd lookup port"];
Reg["&sct", SetCellContext, "lichen set cell type context"];
Reg["&subcells", FriendlySubcells, "lichen subcells"];
RETURN};
Start[];
END.