# HG changeset patch # User Claus Gittinger # Date 1525674648 -7200 # Node ID 9c5bf178961649c4b46f983e480c9aa555cfc4c7 # Parent 62881b8bd163743152339dc3034be174d2a98883 #UI_ENHANCEMENT by cg class: ReadEvalPrintLoop changed: #basicReadEvalPrintLoopWithInput:output:error:compiler:prompt:print: #cmd_help: #cmd_setOrClear:to: #cmd_show: diff -r 62881b8bd163 -r 9c5bf1789616 ReadEvalPrintLoop.st --- a/ReadEvalPrintLoop.st Mon May 07 08:17:02 2018 +0200 +++ b/ReadEvalPrintLoop.st Mon May 07 08:30:48 2018 +0200 @@ -556,14 +556,14 @@ packages ........... available packages to load all ................ all of the above #set/clear ... set or clear a flag + print .............. print return values + nodebug ............ no debugger on error + confirmdebug ....... ask for debugger on error trace .............. tracing execution timing ............. timing execution profiling .......... show execution profile chunkFormat ........ traditional bang chunk format input mode editor ............. command used with #edit directive - nodebug ............ no debugger on error - confirmdebugger .... ask for debugger on error - print .............. print return values #debug ................. enter a MiniDebugger #edit ........ open an external editor class .............. on a class @@ -741,7 +741,7 @@ ]. self errorStream showCR:'? usage: set/clear '; - showCR:'? ( must be one of: trace, times, profile, chunk, editor, nodebug, confirmdebug, print)'. + showCR:'? ( must be one of: print, nodebug, confirmdebug, trace, times, profile, chunk, editor)'. self cmd_show:('flags' readStream). "Modified: / 08-11-2016 / 22:49:17 / cg" @@ -809,14 +809,15 @@ (showAll or:[ what startsWith:'flag' ]) ifTrue:[ errStream cr; showCR:'Flags:'; showCR:'------'. errStream + showCR:('print: ',self printFlag printString); + showCR:('nodebug: ',self noDebugger printString); + showCR:('confirmdebug:',self confirmDebugger printString); showCR:('trace : ',(traceFlag ? false) printString); showCR:('timing: ',(timingFlag ? false) printString); showCR:('profiling: ',(profilingFlag ? false) printString); showCR:('chunkFormat: ',(doChunkFormat ? false) printString); showCR:('editor: ',self editorCommand printString); - showCR:('nodebug: ',self noDebugger printString); - showCR:('confirmdebug:',self confirmDebugger printString); - showCR:('print: ',self printFlag printString). + yourself. ok := true. ]. ]. @@ -1075,9 +1076,11 @@ ) ifTrue:[ "abortAll is handled, but not asked for here!!" AbortAllOperationRequest handle:[:ex | + ObjectMemory sendTraceOff. error nextPutLine:('Evaluation aborted.') ] do:[ (Error, ControlInterrupt) handle:[:ex | + ObjectMemory sendTraceOff. prompt isNil ifTrue:[ ex reject ]. @@ -1099,45 +1102,57 @@ ]. ex return. ] do:[ - |value ms us| + |value ms us mthd codeBlock| + + traceFlag == true ifTrue:[ + mthd := Compiler + compile:('[',chunk,']') forClass:nil + inCategory:'doit' notifying:self + install:false. - profilingFlag == true ifTrue:[ - MessageTally spyDetailedOn:[ - value := (compilerClass new requestor:self) - evaluate:chunk - compile:true. - ]. - (doPrint and:[self printFlag]) ifTrue:[ + mthd isMethod ifTrue:[ + codeBlock := mthd valueWithReceiver:nil arguments:nil. + [ + ObjectMemory sendTraceOn. + codeBlock value. + ] ensure:[ + ObjectMemory sendTraceOff. + ] + ]. + ] ifFalse:[ + profilingFlag == true ifTrue:[ + MessageTally spyDetailedOn:[ + value := (compilerClass new requestor:self) + evaluate:chunk + compile:true. + ]. + ] ifFalse:[ + us := Time microsecondsToRun:[ + value := (compilerClass new requestor:self) + evaluate:chunk compile:true. + ]. + + timingFlag == true ifTrue:[ + 'execution time: ' printOn:error. + us < 1000 ifTrue:[ + us < 1 ifTrue:[ + 'too small to measure (<1us)' printOn:error. + ] ifFalse:[ + us printOn:output. 'us' printOn:error. + ] + ] ifFalse:[ + ((us / 1000) asFixedPoint:2) printOn:output. 'ms' printOn:error. + ]. + error cr. + ]. + ]. + ]. + (doPrint and:[self printFlag]) ifTrue:[ + value isVoid ifFalse:[ '-> (Return value): ' print. value displayString printOn:output. output cr. output flush. ]. - ] ifFalse:[ - us := Time microsecondsToRun:[ - value := (compilerClass new requestor:self) - evaluate:chunk compile:true. - ]. - (doPrint and:[self printFlag]) ifTrue:[ - value isVoid ifFalse:[ - '-> (Return value): ' print. - value displayString printOn:output. output cr. - output flush. - ]. - ]. - - timingFlag == true ifTrue:[ - 'execution time: ' printOn:error. - us < 1000 ifTrue:[ - us < 1 ifTrue:[ - 'too small to measure (<1us)' printOn:error. - ] ifFalse:[ - us printOn:output. 'us' printOn:error. - ] - ] ifFalse:[ - ((us / 1000) asFixedPoint:2) printOn:output. 'ms' printOn:error. - ]. - error cr. - ]. ]. Workspace notNil ifTrue:[ Workspace rememberResultAsWorkspaceVariable:value.