author | Stefan Vogel <sv@exept.de> |
Tue, 03 Jul 2018 23:38:44 +0200 | |
changeset 23189 | 15ea23cfead5 |
parent 22903 | d5cefe5e6246 |
child 23509 | f6b24e7b5512 |
permissions | -rw-r--r-- |
22574 | 1 |
"{ Encoding: utf8 }" |
2 |
||
10249 | 3 |
" |
4 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
16565 | 5 |
All Rights Reserved |
10249 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
10248 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
19379 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
10248 | 18 |
Object subclass:#ReadEvalPrintLoop |
22764 | 19 |
instanceVariableNames:'stdin stdout stderr inputStream outputStream errorStream compiler |
20 |
prompt doChunkFormat traceFlag timingFlag profilingFlag printFlag |
|
20935 | 21 |
exitAction currentDirectory lastEditedClass lastEditedSelector |
22746 | 22 |
editorCommand confirmDebugger noDebugger debuggerUsed |
22765 | 23 |
returnValuePrinting returnValuePrompt defaultPackagePrefix |
24 |
answerPrompt' |
|
16228 | 25 |
classVariableNames:'' |
26 |
poolDictionaries:'' |
|
27 |
category:'System-Support' |
|
10248 | 28 |
! |
29 |
||
10249 | 30 |
!ReadEvalPrintLoop class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
16565 | 35 |
All Rights Reserved |
10249 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
10461
0b2935207fec
+correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents:
10277
diff
changeset
|
44 |
! |
0b2935207fec
+correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents:
10277
diff
changeset
|
45 |
|
0b2935207fec
+correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents:
10277
diff
changeset
|
46 |
documentation |
0b2935207fec
+correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents:
10277
diff
changeset
|
47 |
" |
0b2935207fec
+correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents:
10277
diff
changeset
|
48 |
A simple read-eval-print loop for non-GUI or stscript operation. |
22735 | 49 |
Invoked, for example if stx is started with a --repl argument, |
50 |
or by the MiniDebugger with the 'I' command. |
|
20833 | 51 |
|
10628
284266d54dbe
#exit only leaves the rep-loop
Claus Gittinger <cg@exept.de>
parents:
10500
diff
changeset
|
52 |
A line starting with '?' shows the usage message. |
284266d54dbe
#exit only leaves the rep-loop
Claus Gittinger <cg@exept.de>
parents:
10500
diff
changeset
|
53 |
Lines starting with '#' are directives: |
22576 | 54 |
#exit - exit the rep-loop |
55 |
#show ... - show various infos |
|
56 |
#use package - show various infos |
|
20833 | 57 |
type '?' to see more. |
58 |
||
16087 | 59 |
The input can be in one of two formats: |
20833 | 60 |
1) traditional chunk format (bang-separated chunks, bangs duplicated) |
61 |
this is the traditional fileIn format, as generated by fileOut from the browser |
|
16087 | 62 |
|
20833 | 63 |
2) interactive line mode. Chunks are any number of lines up to either an empty line or |
64 |
a line ending in a period. This is more useful for an interactive REPL, where statements/expressions |
|
65 |
are entered linewise by a user. |
|
16087 | 66 |
|
67 |
The input can is switched to non-chunk format whenever a line with a '#' in the first column appears. |
|
20833 | 68 |
|
20933 | 69 |
Try it (but only if you have a console): |
70 |
Smalltalk readEvalPrintLoop |
|
71 |
||
20833 | 72 |
[Author:] |
73 |
Claus Gittinger |
|
10461
0b2935207fec
+correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents:
10277
diff
changeset
|
74 |
" |
10249 | 75 |
! ! |
10248 | 76 |
|
77 |
!ReadEvalPrintLoop methodsFor:'accessing'! |
|
78 |
||
22765 | 79 |
answerPrompt |
80 |
"the string shown before the answer" |
|
81 |
||
82 |
^ answerPrompt ? '-> (Answer): ' |
|
83 |
! |
|
84 |
||
85 |
answerPrompt:aString |
|
86 |
"set the string shown before the answer" |
|
87 |
||
88 |
answerPrompt := aString. |
|
89 |
! |
|
90 |
||
10463 | 91 |
compiler:something |
22765 | 92 |
"assign a compiler to use; |
93 |
can be used to change the language" |
|
16087 | 94 |
|
10463 | 95 |
compiler := something. |
10248 | 96 |
! |
97 |
||
22735 | 98 |
confirmDebugger |
99 |
"true if the user is asked for a debugger in case of errors" |
|
100 |
||
101 |
^ confirmDebugger ? true |
|
102 |
! |
|
103 |
||
104 |
confirmDebugger:aBoolean |
|
105 |
"true if the user is asked for a debugger in case of errors" |
|
106 |
||
107 |
confirmDebugger := aBoolean |
|
108 |
! |
|
109 |
||
110 |
debuggerUsed |
|
111 |
"by default, the miniDebugger is given control in case of an error; |
|
112 |
you may want to write (subclass) your own ;-)" |
|
113 |
||
114 |
^ debuggerUsed ? MiniDebugger |
|
115 |
! |
|
116 |
||
117 |
debuggerUsed:aDebuggerClass |
|
118 |
"by default, the miniDebugger is given control in case of an error; |
|
119 |
you may want to write (subclass) your own ;-)" |
|
120 |
||
121 |
debuggerUsed := aDebuggerClass |
|
122 |
! |
|
123 |
||
22765 | 124 |
defaultPackagePrefix |
125 |
"a default to be prepended to #use packages" |
|
126 |
||
127 |
^ defaultPackagePrefix ? 'stx:' |
|
128 |
! |
|
129 |
||
130 |
defaultPackagePrefix:aStringOrNil |
|
131 |
"a default to be prepended to #use packages" |
|
132 |
||
133 |
defaultPackagePrefix := aStringOrNil |
|
134 |
! |
|
135 |
||
10632 | 136 |
doChunkFormat |
16087 | 137 |
"true if currently reading chunk format" |
138 |
||
10632 | 139 |
^ doChunkFormat ? true |
140 |
||
141 |
"Created: / 07-12-2006 / 18:24:04 / cg" |
|
142 |
! |
|
143 |
||
16087 | 144 |
doChunkFormat:aBoolean |
145 |
"enable/disable chunk format" |
|
146 |
||
147 |
doChunkFormat := aBoolean. |
|
10254 | 148 |
|
149 |
"Created: / 07-12-2006 / 18:24:04 / cg" |
|
10248 | 150 |
! |
151 |
||
20935 | 152 |
editorCommand |
21934 | 153 |
"the editor command to use with the #edit directive. |
154 |
Uses the STX_EDITOR or EDITOR shell variables' value, if defined; |
|
155 |
if not, the value in the classvar EDITORCOMMAND if non-nil; |
|
156 |
otheriwse vi (notepad on windows)" |
|
157 |
||
20935 | 158 |
|editor| |
159 |
||
160 |
(editor := editorCommand) isNil ifTrue:[ |
|
161 |
editor := OperatingSystem getEnvironment:'STX_EDITOR'. |
|
162 |
editor isNil ifTrue:[ |
|
163 |
editor := OperatingSystem getEnvironment:'EDITOR'. |
|
164 |
editor isNil ifTrue:[ |
|
165 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
166 |
editor := 'notepad'. |
|
167 |
] ifFalse:[ |
|
168 |
editor := 'vi'. |
|
169 |
]. |
|
170 |
]. |
|
171 |
]. |
|
172 |
]. |
|
173 |
^ editor |
|
174 |
||
175 |
"Created: / 08-11-2016 / 22:45:22 / cg" |
|
21934 | 176 |
"Modified: / 24-06-2017 / 09:54:10 / cg" |
20935 | 177 |
! |
178 |
||
10463 | 179 |
errorStream |
16087 | 180 |
"return the current error stream" |
181 |
||
19379 | 182 |
errorStream notNil ifTrue:[^ errorStream]. |
183 |
^ Processor activeProcess stderr |
|
10256 | 184 |
|
19379 | 185 |
"Created: / 07-12-2006 / 19:12:27 / cg" |
10256 | 186 |
! |
187 |
||
22832 | 188 |
errorStream:aStream |
189 |
"assign an error stream" |
|
190 |
||
191 |
errorStream := stderr := aStream. |
|
192 |
||
193 |
"Created: / 07-12-2006 / 17:33:39 / cg" |
|
194 |
! |
|
195 |
||
16087 | 196 |
input:aStream |
22832 | 197 |
<resource: #obsolete> |
16087 | 198 |
"assign an input stream" |
199 |
||
22775 | 200 |
inputStream := stdin := aStream asLineNumberReadStream. |
10248 | 201 |
|
202 |
"Modified: / 07-12-2006 / 17:33:31 / cg" |
|
203 |
! |
|
204 |
||
10463 | 205 |
inputStream |
16087 | 206 |
"get the current input stream" |
207 |
||
19379 | 208 |
inputStream notNil ifTrue:[^ inputStream]. |
209 |
^ Processor activeProcess stdin |
|
10463 | 210 |
|
211 |
"Created: / 07-12-2006 / 19:12:13 / cg" |
|
10256 | 212 |
! |
213 |
||
22832 | 214 |
inputStream:aStream |
215 |
"assign an input stream" |
|
216 |
||
217 |
inputStream := stdin := aStream asLineNumberReadStream. |
|
218 |
||
219 |
"Modified: / 07-12-2006 / 17:33:31 / cg" |
|
220 |
! |
|
221 |
||
22746 | 222 |
noDebugger |
223 |
"true if no debugger should be activated on errors (aborts)" |
|
224 |
||
225 |
^ noDebugger ? false |
|
226 |
! |
|
227 |
||
228 |
noDebugger:aBoolean |
|
229 |
"true if no debugger should be activated on errors (aborts)" |
|
230 |
||
231 |
noDebugger := aBoolean |
|
232 |
! |
|
233 |
||
16087 | 234 |
output:aStream |
22832 | 235 |
<resource: #obsolete> |
16087 | 236 |
"assign an output stream" |
237 |
||
22775 | 238 |
outputStream := stdout := aStream. |
10248 | 239 |
|
240 |
"Created: / 07-12-2006 / 17:27:48 / cg" |
|
241 |
! |
|
242 |
||
10463 | 243 |
outputStream |
19379 | 244 |
"return the current output stream" |
16087 | 245 |
|
19379 | 246 |
outputStream notNil ifTrue:[^ outputStream]. |
247 |
^ Processor activeProcess stdout |
|
10463 | 248 |
|
249 |
"Created: / 07-12-2006 / 19:12:27 / cg" |
|
250 |
! |
|
251 |
||
22832 | 252 |
outputStream:aStream |
253 |
"assign an output stream" |
|
254 |
||
255 |
outputStream := stdout := aStream. |
|
256 |
||
257 |
"Created: / 07-12-2006 / 17:27:48 / cg" |
|
258 |
! |
|
259 |
||
22743 | 260 |
printFlag |
261 |
"true if the return value of expressions should be printed" |
|
262 |
||
263 |
^ printFlag ? true |
|
264 |
! |
|
265 |
||
266 |
printFlag:aBoolean |
|
267 |
"true if the return value of expressions should be printed" |
|
268 |
||
269 |
printFlag := aBoolean |
|
270 |
! |
|
271 |
||
16087 | 272 |
prompt:aString |
22765 | 273 |
"set the string shown as prompt" |
16087 | 274 |
|
275 |
prompt := aString. |
|
10248 | 276 |
! ! |
277 |
||
10631 | 278 |
!ReadEvalPrintLoop methodsFor:'compiler interface-error handling'! |
279 |
||
280 |
correctableError:message position:pos1 to:pos2 from:aCompiler |
|
281 |
"compiler notifies us of an error - ignore it" |
|
282 |
||
15702 | 283 |
^ false "/ no correction |
10631 | 284 |
! |
285 |
||
286 |
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler |
|
287 |
"compiler notifies us of a warning - ignore it" |
|
288 |
||
289 |
^ false |
|
290 |
! |
|
291 |
||
13121
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
292 |
correctableWarning:message position:pos1 to:pos2 from:aCompiler |
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
293 |
"compiler notifies us of an error - ignore it" |
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
294 |
|
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
295 |
^ false |
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
296 |
|
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
297 |
"Created: / 02-11-2010 / 13:29:22 / cg" |
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
298 |
! |
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
299 |
|
10631 | 300 |
error:aString position:relPos to:relEndPos from:aCompiler |
301 |
"compiler notifies us of a warning - ignore it" |
|
302 |
||
22761 | 303 |
self error:('Syntax Error: ',aString). |
10631 | 304 |
! |
305 |
||
306 |
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler |
|
307 |
"compiler notifies us of a warning - ignore it" |
|
308 |
||
309 |
^ false |
|
310 |
! |
|
311 |
||
312 |
warning:aString position:relPos to:relEndPos from:aCompiler |
|
313 |
"compiler notifies us of a warning - ignore it" |
|
314 |
||
315 |
^ self |
|
316 |
! ! |
|
317 |
||
10255 | 318 |
!ReadEvalPrintLoop methodsFor:'directives'! |
319 |
||
22735 | 320 |
askYesNo:message |
22771 | 321 |
stderr show:message. |
22735 | 322 |
^ (self inputStream nextLine withoutSeparators startsWith:'y'). |
323 |
! |
|
324 |
||
325 |
cmd_apropos:lineStream |
|
326 |
"apropos directive; i.e. |
|
327 |
#apropos collection [;more] |
|
328 |
" |
|
329 |
||
330 |
|words classNamesMatching selectorsMatching showList| |
|
331 |
||
332 |
lineStream skipSeparators. |
|
333 |
words := lineStream upToEnd asCollectionOfSubstringsSeparatedBy:$;. |
|
334 |
words := words select:[:each | each notEmpty]. |
|
335 |
words := words select:[:each | each isBlank not]. |
|
336 |
||
337 |
(words isEmpty) ifTrue:[ |
|
22771 | 338 |
stderr showCR:'? usage: #apropos <word> [; morewords]'. |
22735 | 339 |
^ self. |
340 |
]. |
|
341 |
||
342 |
"/ search in classes: |
|
343 |
classNamesMatching := Smalltalk allClasses |
|
344 |
select:[:cls | |
|
345 |
cls isPrivate not |
|
346 |
and:[ words conform:[:word | |
|
347 |
cls name matches:word caseSensitive:false]]] |
|
348 |
thenCollect:#name. |
|
349 |
"/ search in method names: |
|
350 |
selectorsMatching := (Smalltalk allClasses |
|
351 |
collectAll:[:cls | |
|
352 |
cls isPrivate |
|
353 |
ifTrue:[#()] |
|
354 |
ifFalse:[ |
|
355 |
cls selectors |
|
356 |
select:[:sel | |
|
357 |
words conform:[:word | |
|
358 |
sel matches:word caseSensitive:false]]]] |
|
359 |
) asSet. |
|
360 |
||
361 |
showList := |
|
362 |
[:list :listName | |
|
22766 | 363 |
|showIt sortedList longest limit numCols colWidth| |
22735 | 364 |
|
365 |
showIt := true. |
|
366 |
list notEmpty ifTrue:[ |
|
367 |
list size > 20 ifTrue:[ |
|
368 |
showIt := self askYesNo:( |
|
369 |
'apropos: there are %1 matching %2; list them all (y/n)? ' |
|
370 |
bindWith:list size |
|
371 |
with:listName) |
|
372 |
] ifFalse:[ |
|
22771 | 373 |
stderr showCR:'matching %1:' with:listName. |
22735 | 374 |
]. |
375 |
showIt ifTrue:[ |
|
376 |
sortedList := list asOrderedCollection sort. |
|
377 |
longest := (list collect:[:nm | nm size]) max. |
|
378 |
limit := 78. |
|
379 |
numCols := (80 // (longest min:limit)) max:1. |
|
22766 | 380 |
colWidth := (longest min:limit). |
22735 | 381 |
sortedList slicesOf:numCols do:[:eachGroupOfN | |
22771 | 382 |
stderr |
22735 | 383 |
spaces:2; |
384 |
nextPutLine:( |
|
385 |
(eachGroupOfN |
|
386 |
collect:[:nm | |
|
22766 | 387 |
(nm contractTo:colWidth) paddedTo:colWidth |
22735 | 388 |
] |
389 |
) asStringWith:' '). |
|
390 |
]. |
|
391 |
]. |
|
392 |
]. |
|
393 |
]. |
|
394 |
||
395 |
showList value:classNamesMatching value:'classes'. |
|
396 |
showList value:selectorsMatching value:'method names'. |
|
397 |
" |
|
398 |
self basicNew |
|
399 |
input:Stdin; |
|
400 |
cmd_apropos:'Array' readStream |
|
401 |
||
402 |
self basicNew |
|
403 |
input:Stdin; |
|
404 |
cmd_apropos:'at:' readStream |
|
405 |
||
406 |
self basicNew |
|
407 |
input:Stdin; |
|
408 |
cmd_apropos:'*at:' readStream |
|
409 |
" |
|
410 |
! |
|
411 |
||
22768 | 412 |
cmd_break:lineStream |
413 |
"breakpoint directive; i.e. |
|
414 |
#break <classname> ['class'] <selector> |
|
415 |
" |
|
416 |
||
22770 | 417 |
|answer class selectorString selector method implClass| |
22768 | 418 |
|
419 |
answer := self |
|
420 |
getClassNameAndSelectorFrom:lineStream |
|
421 |
specialWords:#('all') |
|
422 |
into:[:classArg :selectorArg | |
|
423 |
class := classArg. |
|
22770 | 424 |
selectorString := selectorArg. |
22768 | 425 |
]. |
426 |
(answer == false) ifTrue:[^ self]. |
|
427 |
(answer = 'all') ifTrue:[ |
|
428 |
^ self |
|
429 |
]. |
|
430 |
||
22770 | 431 |
(selectorString isEmptyOrNil) ifTrue:[ |
22768 | 432 |
stderr nextPutLine:'usage: #break <className> [class] <selector>'. |
433 |
^ self. |
|
434 |
]. |
|
22770 | 435 |
(selector := selectorString asSymbolIfInterned) isNil ifTrue:[ |
436 |
stderr show:'no implementation of selector: '; showCR:selectorString. |
|
22768 | 437 |
^ self. |
22770 | 438 |
]. |
439 |
||
440 |
"/ stderr show:'class: '; showCR:class. |
|
441 |
"/ stderr show:'selector: '; showCR:selector. |
|
442 |
||
443 |
(method := class compiledMethodAt:selector) isNil ifTrue:[ |
|
444 |
implClass := class whichClassImplements:selector. |
|
445 |
implClass isNil ifTrue:[ |
|
22774 | 446 |
(class isMeta not and:[(implClass := class theMetaclass whichClassImplements:selector) notNil]) ifTrue:[ |
22775 | 447 |
stderr nextPutLine:('no such method\(but found one on the class-side; try "#break %1 %2")' withCRs |
22774 | 448 |
bindWith:implClass name with:selector). |
22772 | 449 |
] ifFalse:[ |
450 |
stderr nextPutLine:'no such method'. |
|
451 |
]. |
|
22770 | 452 |
^ self. |
453 |
]. |
|
22774 | 454 |
(self askYesNo:('no such method in %1, but inherited from %2.\Add breakpoint there (y/n)?' withCRs |
22770 | 455 |
bindWith:class name with:implClass name)) ifFalse:[ |
456 |
^ self |
|
457 |
]. |
|
458 |
method := implClass compiledMethodAt:selector. |
|
22768 | 459 |
]. |
460 |
MessageTracer trapMethod:method. |
|
461 |
stderr nextPutLine:'breakpoint set. Use #delete to remove.'. |
|
462 |
||
463 |
" |
|
464 |
self basicNew |
|
465 |
input:Stdin; |
|
466 |
cmd_list:'Array' readStream |
|
467 |
||
468 |
self basicNew |
|
469 |
input:Stdin; |
|
470 |
cmd_list:'Array at:put:' readStream |
|
471 |
||
472 |
self basicNew |
|
473 |
input:Stdin; |
|
474 |
cmd_list:'ReadEvalPrintLoop doIt' readStream |
|
475 |
" |
|
476 |
! |
|
477 |
||
10463 | 478 |
cmd_clear:lineStream |
10255 | 479 |
self cmd_setOrClear:lineStream to:false |
480 |
||
481 |
"Created: / 07-12-2006 / 19:04:50 / cg" |
|
482 |
! |
|
483 |
||
20900 | 484 |
cmd_debug:lineStream |
485 |
MiniDebugger enter. |
|
486 |
! |
|
487 |
||
22768 | 488 |
cmd_delete:lineStream |
489 |
"breakpoint delete directive; i.e. |
|
490 |
#delete <classname> ['class'] <selector> |
|
491 |
#delete <classname> |
|
492 |
#delete all |
|
493 |
" |
|
494 |
||
495 |
|class selector method answer count| |
|
496 |
||
497 |
answer := self |
|
498 |
getClassNameAndSelectorFrom:lineStream |
|
499 |
specialWords:#('all') |
|
500 |
into:[:classArg :selectorArg | |
|
501 |
class := classArg. |
|
502 |
selector := selectorArg. |
|
503 |
]. |
|
504 |
||
505 |
(answer == false) ifTrue:[ |
|
506 |
stderr nextPutLine:'usage: #delete <className> [class] <selector>'. |
|
507 |
stderr nextPutLine:' or: #delete <className> [class]'. |
|
508 |
stderr nextPutLine:' or: #delete all'. |
|
509 |
^ self |
|
510 |
]. |
|
511 |
(answer = 'all') ifTrue:[ |
|
512 |
MessageTracer unwrapAllMethods. |
|
513 |
^ self |
|
514 |
]. |
|
515 |
||
516 |
selector notNil ifTrue:[ |
|
517 |
(method := class compiledMethodAt:selector asSymbol) isNil ifTrue:[ |
|
518 |
stderr nextPutLine:'no such method'. |
|
519 |
^ self. |
|
520 |
]. |
|
521 |
MessageTracer unwrapMethod:method. |
|
522 |
stderr nextPutLine:'breakpoint removed.'. |
|
523 |
^ self. |
|
524 |
]. |
|
525 |
||
526 |
count := 0. |
|
527 |
class instAndClassMethodsDo:[:m | |
|
528 |
m isWrapped ifTrue:[ |
|
529 |
MessageTracer unwrapMethod:m. |
|
530 |
count := count + 1. |
|
531 |
]. |
|
532 |
]. |
|
533 |
stderr nextPutLine:('%1 breakpoints removed.' bindWith:count). |
|
534 |
||
535 |
" |
|
536 |
self basicNew |
|
537 |
input:Stdin; |
|
538 |
cmd_list:'Array' readStream |
|
539 |
||
540 |
self basicNew |
|
541 |
input:Stdin; |
|
542 |
cmd_list:'Array at:put:' readStream |
|
543 |
||
544 |
self basicNew |
|
545 |
input:Stdin; |
|
546 |
cmd_list:'ReadEvalPrintLoop doIt' readStream |
|
547 |
" |
|
548 |
! |
|
549 |
||
20900 | 550 |
cmd_edit:lineStream |
20935 | 551 |
"edit a class or selector in an external editor" |
20900 | 552 |
|
22771 | 553 |
|classOrMethodName cls methodName selector |
20906 | 554 |
code isNewClass editFullClass tmpFile modifiedTime| |
20900 | 555 |
|
20906 | 556 |
isNewClass := editFullClass := false. |
20900 | 557 |
|
558 |
lineStream skipSeparators. |
|
20926 | 559 |
lineStream atEnd ifTrue:[ |
560 |
cls := lastEditedClass. |
|
561 |
methodName := lastEditedSelector. |
|
562 |
] ifFalse:[ |
|
563 |
classOrMethodName := lineStream |
|
564 |
upToElementForWhich:[:ch | |
|
565 |
ch isLetterOrDigit not and:[ch ~~ $_] |
|
566 |
]. |
|
567 |
"/ |
|
568 |
(classOrMethodName isUppercaseFirst) ifTrue:[ |
|
569 |
(cls := Smalltalk classNamed:classOrMethodName) isNil ifTrue:[ |
|
22771 | 570 |
stderr show:'edit: no such class: ',classOrMethodName,' ; create (y/n)? '. |
20926 | 571 |
(self inputStream nextLine withoutSeparators startsWith:'y') ifFalse:[^ self]. |
572 |
isNewClass := true. |
|
573 |
code := |
|
574 |
'"/ change the code as required, then save and exit the editor. |
|
575 |
"/ To cancel this edit, leave the editor WITHOUT saving. |
|
576 |
"/ |
|
577 |
||
578 |
Object |
|
20900 | 579 |
subclass:#%1 |
580 |
instanceVariableNames:'''' |
|
581 |
classVariableNames:'''' |
|
582 |
poolDictionaries:'''' |
|
583 |
category:''user classes'' |
|
584 |
' bindWith:classOrMethodName. |
|
20926 | 585 |
] ifFalse:[ |
586 |
lineStream skipSeparators. |
|
587 |
lineStream atEnd ifFalse:[ |
|
588 |
methodName := lineStream upToSeparator. |
|
22735 | 589 |
methodName = 'class' ifTrue:[ |
590 |
cls := cls theMetaclass. |
|
591 |
lineStream skipSeparators. |
|
592 |
methodName := lineStream upToSeparator. |
|
593 |
]. |
|
20926 | 594 |
]. |
20900 | 595 |
]. |
20926 | 596 |
] ifFalse:[ |
597 |
methodName := classOrMethodName |
|
20900 | 598 |
]. |
599 |
]. |
|
20926 | 600 |
|
20900 | 601 |
isNewClass ifFalse:[ |
602 |
cls := cls ? lastEditedClass. |
|
603 |
cls isNil ifTrue:[ |
|
22771 | 604 |
stderr showCR:'edit usage:'. |
605 |
stderr showCR:' #edit className selector'. |
|
606 |
stderr showCR:' #edit className '. |
|
607 |
stderr showCR:' #edit selector (class as in previous edit)'. |
|
608 |
stderr showCR:' #edit (class/method as in previous edit)'. |
|
20900 | 609 |
^ self. |
610 |
]. |
|
611 |
lastEditedClass := cls. |
|
20926 | 612 |
lastEditedSelector := methodName. |
613 |
||
20906 | 614 |
methodName isNil ifTrue:[ |
615 |
editFullClass := true. |
|
616 |
code := cls source asString |
|
617 |
] ifFalse:[ |
|
618 |
((selector := methodName asSymbolIfInterned) isNil |
|
619 |
or:[ (cls implements:selector) not]) ifTrue:[ |
|
22735 | 620 |
(self askYesNo:('"',methodName,'" is a new method; create (y/n)? ')) ifFalse:[^ self]. |
621 |
||
20926 | 622 |
code := |
623 |
'"/ change the code as required, then save and exit the editor. |
|
624 |
"/ To cancel this edit, leave the editor WITHOUT saving. |
|
625 |
||
20900 | 626 |
%1 |
627 |
"this is a new method" |
|
628 |
self halt |
|
20906 | 629 |
' bindWith:methodName. |
630 |
] ifFalse:[ |
|
20926 | 631 |
code := (cls compiledMethodAt:selector) source. |
20906 | 632 |
]. |
20900 | 633 |
]. |
634 |
]. |
|
635 |
||
20906 | 636 |
[ |
20936 | 637 |
|ok cmd| |
20933 | 638 |
|
20906 | 639 |
tmpFile := Filename newTemporary. |
640 |
tmpFile contents:code. |
|
641 |
modifiedTime := tmpFile modificationTime. |
|
20933 | 642 |
|
20936 | 643 |
cmd := '%1 "%2"'. |
644 |
OperatingSystem isUNIXlike ifTrue:[ |
|
22767 | 645 |
cmd := '%1 "%2" </dev/tty >/dev/tty 2>&1'. |
20936 | 646 |
]. |
647 |
||
20933 | 648 |
ok := OperatingSystem |
20936 | 649 |
executeCommand:(cmd bindWith:(self editorCommand) with:tmpFile pathName) |
650 |
inputFrom:Stdin |
|
651 |
outputTo:Stdout |
|
652 |
errorTo:Stderr |
|
20933 | 653 |
auxFrom:nil |
654 |
environment:nil |
|
655 |
inDirectory:nil |
|
656 |
lineWise:false |
|
657 |
newPgrp:false |
|
658 |
showWindow:true |
|
659 |
onError:[:status | false]. |
|
660 |
||
661 |
(ok and:[tmpFile modificationTime ~= modifiedTime]) ifTrue:[ |
|
20906 | 662 |
isNewClass ifTrue:[ |
663 |
Compiler evaluate:tmpFile contentsOfEntireFile. |
|
22771 | 664 |
stderr showCR:'Class (re)defined.' |
20906 | 665 |
] ifFalse:[ |
666 |
editFullClass ifTrue:[ |
|
667 |
tmpFile fileIn. |
|
22771 | 668 |
stderr showCR:'Class (re)compiled.' |
20906 | 669 |
] ifFalse:[ |
670 |
cls compile:tmpFile contentsOfEntireFile classified:'*as yet uncategorized'. |
|
22771 | 671 |
stderr showCR:'Method (re)compiled.' |
20906 | 672 |
]. |
673 |
]. |
|
20937 | 674 |
] ifFalse:[ |
22771 | 675 |
stderr showCR:'No change.' |
20937 | 676 |
]. |
20906 | 677 |
] ensure:[ |
678 |
tmpFile notNil ifTrue:[ |
|
679 |
tmpFile remove |
|
680 |
] |
|
20900 | 681 |
]. |
20906 | 682 |
|
20900 | 683 |
" |
20934 | 684 |
Smalltalk readEvalPrintLoop |
685 |
||
20900 | 686 |
self new |
687 |
input:Stdin; |
|
688 |
cmd_edit:'MyClass foo' readStream |
|
22735 | 689 |
|
690 |
self new |
|
691 |
input:Stdin; |
|
692 |
cmd_edit:'Array class new:' readStream |
|
20900 | 693 |
" |
20933 | 694 |
|
20935 | 695 |
"Modified: / 08-11-2016 / 22:46:12 / cg" |
20900 | 696 |
! |
697 |
||
10463 | 698 |
cmd_exit:lineStream |
22576 | 699 |
"exit directive - leaves the repl" |
700 |
||
10628
284266d54dbe
#exit only leaves the rep-loop
Claus Gittinger <cg@exept.de>
parents:
10500
diff
changeset
|
701 |
exitAction value |
10463 | 702 |
|
703 |
"Created: / 07-12-2006 / 18:55:46 / cg" |
|
10255 | 704 |
! |
705 |
||
10463 | 706 |
cmd_help:lineStream |
22771 | 707 |
stderr |
20771 | 708 |
nextPutAll: |
16084 | 709 |
'Everything entered up to an empty line or a line ending in "." is called a "chunk" and evaluated. |
22742 | 710 |
Lines starting with "#" (in the first column) are commands to the read-eval-print interpreter. |
10463 | 711 |
|
712 |
Valid commands are: |
|
22765 | 713 |
#exit ............... exit interpreter loop |
10635
c3c4fc186068
changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents:
10632
diff
changeset
|
714 |
#help ............... this text |
22795 | 715 |
#usage .............. command line arguments |
22776 | 716 |
#ide ................ open the IDE |
22765 | 717 |
#apropos word ....... list classes/selectors matching word |
718 |
#list <what> ........ show source |
|
719 |
class .............. class definition and comment |
|
720 |
class selector ..... method source |
|
721 |
#read <filename>..... read another script or source file |
|
10635
c3c4fc186068
changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents:
10632
diff
changeset
|
722 |
#use <package>....... use (load) a package |
20771 | 723 |
stx:libwidg .............. GUI package |
724 |
stx:libtool .............. IDE tool package |
|
725 |
stx:goodies/regex ........ regex package |
|
726 |
stx:goodies/petitparser .. peg parser package |
|
22765 | 727 |
goodies/petitparser ...... default package prefix is "stx:" |
728 |
default defaultPrefix .... change the default package prefix |
|
22775 | 729 |
#show <what> .......... show info |
730 |
variables ............ interpreter variables |
|
731 |
processes ............ processes |
|
732 |
memory ............... memory usage |
|
733 |
flags ................ flags |
|
734 |
modules .............. loaded modules |
|
735 |
packages ............. available packages to load |
|
736 |
all .................. all of the above |
|
737 |
#set <flag> ........... set a flag (value defaults to true) |
|
738 |
print ................ print return values |
|
739 |
nodebug .............. no debugger on error |
|
740 |
confirmdebug ......... ask for debugger on error |
|
741 |
trace ................ tracing execution |
|
742 |
timing ............... timing execution |
|
743 |
profiling ............ show execution profile |
|
744 |
chunkFormat .......... traditional bang chunk format input mode |
|
745 |
editor ............... command used with #edit directive |
|
746 |
prefix defPrefix ..... change the default package prefix |
|
747 |
#clear <flag> ......... same as: "#set <flag> false" |
|
748 |
#debug ................ enter a MiniDebugger |
|
749 |
#break class selector .... add a breakpoint |
|
750 |
#delete <what> ........ delete breakpoint(s) |
|
751 |
all .................. delete all breakpoints |
|
752 |
class ................ delete breakpoints in class |
|
753 |
class selector ....... delete this breakpoint |
|
754 |
#edit <what> .......... open an external editor |
|
755 |
class ................ on a class |
|
756 |
class selector ....... on a method |
|
757 |
<empty> .............. on previously edited method/last class |
|
10257 | 758 |
|
16087 | 759 |
The MiniDebugger (if entered) shows its own help with "?". |
10255 | 760 |
' |
761 |
||
762 |
"Created: / 07-12-2006 / 18:54:20 / cg" |
|
20935 | 763 |
"Modified: / 08-11-2016 / 22:53:53 / cg" |
10255 | 764 |
! |
765 |
||
22768 | 766 |
cmd_ide:lineStream |
767 |
"upen up the ide" |
|
768 |
||
22778 | 769 |
|builder app| |
770 |
||
771 |
builder := NewLauncher open. |
|
772 |
builder notNil ifTrue:[ |
|
773 |
app := builder application. |
|
774 |
||
22780 | 775 |
stderr showCR:'waiting for launcher to be closed...'. |
776 |
||
22778 | 777 |
"/ don't go back into the reader, as this will slow down the |
778 |
"/ IDE (donnow why, at the moment) |
|
779 |
[ |
|
22779 | 780 |
Delay waitForSeconds:0.5. |
22778 | 781 |
app isOpen |
782 |
] whileTrue. |
|
783 |
]. |
|
22768 | 784 |
! |
785 |
||
22765 | 786 |
cmd_language:lineStream |
787 |
"language directive; i.e. |
|
788 |
#language smalltalk |
|
789 |
#language javascript |
|
790 |
" |
|
791 |
||
792 |
|lang| |
|
793 |
||
794 |
lineStream skipSeparators. |
|
795 |
lang := lineStream upToEnd withoutSeparators. |
|
796 |
lang = 'smalltalk' ifTrue:[ |
|
797 |
compiler := Compiler. |
|
798 |
^ self. |
|
799 |
]. |
|
800 |
lang = 'javascript' ifTrue:[ |
|
801 |
compiler := JavaScriptCompiler. |
|
802 |
^ self. |
|
803 |
]. |
|
804 |
||
22771 | 805 |
stderr |
22765 | 806 |
showCR:'? usage: #language smalltalk'; |
807 |
showCR:'? or: #language javascript'. |
|
808 |
! |
|
809 |
||
22735 | 810 |
cmd_list:lineStream |
811 |
"list directive; i.e. |
|
812 |
#list <classname> ['class'] <selector> |
|
813 |
" |
|
814 |
||
22771 | 815 |
|class selector source| |
22735 | 816 |
|
817 |
(self |
|
22768 | 818 |
getClassNameAndSelectorFrom:lineStream |
819 |
specialWords:nil |
|
22735 | 820 |
into:[:classArg :selectorArg | |
821 |
class := classArg. |
|
822 |
selector := selectorArg. |
|
823 |
]) ifFalse:[^ self]. |
|
824 |
||
825 |
selector isNil ifTrue:[ |
|
22771 | 826 |
stderr nextPutAll:(class definition); cr. |
827 |
stderr nextPutAll:(class commentOrDocumentationString); cr. |
|
22735 | 828 |
] ifFalse:[ |
829 |
source := class sourceCodeAt:selector asSymbol. |
|
830 |
source isEmptyOrNil ifTrue:[ |
|
22771 | 831 |
stderr nextPutLine:'Sorry, no sourcecode found' |
22735 | 832 |
] ifFalse:[ |
22771 | 833 |
stderr nextPutAll:source; cr |
22735 | 834 |
]. |
835 |
]. |
|
836 |
||
837 |
" |
|
22775 | 838 |
(ReadEvalPrintLoop basicNew error:Stderr) |
22735 | 839 |
input:Stdin; |
840 |
cmd_list:'Array' readStream |
|
841 |
||
22775 | 842 |
(ReadEvalPrintLoop basicNew error:Stderr) |
22735 | 843 |
input:Stdin; |
844 |
cmd_list:'Array at:put:' readStream |
|
22764 | 845 |
|
22775 | 846 |
(ReadEvalPrintLoop basicNew error:Stderr) |
22764 | 847 |
input:Stdin; |
848 |
cmd_list:'ReadEvalPrintLoop doIt' readStream |
|
22735 | 849 |
" |
850 |
! |
|
851 |
||
16087 | 852 |
cmd_read:lineStream |
22577 | 853 |
"read directive; i.e. |
854 |
#read scriptFile |
|
855 |
" |
|
856 |
||
22765 | 857 |
|filename newInput |
858 |
savedPrompt savedPrint savedInput savedCurrentDirectory savedDoChunkFormat |
|
859 |
savedTraceFlag savedProfileFlag savedNoDebugger| |
|
16087 | 860 |
|
861 |
lineStream skipSeparators. |
|
862 |
filename := lineStream upToEnd withoutSeparators. |
|
22577 | 863 |
filename isEmptyOrNil ifTrue:[ |
22771 | 864 |
stderr showCR:'? usage: #read <filename>'. |
20909 | 865 |
^ self. |
16133 | 866 |
]. |
16087 | 867 |
|
20915 | 868 |
currentDirectory := currentDirectory ? (Filename currentDirectory). |
869 |
||
16087 | 870 |
filename := filename asFilename. |
871 |
filename isAbsolute ifFalse:[ |
|
20909 | 872 |
filename := currentDirectory construct:filename. |
16087 | 873 |
]. |
874 |
||
20922 | 875 |
StreamError ignoreIn:[ |
876 |
newInput := filename readStream. |
|
877 |
]. |
|
16087 | 878 |
newInput isNil ifTrue:[ |
22771 | 879 |
stderr showCR:('Could not find file: "',filename pathName,'"'). |
20909 | 880 |
^ self. |
16087 | 881 |
]. |
882 |
||
883 |
[ |
|
20909 | 884 |
savedCurrentDirectory := currentDirectory. |
20912 | 885 |
savedDoChunkFormat := doChunkFormat. |
22765 | 886 |
savedTraceFlag := traceFlag. |
887 |
savedProfileFlag := profilingFlag. |
|
20909 | 888 |
savedInput := inputStream. |
889 |
savedPrint := printFlag. |
|
890 |
savedPrompt := prompt. |
|
16087 | 891 |
|
20909 | 892 |
currentDirectory := filename directory. |
893 |
inputStream := newInput. |
|
22765 | 894 |
prompt := nil. |
895 |
||
20909 | 896 |
self |
897 |
basicReadEvalPrintLoopWithInput:newInput |
|
898 |
output:outputStream |
|
899 |
error:errorStream |
|
20910 | 900 |
compiler:(compiler ? Compiler ? Parser) |
20909 | 901 |
prompt:false |
902 |
print:false. |
|
16087 | 903 |
] ensure:[ |
20914 | 904 |
newInput close. |
20912 | 905 |
doChunkFormat := savedDoChunkFormat. |
20909 | 906 |
currentDirectory := savedCurrentDirectory. |
22765 | 907 |
traceFlag := savedTraceFlag. |
908 |
profilingFlag := savedProfileFlag. |
|
20909 | 909 |
inputStream := savedInput. |
910 |
printFlag := savedPrint. |
|
20912 | 911 |
prompt := savedPrompt. |
16087 | 912 |
]. |
913 |
! |
|
914 |
||
10463 | 915 |
cmd_set:lineStream |
10255 | 916 |
self cmd_setOrClear:lineStream to:true |
917 |
||
918 |
"Modified: / 07-12-2006 / 19:04:46 / cg" |
|
919 |
! |
|
920 |
||
10463 | 921 |
cmd_setOrClear:lineStream to:aBoolean |
22735 | 922 |
"set/clear one of my internal flags" |
923 |
||
22765 | 924 |
|what flag| |
22753 | 925 |
|
926 |
flag := aBoolean. |
|
10463 | 927 |
|
928 |
lineStream skipSeparators. |
|
929 |
what := lineStream nextAlphaNumericWord. |
|
22765 | 930 |
|
931 |
lineStream skipSeparators. |
|
932 |
||
933 |
"/ peek ahead for "false" |
|
934 |
"/ so we can also say: #set <flag> f |
|
22753 | 935 |
flag ifTrue:[ |
936 |
lineStream atEnd ifFalse:[ |
|
22765 | 937 |
flag := (lineStream peek == $f) not. |
22753 | 938 |
]. |
939 |
]. |
|
940 |
||
16133 | 941 |
what notNil ifTrue:[ |
20771 | 942 |
(what startsWith:'tra') ifTrue:[ |
22753 | 943 |
traceFlag := flag. |
20771 | 944 |
^ self. |
945 |
]. |
|
946 |
(what startsWith:'tim') ifTrue:[ |
|
22753 | 947 |
timingFlag := flag. |
20771 | 948 |
^ self. |
949 |
]. |
|
22765 | 950 |
(what startsWith:'prof') ifTrue:[ |
22753 | 951 |
profilingFlag := flag. |
20771 | 952 |
^ self. |
953 |
]. |
|
954 |
(what startsWith:'chunk') ifTrue:[ |
|
22753 | 955 |
doChunkFormat := flag. |
20771 | 956 |
^ self. |
957 |
]. |
|
20935 | 958 |
(what startsWith:'edi') ifTrue:[ |
22753 | 959 |
flag ifTrue:[ |
22765 | 960 |
"/ #set editor <cmd> |
20935 | 961 |
lineStream skipSeparators. |
22765 | 962 |
editorCommand := lineStream upToEnd withoutSeparators. |
20935 | 963 |
] ifFalse:[ |
964 |
editorCommand := nil. |
|
20938 | 965 |
]. |
966 |
^ self. |
|
20935 | 967 |
]. |
22735 | 968 |
(what startsWith:'con') ifTrue:[ |
22753 | 969 |
confirmDebugger := flag. |
22735 | 970 |
^ self. |
971 |
]. |
|
22747 | 972 |
(what startsWith:'node') ifTrue:[ |
22753 | 973 |
noDebugger := flag. |
22746 | 974 |
^ self. |
975 |
]. |
|
22743 | 976 |
(what startsWith:'pri') ifTrue:[ |
22753 | 977 |
printFlag := flag. |
22743 | 978 |
^ self. |
979 |
]. |
|
22765 | 980 |
(what startsWith:'prom') ifTrue:[ |
981 |
flag ifTrue:[ |
|
982 |
"/ #set prompt <prompt> |
|
983 |
self prompt:(lineStream upToEnd withoutSeparators). |
|
984 |
] ifFalse:[ |
|
985 |
"/ #clear prompt |
|
986 |
self prompt:nil |
|
987 |
]. |
|
988 |
^ self. |
|
989 |
]. |
|
990 |
(what startsWith:'ans') ifTrue:[ |
|
991 |
flag ifTrue:[ |
|
992 |
"/ #set returnprompt <cmd> |
|
993 |
lineStream skipSeparators. |
|
994 |
self answerPrompt:(lineStream upToEnd withoutSeparators). |
|
995 |
] ifFalse:[ |
|
996 |
"/ #clear the answer prompt |
|
997 |
self answerPrompt:''. |
|
998 |
]. |
|
999 |
^ self. |
|
1000 |
]. |
|
10463 | 1001 |
]. |
22771 | 1002 |
stderr |
22735 | 1003 |
showCR:'? usage: set/clear <flag>'; |
22765 | 1004 |
showCR:'? (<flag> must be one of: print, nodebug, confirmdebug, trace, times, profile, chunk, prompt, answerprompt, editor)'. |
22749 | 1005 |
self cmd_show:('flags' readStream). |
10255 | 1006 |
|
20935 | 1007 |
"Modified: / 08-11-2016 / 22:49:17 / cg" |
10255 | 1008 |
! |
1009 |
||
10463 | 1010 |
cmd_show:lineStream |
22575 | 1011 |
"show directive: |
1012 |
show packages |
|
1013 |
show modules (= loaded packages) |
|
1014 |
show variables |
|
1015 |
etc. |
|
1016 |
" |
|
1017 |
||
22771 | 1018 |
|what showAll ok| |
16087 | 1019 |
|
10463 | 1020 |
lineStream skipSeparators. |
1021 |
what := lineStream nextAlphaNumericWord. |
|
20834 | 1022 |
ok := false. |
1023 |
||
16133 | 1024 |
what notNil ifTrue:[ |
20834 | 1025 |
showAll := (what startsWith:'all'). |
1026 |
||
20835 | 1027 |
(showAll or:[ what startsWith:'var' ]) ifTrue:[ |
22771 | 1028 |
stderr showCR:'Variables:'; showCR:'----------'. |
20901 | 1029 |
self showVariables. |
20845 | 1030 |
ok := true. |
20768 | 1031 |
]. |
20845 | 1032 |
|
20835 | 1033 |
(showAll or:[ what startsWith:'proc' ]) ifTrue:[ |
22771 | 1034 |
stderr cr; showCR:'Threads:'; showCR:'--------'. |
20768 | 1035 |
MiniDebugger basicNew showProcesses. |
20845 | 1036 |
ok := true. |
20768 | 1037 |
]. |
20845 | 1038 |
|
20902 | 1039 |
("showAll or:[" what startsWith:'pack' "]") ifTrue:[ |
22771 | 1040 |
stderr cr; showCR:'Available Packages:'; showCR:'--------'. |
20900 | 1041 |
self showPackages. |
1042 |
ok := true. |
|
1043 |
]. |
|
1044 |
||
20834 | 1045 |
(showAll or:[ what startsWith:'mod' ]) ifTrue:[ |
22771 | 1046 |
stderr cr; showCR:'Modules:'; showCR:'--------'. |
20901 | 1047 |
self showModules. |
13865 | 1048 |
|
20845 | 1049 |
ok := true. |
20768 | 1050 |
]. |
20845 | 1051 |
|
20834 | 1052 |
(showAll or:[ what startsWith:'mem' ]) ifTrue:[ |
1053 |
|allMem| |
|
1054 |
||
22771 | 1055 |
stderr cr; showCR:'Memory:'; showCR:'-------'. |
20891 | 1056 |
"/ allMem := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed |
1057 |
"/ + ObjectMemory newSpaceUsed. |
|
22771 | 1058 |
stderr |
20923 | 1059 |
"/ showCR:('overall: ',(allMem // 1024) printString,' Kb'); |
1060 |
showCR:('used : ',(ObjectMemory bytesUsed // 1024) printString,' Kb'); |
|
1061 |
showCR:('free : ',(ObjectMemory freeSpace // 1024) printString,' Kb'); |
|
1062 |
show:('minorGC: ',(ObjectMemory scavengeCount) printString); |
|
1063 |
showCR:(' majorGC: ',(ObjectMemory garbageCollectCount) printString). |
|
20845 | 1064 |
ok := true. |
20768 | 1065 |
]. |
20845 | 1066 |
|
22775 | 1067 |
(showAll or:[ what startsWith:'bre' ]) ifTrue:[ |
1068 |
stderr cr; showCR:'Breakpoints:'; showCR:'--------'. |
|
1069 |
self showBreakpoints. |
|
1070 |
||
1071 |
ok := true. |
|
1072 |
]. |
|
1073 |
||
20834 | 1074 |
(showAll or:[ what startsWith:'flag' ]) ifTrue:[ |
22771 | 1075 |
stderr cr; showCR:'Flags:'; showCR:'------'. |
1076 |
stderr |
|
22754 | 1077 |
showCR:('print: ',self printFlag printString); |
1078 |
showCR:('nodebug: ',self noDebugger printString); |
|
1079 |
showCR:('confirmdebug:',self confirmDebugger printString); |
|
20923 | 1080 |
showCR:('trace : ',(traceFlag ? false) printString); |
1081 |
showCR:('timing: ',(timingFlag ? false) printString); |
|
1082 |
showCR:('profiling: ',(profilingFlag ? false) printString); |
|
20935 | 1083 |
showCR:('chunkFormat: ',(doChunkFormat ? false) printString); |
22735 | 1084 |
showCR:('editor: ',self editorCommand printString); |
22765 | 1085 |
showCR:('prefix: ',self defaultPackagePrefix printString); |
1086 |
showCR:('prompt: ',prompt printString); |
|
1087 |
showCR:('answerprompt:',self answerPrompt printString); |
|
22754 | 1088 |
yourself. |
20845 | 1089 |
ok := true. |
20768 | 1090 |
]. |
10463 | 1091 |
]. |
1092 |
||
20834 | 1093 |
ok ifFalse:[ |
22771 | 1094 |
stderr showCR:'? usage: show <what>'. |
1095 |
stderr showCR:'? (<what> must be one of: packages, modules, variables, flags, memory, processes)'. |
|
20834 | 1096 |
]. |
1097 |
||
1098 |
" |
|
22775 | 1099 |
(ReadEvalPrintLoop basicNew error:Stderr) cmd_show:'packages' readStream |
20834 | 1100 |
" |
10255 | 1101 |
|
20935 | 1102 |
"Modified: / 08-11-2016 / 22:46:51 / cg" |
10255 | 1103 |
! |
1104 |
||
22795 | 1105 |
cmd_usage:lineStream |
1106 |
stderr |
|
1107 |
nextPutAll:'usage: ',OperatingSystem nameOfSTXExecutable asFilename baseName,' [options...] |
|
1108 |
--help .................. output full detailed usage info. |
|
22796 | 1109 |
-R / --repl ............. read-eval-print-loop |
1110 |
-E / --eval <expr> ...... eval expr, then exit |
|
1111 |
-P / --print <expr> ..... eval expr, print, then exit |
|
1112 |
-f / --execute <file> ... eval exprs from file, then exit |
|
1113 |
-l / --load <file> ...... load file before starting |
|
1114 |
-q / --silent ........... suppress messages (& prompts in repl) |
|
22795 | 1115 |
|
1116 |
For a full list of options, please take a look at the documentation |
|
1117 |
in "doc/online/english/getstart/TOP.html". |
|
1118 |
' |
|
1119 |
! |
|
1120 |
||
10463 | 1121 |
cmd_use:lineStream |
22574 | 1122 |
"use directive; i.e. |
1123 |
#use stx:goodies/xml |
|
1124 |
#use exept:mqtt |
|
22765 | 1125 |
#use goodies/regression |
22574 | 1126 |
" |
1127 |
||
22765 | 1128 |
|pkg s defaultPrefix| |
10463 | 1129 |
|
1130 |
lineStream skipSeparators. |
|
22765 | 1131 |
pkg := lineStream upToEnd withoutSeparators. |
1132 |
pkg isEmpty ifTrue:[ |
|
22771 | 1133 |
stderr |
22765 | 1134 |
showCR:'? usage: #use <package>'; |
1135 |
showCR:'? or: #use default <packagePrefix>'. |
|
1136 |
^ self. |
|
1137 |
]. |
|
1138 |
||
1139 |
s := pkg readStream. |
|
1140 |
(s nextAlphaNumericWord) = 'default' ifTrue:[ |
|
1141 |
defaultPrefix := s upToEnd withoutSeparators. |
|
1142 |
self defaultPackagePrefix:defaultPrefix. |
|
20923 | 1143 |
^ self. |
16133 | 1144 |
]. |
1145 |
||
16145 | 1146 |
[ |
20923 | 1147 |
Smalltalk loadPackage:pkg. |
16145 | 1148 |
] on:PackageLoadError do:[:ex| |
20923 | 1149 |
"/ allow for some shortcuts... |
1150 |
(pkg includes:$:) ifTrue:[ |
|
22771 | 1151 |
stderr showCR:('Failed to load package: "',pkg,'"'). |
20923 | 1152 |
] ifFalse:[ |
1153 |
"/ try stx standard package |
|
22765 | 1154 |
pkg := (self defaultPackagePrefix), pkg. |
20923 | 1155 |
ex restart. |
1156 |
]. |
|
13852 | 1157 |
]. |
10255 | 1158 |
|
1159 |
"Created: / 07-12-2006 / 19:07:56 / cg" |
|
10463 | 1160 |
! |
1161 |
||
1162 |
directive:line |
|
1163 |
|s cmd| |
|
1164 |
||
1165 |
s := line readStream. |
|
1166 |
s next. "/ skip the hash |
|
20913 | 1167 |
s peek == $!! ifTrue:[ |
1168 |
"/ skip shebang line |
|
1169 |
^ self. |
|
1170 |
]. |
|
10463 | 1171 |
s skipSeparators. |
1172 |
||
1173 |
cmd := s nextAlphaNumericWord. |
|
16087 | 1174 |
cmd notNil ifTrue:[ |
20919 | 1175 |
AbortAllOperationRequest handle:[:ex | |
22771 | 1176 |
stderr showCR:('Directive aborted: ', ex description) |
20919 | 1177 |
] do:[ |
20920 | 1178 |
Error handle:[:ex | |
22771 | 1179 |
stderr showCR:('Caught in directive: ', ex description). |
20926 | 1180 |
ex suspendedContext fullPrintAll. |
20919 | 1181 |
] do:[ |
20926 | 1182 |
ControlInterrupt handle:[:ex | |
20936 | 1183 |
MiniDebugger enter. |
22771 | 1184 |
"/ stderr showCR:('Ignored in directive: ', ex description). |
20936 | 1185 |
"/ ex reject. |
1186 |
"/ ex proceed. |
|
20926 | 1187 |
] do:[ |
1188 |
self |
|
1189 |
perform:('cmd_',cmd) asMutator with:s |
|
1190 |
ifNotUnderstood:[ |
|
22771 | 1191 |
stderr |
22739 | 1192 |
showCR:'?? invalid command: %1. Type "#help" for help.' with:cmd. |
20926 | 1193 |
]. |
1194 |
]. |
|
20913 | 1195 |
]. |
20919 | 1196 |
]. |
16087 | 1197 |
]. |
10463 | 1198 |
|
1199 |
"Created: / 07-12-2006 / 18:49:17 / cg" |
|
20933 | 1200 |
"Modified: / 08-11-2016 / 21:59:16 / cg" |
20900 | 1201 |
! |
1202 |
||
22768 | 1203 |
getClassNameAndSelectorFrom:lineStream specialWords:specialWords into:aBlock |
22735 | 1204 |
"a helper for list and edit; parses class and selector name. |
22768 | 1205 |
if the argument is one of the specialWords, return it. |
1206 |
otherwise, returns true if class/selector are ok, |
|
1207 |
or false if nothing reasonable was entered" |
|
22735 | 1208 |
|
1209 |
|words wordStream className class selector| |
|
1210 |
||
1211 |
lineStream skipSeparators. |
|
1212 |
words := lineStream upToEnd asCollectionOfWords. |
|
1213 |
||
1214 |
(words isEmpty) ifTrue:[ |
|
1215 |
^ false. |
|
1216 |
]. |
|
1217 |
||
1218 |
wordStream := words readStream. |
|
1219 |
||
1220 |
"/ search in classes: |
|
1221 |
className := wordStream next. |
|
22768 | 1222 |
((specialWords ? #()) includes:className) ifTrue:[ |
1223 |
^ className |
|
1224 |
]. |
|
1225 |
||
22735 | 1226 |
class := Smalltalk classNamed:className. |
1227 |
class isNil ifTrue:[ |
|
22771 | 1228 |
stderr showCR:'no such class: ',className. |
22735 | 1229 |
^ false. |
1230 |
]. |
|
1231 |
||
1232 |
(wordStream atEnd not and:[wordStream peek = 'class']) ifTrue:[ |
|
1233 |
wordStream next. |
|
1234 |
class := class theMetaclass |
|
1235 |
]. |
|
1236 |
(wordStream atEnd) ifFalse:[ |
|
1237 |
selector := wordStream next. |
|
1238 |
]. |
|
1239 |
aBlock value:class value:selector. |
|
1240 |
^ true |
|
1241 |
! |
|
1242 |
||
22775 | 1243 |
showBreakpoints |
1244 |
Smalltalk allClassesDo:[:cls | |
|
1245 |
cls theNonMetaclass instAndClassSelectorsAndMethodsDo:[:sel :mthd | |
|
1246 |
mthd isWrapped ifTrue:[ |
|
22776 | 1247 |
stderr showCR:(mthd whoString) |
22775 | 1248 |
]. |
1249 |
]. |
|
1250 |
]. |
|
1251 |
||
1252 |
" |
|
1253 |
(ReadEvalPrintLoop basicNew error:Stderr) showBreakpoints |
|
1254 |
" |
|
1255 |
! |
|
1256 |
||
20901 | 1257 |
showModules |
22775 | 1258 |
"lists loaded packages" |
1259 |
||
22771 | 1260 |
|printModule| |
20901 | 1261 |
|
1262 |
printModule := |
|
1263 |
[:mod | |
|
22775 | 1264 |
self errorStream |
20923 | 1265 |
show:' '; |
1266 |
show:(mod package "libraryName"); |
|
1267 |
showCR:' (',(mod type),')'. |
|
20901 | 1268 |
]. |
1269 |
||
22771 | 1270 |
stderr nextPutLine:'builtIn:'. |
20901 | 1271 |
((ObjectMemory binaryModuleInfo |
1272 |
reject:[:m | m dynamic]) |
|
1273 |
asSortedCollection:[:a :b | a name < b name]) do:printModule. |
|
1274 |
||
22771 | 1275 |
stderr nextPutLine:'dynamic:'. |
20901 | 1276 |
((ObjectMemory binaryModuleInfo |
1277 |
select:[:m | m dynamic]) |
|
1278 |
asSortedCollection:[:a :b | a name < b name]) do:printModule. |
|
1279 |
||
1280 |
" |
|
22775 | 1281 |
(ReadEvalPrintLoop basicNew error:Stderr) showModules |
20901 | 1282 |
" |
1283 |
! |
|
1284 |
||
20900 | 1285 |
showPackages |
22775 | 1286 |
"lists all known packages" |
1287 |
||
20900 | 1288 |
|all| |
1289 |
||
1290 |
all := Set new. |
|
1291 |
Smalltalk knownLoadablePackagesDo:[:packageID :type :path | |
|
1292 |
all add:packageID |
|
1293 |
]. |
|
1294 |
all := all asOrderedCollection sort. |
|
1295 |
all do:[:eachPackage | |
|
22771 | 1296 |
stderr show:eachPackage. |
20901 | 1297 |
(Smalltalk isPackageLoaded:eachPackage) ifTrue:[ |
22771 | 1298 |
stderr show:' (loaded)'. |
20901 | 1299 |
]. |
22771 | 1300 |
stderr cr. |
20900 | 1301 |
]. |
1302 |
||
1303 |
" |
|
22775 | 1304 |
(ReadEvalPrintLoop basicNew error:Stderr) showPackages |
1305 |
(ReadEvalPrintLoop basicNew error:Stderr) showModules |
|
20901 | 1306 |
" |
1307 |
! |
|
1308 |
||
1309 |
showVariables |
|
1310 |
Workspace notNil ifTrue:[ |
|
1311 |
Workspace workspaceVariables keys asOrderedCollection sort do:[:nm | |
|
1312 |
|holder| |
|
22771 | 1313 |
|
20901 | 1314 |
holder := Workspace workspaceVariables at:nm. |
22771 | 1315 |
stderr |
20923 | 1316 |
show:nm; |
1317 |
show:' -> '; |
|
1318 |
showCR:holder value printString. |
|
20901 | 1319 |
]. |
1320 |
]. |
|
1321 |
||
1322 |
" |
|
22775 | 1323 |
(ReadEvalPrintLoop basicNew error:Stderr) showVariables |
20900 | 1324 |
" |
10255 | 1325 |
! ! |
1326 |
||
10248 | 1327 |
!ReadEvalPrintLoop methodsFor:'evaluation'! |
1328 |
||
16565 | 1329 |
basicReadEvalPrintLoopWithInput:input output:output error:error |
22762 | 1330 |
compiler:compilerClass prompt:doPrompt print:doPrint |
16087 | 1331 |
|
1332 |
"{ Pragma: +optSpace }" |
|
1333 |
||
22735 | 1334 |
"the core of the interpreter loop; |
1335 |
extracted and parametrized, so it can be called recursively for included scripts. |
|
16087 | 1336 |
If chunkFormat is true, chunks are read. |
1337 |
Otherwise, lines up to an empty line (or EOF) or a line ending in '.' are read. |
|
20774 | 1338 |
A '#' character appearing in the first column of the first line turns off chunkmode, |
1339 |
which allows for convenient shell scripts containing a #/bin/stx as the first line." |
|
16087 | 1340 |
|
20911 | 1341 |
exitAction := [^ self]. |
1342 |
||
16087 | 1343 |
[ |
20769 | 1344 |
|lines chunk| |
16087 | 1345 |
|
22762 | 1346 |
(doPrompt and:[prompt notEmptyOrNil]) ifTrue:[ |
20935 | 1347 |
error show:prompt. |
20769 | 1348 |
]. |
16087 | 1349 |
|
20769 | 1350 |
input atEnd ifTrue:[ |
20912 | 1351 |
doPrint ifTrue:[ error cr ]. |
20769 | 1352 |
^ self. |
1353 |
]. |
|
16087 | 1354 |
|
20769 | 1355 |
input peek == $# ifTrue:[ |
1356 |
self doChunkFormat:false. |
|
1357 |
]. |
|
16087 | 1358 |
|
20769 | 1359 |
self doChunkFormat ifTrue:[ |
1360 |
input skipSeparators. |
|
1361 |
chunk := input nextChunk. |
|
1362 |
] ifFalse:[ |
|
1363 |
lines := OrderedCollection new. |
|
1364 |
[ |
|
1365 |
|line| |
|
16087 | 1366 |
|
20769 | 1367 |
line := input nextLine. |
1368 |
line notEmptyOrNil ifTrue:[ |
|
1369 |
line = '?' ifTrue:[ |
|
1370 |
self cmd_help:nil. |
|
22762 | 1371 |
doPrompt notNil ifTrue:[ |
20935 | 1372 |
error show:prompt. |
20769 | 1373 |
]. |
1374 |
] ifFalse:[ |
|
1375 |
(line startsWith:'#') ifTrue:[ |
|
1376 |
self directive:line. |
|
22762 | 1377 |
(doPrompt and:[prompt notEmptyOrNil]) ifTrue:[ |
20935 | 1378 |
error show:prompt. |
20769 | 1379 |
]. |
1380 |
] ifFalse:[ |
|
1381 |
lines add:line. |
|
1382 |
] |
|
1383 |
] |
|
1384 |
]. |
|
1385 |
line notEmptyOrNil and:[(line endsWith:$.) not]. |
|
1386 |
] whileTrue. |
|
1387 |
chunk := lines asStringWith:Character cr. |
|
1388 |
]. |
|
16087 | 1389 |
|
20890 | 1390 |
(chunk notEmptyOrNil |
1391 |
and:[chunk withoutSeparators notEmpty |
|
1392 |
and:[chunk withoutSeparators ~= '.']] |
|
1393 |
) ifTrue:[ |
|
22765 | 1394 |
self compileAndExexute:chunk with:compilerClass doPrompt:doPrompt doPrint:doPrint. |
20769 | 1395 |
]. |
16087 | 1396 |
] loop. |
1397 |
||
1398 |
" |
|
20935 | 1399 |
Smalltalk readEvalPrintLoop. |
1400 |
||
22764 | 1401 |
(ReadEvalPrintLoop new |
1402 |
doChunkFormat:false; |
|
1403 |
prompt:'>') readEvalPrintLoop |
|
16087 | 1404 |
" |
1405 |
||
1406 |
"Created: / 07-12-2006 / 17:27:21 / cg" |
|
20935 | 1407 |
"Modified: / 08-11-2016 / 22:41:47 / cg" |
16087 | 1408 |
! |
1409 |
||
22765 | 1410 |
compileAndExexute:chunk with:compilerClass doPrompt:doPrompt doPrint:doPrint |
22764 | 1411 |
"abortAll is handled, but not asked for here!!" |
1412 |
AbortAllOperationRequest handle:[:ex | |
|
1413 |
ObjectMemory sendTraceOff. |
|
1414 |
stderr nextPutLine:('Evaluation aborted.') |
|
1415 |
] do:[ |
|
1416 |
(Error, ControlInterrupt) handle:[:ex | |
|
1417 |
ObjectMemory sendTraceOff. |
|
1418 |
doPrompt ifFalse:[ |
|
1419 |
ex reject |
|
1420 |
]. |
|
1421 |
(self noDebugger |
|
1422 |
and:[ ex creator isControlInterrupt not]) ifTrue:[ |
|
1423 |
stderr showCR:('Evaluation aborted: ', ex description). |
|
1424 |
] ifFalse:[ |
|
1425 |
(self confirmDebugger not |
|
1426 |
or:[ ex creator isControlInterrupt |
|
1427 |
or:[ self askYesNo:('Error encountered: %1\Debug (y/n)? ' |
|
1428 |
withCRs bindWith:ex description)]] |
|
1429 |
) ifTrue:[ |
|
1430 |
MiniDebugger enterWithMessage:(ex errorString) mayProceed:true. |
|
1431 |
"/ if we arrive here, user typed 'c' - continue |
|
1432 |
ex mayProceed ifTrue:[ |
|
1433 |
ex proceed. |
|
1434 |
]. |
|
1435 |
]. |
|
1436 |
]. |
|
1437 |
ex return. |
|
1438 |
] do:[ |
|
1439 |
|value ms us mthd| |
|
1440 |
||
22903 | 1441 |
Class withoutUpdatingChangesDo:[ |
1442 |
mthd := compilerClass |
|
1443 |
compile:('doIt ^[',chunk,'] value') forClass:(self class) |
|
1444 |
inCategory:'doit' notifying:self |
|
1445 |
install:true. |
|
1446 |
]. |
|
22763 | 1447 |
|
22764 | 1448 |
mthd isMethod ifTrue:[ |
1449 |
traceFlag == true ifTrue:[ |
|
1450 |
[ |
|
1451 |
ObjectMemory sendTraceOn. |
|
22903 | 1452 |
value := self doIt. "/ not here now, but dynamically created |
22764 | 1453 |
] ensure:[ |
1454 |
ObjectMemory sendTraceOff. |
|
1455 |
] |
|
1456 |
] ifFalse:[ |
|
1457 |
profilingFlag == true ifTrue:[ |
|
1458 |
MessageTally spyDetailedOn:[ |
|
22903 | 1459 |
value := self doIt. "/ not here now, but dynamically created |
22764 | 1460 |
]. |
1461 |
] ifFalse:[ |
|
1462 |
us := Time microsecondsToRun:[ |
|
22903 | 1463 |
value := self doIt. "/ not here now, but dynamically created |
22764 | 1464 |
]. |
1465 |
||
1466 |
timingFlag == true ifTrue:[ |
|
1467 |
'execution time: ' printOn:stderr. |
|
1468 |
us < 1000 ifTrue:[ |
|
1469 |
us < 1 ifTrue:[ |
|
1470 |
stderr nextPutLine:'too small to measure (<1us)'. |
|
1471 |
] ifFalse:[ |
|
1472 |
stderr print:us; nextPutLine:'us'. |
|
1473 |
] |
|
1474 |
] ifFalse:[ |
|
1475 |
stderr print:((us / 1000) asFixedPoint:2); nextPutLine:'ms'. |
|
1476 |
]. |
|
1477 |
]. |
|
1478 |
]. |
|
1479 |
]. |
|
1480 |
(doPrint and:[self printFlag]) ifTrue:[ |
|
1481 |
value isVoid ifFalse:[ |
|
22765 | 1482 |
stderr nextPutAll:(self answerPrompt). |
22764 | 1483 |
stderr nextPutLine:(value displayString). |
1484 |
]. |
|
1485 |
]. |
|
1486 |
Workspace notNil ifTrue:[ |
|
1487 |
Workspace rememberResultAsWorkspaceVariable:value. |
|
1488 |
]. |
|
1489 |
]. |
|
1490 |
]. |
|
1491 |
]. |
|
22763 | 1492 |
! |
1493 |
||
10463 | 1494 |
readEvalPrintLoop |
1495 |
"{ Pragma: +optSpace }" |
|
1496 |
||
1497 |
"simple read-eval-print loop for non-graphical Minitalk. |
|
1498 |
If the chunkFormat-argument is true, chunks are read. |
|
16087 | 1499 |
Otherwise, lines up to an empty line (or EOF) are read. |
1500 |
A '#' character appearing in the first column of the first line |
|
22781 | 1501 |
switches to non-chunkMode." |
10463 | 1502 |
|
1503 |
ControlInterrupt handle:[:ex | |
|
20935 | 1504 |
self errorStream showCR:('Caught: ', ex description). |
20833 | 1505 |
self inputStream atEnd ifTrue:[ |
1506 |
ex return. |
|
1507 |
]. |
|
20933 | 1508 |
MiniDebugger enter. |
1509 |
ex proceed. |
|
1510 |
"/ ex restart. |
|
10463 | 1511 |
] do:[ |
22764 | 1512 |
|compilerClass| |
20774 | 1513 |
|
1514 |
"/ re-evaluate these in the loop, so they can be changed dynamically |
|
22764 | 1515 |
stdin := self inputStream. |
1516 |
stdout := self outputStream. |
|
1517 |
stderr := self errorStream. |
|
10463 | 1518 |
|
20774 | 1519 |
compilerClass := compiler ? Compiler ? Parser. |
1520 |
compilerClass isNil ifTrue:[ |
|
22764 | 1521 |
stderr showCR:('oops - no Compiler class found'). |
20774 | 1522 |
^ self. |
1523 |
]. |
|
1524 |
StreamError handle:[:ex | |
|
22764 | 1525 |
(stdin isOpen not or:[stdin atEnd]) ifTrue:[ |
1526 |
stderr showCR:'<EOF>'. |
|
20833 | 1527 |
ex return. |
20774 | 1528 |
]. |
22764 | 1529 |
(stdout isOpen not) ifTrue:[ |
1530 |
stderr showCR:'no output'. |
|
20774 | 1531 |
]. |
22764 | 1532 |
(stderr isOpen not) ifTrue:[ |
20774 | 1533 |
]. |
1534 |
] do:[ |
|
22764 | 1535 |
stdin signalAtEnd:true. |
22743 | 1536 |
|
20774 | 1537 |
self |
22764 | 1538 |
basicReadEvalPrintLoopWithInput:stdin output:stdout error:stderr |
22762 | 1539 |
compiler:compilerClass prompt:true print:true. |
22743 | 1540 |
|
1541 |
]. |
|
20933 | 1542 |
]. |
20935 | 1543 |
"/ self errorStream showCR:('done.'). |
10463 | 1544 |
|
1545 |
" |
|
22764 | 1546 |
(ReadEvalPrintLoop new |
1547 |
doChunkFormat:false; |
|
1548 |
prompt:'>') readEvalPrintLoop |
|
1549 |
" |
|
1550 |
||
1551 |
" |
|
20933 | 1552 |
Stdin atEnd |
1553 |
Stdin clearEOF |
|
1554 |
Smalltalk readEvalPrintLoop |
|
10463 | 1555 |
(ReadEvalPrintLoop new prompt:'>') readEvalPrintLoop |
1556 |
" |
|
1557 |
||
1558 |
"Created: / 07-12-2006 / 17:27:21 / cg" |
|
20935 | 1559 |
"Modified: / 08-11-2016 / 22:42:21 / cg" |
10248 | 1560 |
! ! |
1561 |
||
16089 | 1562 |
!ReadEvalPrintLoop methodsFor:'queries'! |
1563 |
||
1564 |
autoDefineVariables |
|
1565 |
"when evaluating with --eval, auto define any variables" |
|
1566 |
||
1567 |
^ #workspace |
|
1568 |
! ! |
|
1569 |
||
10248 | 1570 |
!ReadEvalPrintLoop class methodsFor:'documentation'! |
1571 |
||
1572 |
version |
|
19379 | 1573 |
^ '$Header$' |
13121
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
1574 |
! |
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
1575 |
|
e0cc829d4b4d
added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents:
10635
diff
changeset
|
1576 |
version_CVS |
19379 | 1577 |
^ '$Header$' |
10248 | 1578 |
! ! |
19379 | 1579 |