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; AllAbout: PROC [cmd: Commander.Handle, subject: ROPE] = { 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]]; 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"]; }; Show: PROC[cmd: Commander.Handle, iD: ROPE, name: ROPE_NIL] = TRUSTED { 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 = { AllAbout[cmd, CommandTool.NextArgument[cmd]]; }; WorldClear: Commander.CommandProc = { NewNames[]; }; ShowCmd: Commander.CommandProc = { Show[cmd, CommandTool.NextArgument[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["AllAbout", AllAboutCmd, "Print Thrush World relating to atom or invented name"]; Commander.Register["Show", ShowCmd, "Show [] sets &v or & to the value of , which is an atom or an invented name"]; Commander.Register["WorldClear", WorldClear, "Forget invented names"]; Commander.Register["VuThrush", ViewCmd, "Program Management variables for Thrush and VoiceUtils"]; }. xTU.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Last modified by D. Swinehart, December 26, 1985 10:20:15 am PST 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 Κi˜šœ™Icodešœ Οmœ1™