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