DIRECTORY AMModel USING [Context, RootContext, Section], AMEvents USING [BreakAt, DuplicateBreakpoint], AMTypes USING [TVType, TV], AMViewerOps USING [ReportProc, SectionFromSource, ViewerFromSection], BackStop USING [Call], Commander USING [CommandProc, Register], CommandTool USING [ArgumentVector, Parse], Convert USING [IntFromRope], Interpreter USING [Evaluate], InterpreterOps USING [EvalHead, WorldFromHead], InterpreterToolPrivate USING [Break, BreakObject, nextBI], IO USING [PutF1, PutRope, STREAM], List USING [Assoc, PutAssoc], PrintTV USING [Print, PrintType], ProcessProps USING [GetPropList], Rope USING [Concat, Fetch, IsEmpty, Length, ROPE, Substr], SafeStorage USING [IsCollectorActive, NWordsAllocated], SymTab USING [Create, Ref], UserProfile USING [Boolean], WorldVM USING [LocalWorld, World]; InterpreterCommandsImpl: CEDAR MONITOR IMPORTS AMEvents, AMModel, AMTypes, AMViewerOps, BackStop, Commander, CommandTool, Convert, Interpreter, InterpreterOps, InterpreterToolPrivate, IO, List, PrintTV, ProcessProps, Rope, SafeStorage, SymTab, UserProfile, WorldVM = BEGIN OPEN InterpreterToolPrivate; ROPE: TYPE = Rope.ROPE; EvalCommand: Commander.CommandProc = { head: InterpreterOps.EvalHead = NARROW[List.Assoc[$EvalHead, ProcessProps.GetPropList[]]]; line: ROPE _ cmd.commandLine; context: AMModel.Context; symTab: SymTab.Ref; resultTV: AMTypes.TV; errorRope: ROPE; noResult: BOOL; depth: INT _ 4; width: INT _ 32; printType: BOOL _ FALSE; collections: INT _ SafeStorage.IsCollectorActive[].previousIncarnation; words: INT _ SafeStorage.NWordsAllocated[]; inner: PROC = { IF noResult THEN RETURN; IF printType THEN { cmd.out.PutRope["***Printing Type...\n"]; PrintTV.PrintType[ put: cmd.out, type: AMTypes.TVType[resultTV], depth: depth, width: width, verbose: depth > 4 ]; } ELSE PrintTV.Print[ put: cmd.out, tv: resultTV, depth: depth, width: width, verbose: depth > 4 ]; }; TRUSTED{ IF head = NIL THEN context _ AMModel.RootContext[WorldVM.LocalWorld[]] ELSE { context _ head.context; IF context = NIL THEN context _ AMModel.RootContext[InterpreterOps.WorldFromHead[head]]; }; symTab _ LOOPHOLE[List.Assoc[$SymTab, cmd.propertyList]]; IF symTab = NIL THEN { symTab _ SymTab.Create[]; [] _ List.PutAssoc[key: $SymTab, val: symTab, aList: cmd.propertyList]; }; }; line _ Rope.Substr[base: line, len: line.Length[] - 1]; -- remove the CR UNTIL line.IsEmpty[] -- strip postfix !'s and ?'s DO ch: CHAR _ line.Fetch[line.Length[] - 1]; SELECT ch FROM '! => {depth _ depth + 1; width _ width + width}; '? => printType _ TRUE; ENDCASE => EXIT; line _ Rope.Substr[base: line, len: line.Length[] - 1]; ENDLOOP; line _ line.Concat["\n"]; -- replace the CR [resultTV, errorRope, noResult] _ Interpreter.Evaluate[rope: Rope.Concat["& _ ", line], context: context, symTab: symTab]; IF errorRope # NIL THEN IO.PutF1[cmd.out, "Error: %g\n", [rope[errorRope]] ] ELSE IO.PutF1[cmd.out, "%g\n", [rope[BackStop.Call[inner]]] ] }; SetBreakCommand: Commander.CommandProc = { out: IO.STREAM = cmd.out; world: WorldVM.World; break: Break _ NIL; argv: CommandTool.ArgumentVector _ CommandTool.Parse[cmd]; HighlightBreakPoint: PROC [break: Break] = { report: AMViewerOps.ReportProc = -- [msg: ROPE, severity: Severity] TRUSTED {out.PutRope[msg]}; inner: SAFE PROC = TRUSTED{ [] _ AMViewerOps.ViewerFromSection[break.section, report]; }; -- yekk. msg: ROPE _ BackStop.Call[inner]; IF msg # NIL THEN out.PutRope[msg]; }; inner: SAFE PROC = TRUSTED { section: AMModel.Section _ NIL; warning: REF; name: ROPE _ argv[1]; index: INT _ Convert.IntFromRope[argv[2]]; out.PutRope["Setting break..."]; [section, warning] _ AMViewerOps.SectionFromSource[world, name, index]; IF warning = NIL THEN out.PutRope["(possible source version mismatch)"]; break _ NEW[BreakObject _ [index: 0, breakID: NIL, world: world, section: section]]; break.breakID _ AMEvents.BreakAt[world, section, break ! AMEvents.DuplicateBreakpoint => {break _ NIL; CONTINUE}]; IF break # NIL THEN {break.index _ nextBI; nextBI _ nextBI + 1}; }; TRUSTED{world _ WorldVM.LocalWorld[]}; msg _ BackStop.Call[inner]; IF msg.Length[] = 0 AND break # NIL THEN { IO.PutF1[out, "Break #%g set.\n", [integer[break.index]] ]; HighlightBreakPoint[break: break]; RETURN; }; IF msg.Length[] # 0 THEN {break _ NIL; result _ $Failure} ELSE msg _ "a break is already set here.\n"; }; showStats: BOOL _ UserProfile.Boolean["ShowEvalStatistics", FALSE]; Commander.Register["_", EvalCommand, "a simple evaluation command", NIL, FALSE]; Commander.Register["eval", EvalCommand, "a simple evaluation command", NIL, FALSE]; Commander.Register["SetBreak", SetBreakCommand, "SetBreak fileName charPos"]; END. \InterpreterCommandsImpl.mesa Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. Russ Atkinson, April 15, 1985 2:01:27 pm PST Paul Rovner, January 11, 1984 1:09 pm Commands registered with Commander START EvalCommand HERE Unify this some day with the stuff in InterpreterToolImpl START SetBreakCommand HERE initialization code Κ– "cedar" style˜codešΟiœ™Kšœ Οmœ7™BK™,Kšœ%™%—K˜šΟk ˜ KšœŸœ!˜.Kšœ Ÿœ ˜.KšœŸœ Ÿœ˜Kšœ Ÿœ4˜EKšœ Ÿœ˜Kšœ Ÿœ˜(Kšœ Ÿœ˜*KšœŸœ˜Kšœ Ÿœ ˜KšœŸœ˜/KšœŸœ˜:KšŸœŸœŸœ˜"KšœŸœ˜KšœŸœ˜!Kšœ Ÿœ˜!KšœŸœ"Ÿœ ˜:Kšœ Ÿœ&˜7KšœŸœ˜Kšœ Ÿœ ˜KšœŸœ˜"K˜—šœŸ ˜&KšŸœ>ŸœKŸœN˜αKšœŸ œŸ˜$K˜KšŸœŸœŸœ˜K˜—Kšœ"™"K˜šΟb œ˜&Kšœ Ÿœ4˜ZKšœŸœ˜Kšœ˜Kšœ˜KšœŸœ˜Kšœ Ÿœ˜Kšœ Ÿœ˜KšœŸœ˜KšœŸœ˜Kšœ ŸœŸœ˜Kšœ Ÿœ7˜GKšœŸœ!˜+šœŸœ˜KšŸœ ŸœŸœ˜šŸœ ˜ šŸœ˜Kšœ)˜)šœ˜Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜—Kšœ˜—šŸœ˜Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜——Kšœ˜—Kšœ™šŸœ˜šŸœŸ˜ KšŸœ4˜8šŸœ˜Kšœ˜šŸœ Ÿ˜KšŸœC˜G—Kšœ˜——Kšœ Ÿœ(˜9šŸœ ŸœŸœ˜Kšœ˜KšœG˜GKšœ˜—Kšœ˜—Kšœ9Οc˜IšŸœ‘˜2šŸ˜KšœŸœ!˜)šŸœŸ˜Kšœ1˜1KšœŸœ˜KšŸœŸœ˜—Kšœ7˜7—KšŸœ˜—Kšœ‘˜,K˜šœ˜KšœZ˜Z—K˜šŸœ Ÿ˜KšŸœŸœ2˜9KšŸœŸœ6˜=—K˜Kšœ˜K˜—š œ˜*K™9KšœŸ œ ˜Kšœ˜KšœŸœ˜Kšœ:˜:šΟnœŸœ˜,šœ"‘"˜DKšŸœ˜—šœŸœŸœŸœ˜Kšœ:˜:Kšœ‘˜ —KšœŸœ˜!KšŸœŸœŸœ˜#K˜—š œŸœŸœŸœ˜KšœŸœ˜Kšœ Ÿœ˜ KšœŸœ ˜KšœŸœ ˜*Kšœ ˜ KšœG˜GKšŸœ ŸœŸœ3˜HKšœŸœ#Ÿœ#˜Tšœ6˜6Kšœ+ŸœŸœ˜;—KšŸœ ŸœŸœ-˜@Kšœ˜—K˜Kšœ™KšŸœ˜&Kšœ˜šŸœŸœ Ÿœ˜*KšŸœ9˜;Kšœ"˜"KšŸœ˜Kšœ˜—šŸœ˜KšŸœ Ÿœ˜%KšŸœ(˜,—Kšœ˜K˜—šœ™Kšœ Ÿœ-Ÿœ˜CKšœDŸœŸœ˜PKšœGŸœŸœ˜SKšœM˜MK˜—šŸœ˜K˜——…—4‘