DIRECTORY BasicTime USING [ Now ], Commander USING [ CommandProc, Handle, Register ], CommandTool USING [ DoCommand, NextArgument ], IO, Nice, RefID USING [ Reseal, Unseal ], RefTab USING [ Create, Fetch, Ref, Store ], Rope USING [ Cat, ROPE ], SafeStorage USING [ NarrowRefFault ], Thrush USING [ Epoch ], ThNet, ThParty USING [ DescribeParty ], ThPartyPrivate USING [ PartyData, SmartsData ], ThSmartsPrivate USING [ SmartsInfo ], Triples USING [ Any, Erase, Foreach, ForeachProc, Item, Make, Select ], TU, VoiceUtils USING [ MakeAtom, pd ] ; TUImpl: CEDAR MONITOR IMPORTS BasicTime, Commander, CommandTool, IO, Nice, RefID, RefTab, Rope, SafeStorage, ThParty, Triples, VoiceUtils EXPORTS Thrush, ThNet, TU = { epoch: PUBLIC Thrush.Epoch; ePoch: Thrush.Epoch; gsI: INT_0; nameToValueTab: RefTab.Ref; valueToNameTab: RefTab.Ref; pd: PUBLIC REF ThNet.PD _ NEW[ThNet.PD_[ debug: FALSE, encryptionRequested: TRUE, encryptVoice: TRUE ]]; ROPE: TYPE = Rope.ROPE; MakeUnique: PUBLIC PROC [att, obj, val: Triples.Item] = { Triples.Erase[att, obj, Triples.Any]; Triples.Make[att, obj, val]; }; Any: Triples.Item = Triples.Any; About: PROC [cmd: Commander.Handle, subject: ROPE, closures: BOOL] = { OPEN IO; o: IO.STREAM = cmd.out; iD: REF _ RefFromRope[subject]; Country: Triples.ForeachProc= { o.PutF["%g[ %g ] = %g\n", RefAddr[trip.att], RefAddr[trip.obj], RefAddr[trip.val]]; IF closures THEN Triples.Foreach[Any, trip.val, Any, Country]; }; Triples.Foreach[iD, Any, Any, Country]; Triples.Foreach[Any, iD, Any, Country]; Triples.Foreach[Any, Any, iD, Country]; o.PutRope["--------------\n\n"]; }; ID: PROC[cmd: Commander.Handle, iD: ROPE] = { OPEN IO; o: IO.STREAM = cmd.out; r: REF _ RefFromRope[iD]; o.PutF["%g\n", card[LOOPHOLE[r, LONG CARDINAL]]]; }; Show: PROC[cmd: Commander.Handle, iD: ROPE, name: ROPE_NIL] = { OPEN IO; []_CommandTool.DoCommand[ IO.PutFR["_ &%g _ TU.RefFromRope[""%g""]", rope[IF name#NIL THEN name ELSE "v"], rope[iD]], cmd]; }; Ref: PUBLIC PROC[iD: ATOM] RETURNS [r: REF] = { OPEN IO; r_nameToValueTab.Fetch[iD].val; IF r=NIL THEN r_iD; -- assume we want to talk about the id itself. }; RefFromRope: PUBLIC PROC[iD: ROPE] RETURNS [REF] = { RETURN[Ref[VoiceUtils.MakeAtom[iD, TRUE]]]; }; RefAddr: PUBLIC PROC[r: REF] RETURNS [IO.Value] = { id: ATOM_NIL; IF r=NIL THEN RETURN[IO.refAny[NIL]]; id _ NARROW[r!SafeStorage.NarrowRefFault => CONTINUE]; IF id=NIL THEN id_NARROW[valueToNameTab.Fetch[r].val]; IF id=NIL THEN { id_Gensym[r, 'R]; []_nameToValueTab.Store[id, r]; []_valueToNameTab.Store[r, id]; }; RETURN [IO.atom[id]]; }; NewNames: PROC = { gsI_0; nameToValueTab _ RefTab.Create[113]; valueToNameTab _ RefTab.Create[113]; }; Gensym: PROC[r: REF, c: CHAR] RETURNS [ATOM] = { OPEN IO; symName: ROPE_WITH r SELECT FROM ref: RefTab.Ref => "abcde", party: ThPartyPrivate.PartyData => Party[party], smarts: ThPartyPrivate.SmartsData => Smarts[smarts], info: ThSmartsPrivate.SmartsInfo => Smarts[NARROW[RefID.Unseal[info.smartsID]], "si"], ENDCASE=>NIL; IF symName=NIL THEN symName_IO.PutFR["%c%02d", char[c], int[gsI_gsI+1]]; RETURN[VoiceUtils.MakeAtom[symName]]; }; Smarts: PROC[smarts:ThPartyPrivate.SmartsData,qual: ROPE_"sm"]RETURNS[name:ROPE_NIL]= { party: ThPartyPrivate.PartyData _ NARROW[Triples.Select[$Smarts, Any, smarts]]; IF party#NIL THEN name_Party[party, qual]; RETURN[name]; }; Party: PROC[party: ThPartyPrivate.PartyData, qual: ROPE_"pt"] RETURNS[name: ROPE_NIL] = { OPEN IO; moreQual: ROPE_"."; SELECT party.type FROM $trunk => { name _ ThParty.DescribeParty[partyID: RefID.Reseal[party], nameReq: $owner].description; moreQual_".k"; }; $service => name _ IO.PutFR["Srv%02d(%g)", int[gsI_gsI+1], rope[party.name]]; ENDCASE => { name_ThParty.DescribeParty[ partyID: RefID.Reseal[party], nameReq: $current].description; IF party.type=$individual THEN qual _ Rope.Cat["i", qual]; }; IF name=NIL THEN RETURN; name_name.Cat[moreQual, qual]; }; AllAboutCmd: Commander.CommandProc = { About[cmd, CommandTool.NextArgument[cmd], TRUE]; }; AboutCmd: Commander.CommandProc = { About[cmd, CommandTool.NextArgument[cmd], FALSE]; }; WorldClear: Commander.CommandProc = { NewNames[]; }; ShowCmd: Commander.CommandProc = { Show[cmd, CommandTool.NextArgument[cmd], CommandTool.NextArgument[cmd]]; }; IDCmd: Commander.CommandProc = { ID[cmd, CommandTool.NextArgument[cmd]]; }; ViewCmd: Commander.CommandProc = { Nice.View[pd, "Thrush-wide PD"]; Nice.View[VoiceUtils.pd, "Log PD"]; }; epoch_BasicTime.Now[]; ePoch _ epoch; NewNames[]; Commander.Register["About", AboutCmd, "Print Triples relating to atom or invented name"]; Commander.Register["AllAbout", AllAboutCmd, "Print Thrush World relating to atom or invented name: About plus transitive closures"]; Commander.Register["Show", ShowCmd, "Show [] sets &v or & to the value of , which is an atom or an invented name"]; Commander.Register["ID", IDCmd, "ID prints the RefID version of ; the RefID version of Show"]; Commander.Register["WorldClear", WorldClear, "Forget invented names"]; Commander.Register["VuThrush", ViewCmd, "Program Management variables for Thrush and VoiceUtils"]; }. >TU.mesa Copyright c 1985, 1986 by Xerox Corporation. All rights reserved. Last modified by D. Swinehart, June 2, 1986 8:57:11 am PDT Obligatory concrete Copies Miscellaneous routines Procedures for debugging only Initialization Debugging nonsense Swinehart, May 16, 1985 9:14:29 am PDT Cedar 6.0 changes to: DIRECTORY (CommandToolExtras => ...Tool), TUImpl, ShowCmd Swinehart, June 2, 1986 8:56:58 am PDT Cedar 6.1, add ID command, About command changes to: About, Country (local of About), ID, Show, AllAboutCmd, AboutCmd, IDCmd, Commander, Commander, Commander Κ ˜šœ™Icodešœ Οmœ7™BJšœ:™:—J˜šΟk ˜ Jšœ žœ ˜Jšœ žœ#˜2Jšœ žœž˜.Jšžœ˜J˜Jšœžœ˜Jšœžœ˜+Jšœžœžœ˜Jšœ žœ˜%Jšœžœ ˜J˜Jšœžœ˜ Jšœžœ˜/Jšœžœ˜%šœžœ˜J˜7—J˜Jšœ žœ˜!J˜J˜—šœžœž˜šž˜J˜ J˜ Jšœ ž˜ Jšžœ˜J˜J˜J˜J˜J˜ J˜J˜J˜ —Jšžœ˜J˜—šœ™J˜Jšœžœ˜J˜J˜Jšœžœ˜ J˜J˜J˜š œžœžœžœžœžœ˜(Jšœžœ˜ Jšœžœ˜Jšœž˜J˜—J˜—šœ™˜Jšžœžœžœ˜J˜——™J™šΟn œžœžœ"˜9J˜%J˜ J˜——šœ™J˜J˜ J˜šŸœžœ"žœ žœ˜FJšžœžœ˜Jšœžœžœ ˜Jšœžœ˜šœ˜JšœS˜SJšžœ žœ.˜>Jšœ˜—Jšœ'˜'Jšœ'˜'Jšœ'˜'J˜#—J˜šŸœžœžœ˜-Jšžœžœ˜Jšœžœžœ ˜Jšœžœ˜Jšœžœžœžœ˜1˜J˜——š Ÿœžœžœžœžœ˜?Jšžœžœ˜šœ˜šžœ(˜*Jš œžœžœžœžœ˜6——˜J˜——š Ÿœž œžœžœžœ˜/Jšžœžœ˜Jšœ˜JšžœžœžœΟc.˜Bšœ˜J˜——š Ÿ œžœžœžœžœžœ˜4Jšžœžœ˜+J˜J˜—š Ÿœžœžœžœžœžœ ˜3Jšœžœžœ˜ Jš žœžœžœžœžœžœ˜%Jšœžœ!žœ˜6Jšžœžœžœ(˜6šžœžœžœ˜Jšœ˜J˜J˜Jšœ˜—Jšžœžœ˜J˜—šŸœžœ˜Jšœ˜Jšœ$˜$Jšœ$˜$Jšœ˜J˜—š Ÿœžœžœžœžœžœ˜0Jšžœžœ˜šœ žœžœžœž˜ J˜J˜0J˜4Jšœ+žœ%˜VJšžœžœ˜ —Jšžœ žœžœ žœ*˜HJšžœ˜%Jšœ˜—J˜šŸœžœ(žœžœžœžœžœ˜WJšœ"žœ'˜OJšžœžœžœ˜*Jšžœ˜ J˜—J˜š Ÿœžœ(žœžœžœžœ˜YJšžœžœ˜Jšœ žœ˜šžœ ž˜šœ ˜ šœ˜JšœQ˜Q—J˜J˜—Jšœžœ8˜Mšžœ˜ šœ˜Jšœ=˜=—Jšžœžœ˜:J˜——Jšžœžœž œ˜Jšœ˜J˜—J˜—™J™šœ&˜&Jšœ*žœ˜0Jšœ˜J˜—šœ#˜#Jšœ*žœ˜1Jšœ˜J˜—šœ%˜%J˜ Jšœ˜J˜—šœ"˜"JšœH˜HJšœ˜J˜—šœ ˜ Jšœ'˜'Jšœ˜J˜—J™šœ"˜"Jšœ ˜ Jšœ#˜#Jšœ˜—J˜Jšœ˜J˜J˜ JšœY˜YJšœ„˜„JšœŒ˜ŒJšœk˜kJšœF˜FJšœb˜bJ˜—J˜J˜™&K™ Kšœ Οr œ‘™E—™&K™(Kšœ ‘œ‘I™t—K™—…—n