#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Thu, 03 Nov 2016 22:38:29 +0100
changeset 20769 174ac2f6d41d
parent 20768 e4c38b21e74c
child 20770 46d2fd1b00a5
#FEATURE by cg class: ReadEvalPrintLoop changed: #basicReadEvalPrintLoopWithInput:output:error:compiler:prompt:print:
ReadEvalPrintLoop.st
--- a/ReadEvalPrintLoop.st	Thu Nov 03 22:20:19 2016 +0100
+++ b/ReadEvalPrintLoop.st	Thu Nov 03 22:38:29 2016 +0100
@@ -443,101 +443,99 @@
      A '#' character appearing in the first column of the first line turns off chunkmode."
 
     [
-	|lines chunk|
+        |lines chunk|
 
-	prompt notNil ifTrue:[
-	    error nextPutAll:prompt.
-	].
+        prompt notNil ifTrue:[
+            error nextPutAll:prompt.
+        ].
 
-	input atEnd ifTrue:[
-	    error cr.
-	    ^ self.
-	].
+        input atEnd ifTrue:[
+            error cr.
+            ^ self.
+        ].
 
-	input peek == $# ifTrue:[
-	    self doChunkFormat:false.
-	].
+        input peek == $# ifTrue:[
+            self doChunkFormat:false.
+        ].
 
-	self doChunkFormat ifTrue:[
-	    input skipSeparators.
-	    chunk := input nextChunk.
-	] ifFalse:[
-	    lines := OrderedCollection new.
-	    [
-		|line|
+        self doChunkFormat ifTrue:[
+            input skipSeparators.
+            chunk := input nextChunk.
+        ] ifFalse:[
+            lines := OrderedCollection new.
+            [
+                |line|
 
-		line := input nextLine.
-		line notEmptyOrNil ifTrue:[
-		    line = '?' ifTrue:[
-			self cmd_help:nil.
-			prompt notNil ifTrue:[
-			    error nextPutAll:prompt.
-			].
-		    ] ifFalse:[
-			(line startsWith:'#') ifTrue:[
-			    self directive:line.
-			    prompt notNil ifTrue:[
-				error nextPutAll:prompt.
-			    ].
-			] ifFalse:[
-			    lines add:line.
-			]
-		    ]
-		].
-		line notEmptyOrNil and:[(line endsWith:$.) not].
-	    ] whileTrue.
-	    chunk := lines asStringWith:Character cr.
-	].
+                line := input nextLine.
+                line notEmptyOrNil ifTrue:[
+                    line = '?' ifTrue:[
+                        self cmd_help:nil.
+                        prompt notNil ifTrue:[
+                            error nextPutAll:prompt.
+                        ].
+                    ] ifFalse:[
+                        (line startsWith:'#') ifTrue:[
+                            self directive:line.
+                            prompt notNil ifTrue:[
+                                error nextPutAll:prompt.
+                            ].
+                        ] ifFalse:[
+                            lines add:line.
+                        ]
+                    ]
+                ].
+                line notEmptyOrNil and:[(line endsWith:$.) not].
+            ] whileTrue.
+            chunk := lines asStringWith:Character cr.
+        ].
 
-	(chunk notEmptyOrNil and:[chunk withoutSeparators notEmpty]) ifTrue:[
-	    "abortAll is handled, but not asked for here!!"
-	    AbortAllOperationRequest handle:[:ex |
-		error nextPutLine:('Evaluation aborted: ', ex description)
-	    ] do:[
-		(Error, ControlInterrupt) handle:[:ex |
-		    prompt isNil ifTrue:[
-			ex reject
-		    ].
-		    MiniDebugger enterWithMessage:(ex errorString) mayProceed:true.
-		    ex mayProceed ifTrue:[
-			ex proceed.
-		    ].
-		    error nextPutLine:('Evaluation aborted: ', ex description).
-		    ex return.
-		] do:[
-		    |value ms us|
+        (chunk notEmptyOrNil and:[chunk withoutSeparators notEmpty]) ifTrue:[
+            "abortAll is handled, but not asked for here!!"
+            AbortAllOperationRequest handle:[:ex |
+                error nextPutLine:('Evaluation aborted: ', ex description)
+            ] do:[
+                (Error, ControlInterrupt) handle:[:ex |
+                    prompt isNil ifTrue:[
+                        ex reject
+                    ].
+                    MiniDebugger enterWithMessage:(ex errorString) mayProceed:true.
+                    ex mayProceed ifTrue:[
+                        ex proceed.
+                    ].
+                    error nextPutLine:('Evaluation aborted: ', ex description).
+                    ex return.
+                ] do:[
+                    |value ms us|
 
-		    ms := Time millisecondsToRun:[
-			us := Time microsecondsToRun:[
-			    value := (compilerClass new
-					requestor:self)
-					evaluate:chunk
-					compile:true.
-			].
-		    ].
-		    doPrint ifTrue:[
-			value printOn:output. output cr.
-		    ].
+                    us := Time microsecondsToRun:[
+                        value := (compilerClass new
+                                    requestor:self)
+                                    evaluate:chunk
+                                    compile:true.
+                    ].
+                    doPrint ifTrue:[
+                        value printOn:output. output cr.
+                    ].
 
-		    timingFlag == true ifTrue:[
-			'execution time: ' printOn:error.
-			ms < 1 ifTrue:[
-			    us < 1 ifTrue:[
-				'too small to measure (<1us)' printOn:error.
-			    ] ifFalse:[
-				us printOn:output. 'us' printOn:error.
-			    ]
-			] ifFalse:[
-			    ms printOn:output. 'ms' printOn:error.
-			].
-			error cr.
-		    ].
-		    Workspace notNil ifTrue:[
-			Workspace workspaceVariableAt:'_$$' put:value.
-		    ].
-		].
-	    ].
-	].
+                    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.
+                    ].
+                ].
+            ].
+        ].
     ] loop.
 
     "