ReadEvalPrintLoop.st
author Claus Gittinger <cg@exept.de>
Mon, 07 May 2018 08:03:29 +0200
changeset 22747 4d2e4587edb1
parent 22746 a90ff4ff37c0
child 22748 c277f3ac0d33
permissions -rw-r--r--
#UI_ENHANCEMENT by cg class: ReadEvalPrintLoop changed: #cmd_help: #cmd_setOrClear:to:
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
16228
85589db2091a class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16145
diff changeset
    19
	instanceVariableNames:'inputStream outputStream errorStream compiler prompt
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
    20
		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
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
    23
		returnValuePrinting'
16228
85589db2091a class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16145
diff changeset
    24
	classVariableNames:''
85589db2091a class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16145
diff changeset
    25
	poolDictionaries:''
85589db2091a class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16145
diff changeset
    26
	category:'System-Support'
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
10249
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    29
!ReadEvalPrintLoop class methodsFor:'documentation'!
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    30
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    31
copyright
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    32
"
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    33
 COPYRIGHT (c) 2006 by eXept Software AG
16565
Claus Gittinger <cg@exept.de>
parents: 16482
diff changeset
    34
	      All Rights Reserved
10249
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    35
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    36
 This software is furnished under a license and may be used
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    37
 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
    38
 inclusion of the above copyright notice.   This software may not
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    39
 be provided or otherwise made available to, or used by, any
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    40
 other person.  No title to or ownership of the software is
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    41
 hereby transferred.
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    42
"
10461
0b2935207fec +correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents: 10277
diff changeset
    43
!
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
documentation
0b2935207fec +correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents: 10277
diff changeset
    46
"
0b2935207fec +correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents: 10277
diff changeset
    47
    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
    48
    Invoked, for example if stx is started with a --repl argument,
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    49
    or by the MiniDebugger with the 'I' command.
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    50
10628
284266d54dbe #exit only leaves the rep-loop
Claus Gittinger <cg@exept.de>
parents: 10500
diff changeset
    51
    A line starting with '?' shows the usage message.
284266d54dbe #exit only leaves the rep-loop
Claus Gittinger <cg@exept.de>
parents: 10500
diff changeset
    52
    Lines starting with '#' are directives:
22576
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
    53
        #exit           - exit the rep-loop
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
    54
        #show ...       - show various infos
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
    55
        #use package    - show various infos
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    56
        type '?' to see more.
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    57
        
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    58
    The input can be in one of two formats:
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    59
        1) traditional chunk format (bang-separated chunks, bangs duplicated)
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    60
          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
    61
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    62
        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
    63
          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
    64
          are entered linewise by a user.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    65
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    66
    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
    67
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
    68
    Try it (but only if you have a console):
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
    69
        Smalltalk readEvalPrintLoop
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
    70
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    71
    [Author:]
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    72
        Claus Gittinger
10461
0b2935207fec +correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents: 10277
diff changeset
    73
"
10249
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    74
! !
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
!ReadEvalPrintLoop methodsFor:'accessing'!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
    78
compiler:something
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    79
    "assign a compiler to use;could be used to change the language"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    80
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
    81
    compiler := something.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    84
confirmDebugger
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    85
    "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
    86
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    87
    ^ confirmDebugger ? true
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    88
!
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    89
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    90
confirmDebugger:aBoolean
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    91
    "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
    92
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    93
    confirmDebugger := aBoolean
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    94
!
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    95
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    96
debuggerUsed
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    97
    "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
    98
     you may want to write (subclass) your own ;-)"
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
    99
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   100
    ^ debuggerUsed ? MiniDebugger
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   101
!
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
debuggerUsed:aDebuggerClass
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   104
    "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
   105
     you may want to write (subclass) your own ;-)"
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
    debuggerUsed := aDebuggerClass
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
10632
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   110
doChunkFormat
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   111
    "true if currently reading chunk format"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   112
10632
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   113
    ^ doChunkFormat ? true
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   114
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   115
    "Created: / 07-12-2006 / 18:24:04 / cg"
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   116
!
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
   117
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   118
doChunkFormat:aBoolean
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   119
    "enable/disable chunk format"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   120
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   121
    doChunkFormat := aBoolean.
10254
e576d49220c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10253
diff changeset
   122
e576d49220c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10253
diff changeset
   123
    "Created: / 07-12-2006 / 18:24:04 / cg"
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   126
editorCommand
21934
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   127
    "the editor command to use with the #edit directive.
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   128
     Uses the STX_EDITOR or EDITOR shell variables' value, if defined;
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   129
     if not, the value in the classvar EDITORCOMMAND if non-nil; 
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   130
     otheriwse vi (notepad on windows)"
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   131
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   132
    |editor|
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   133
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   134
    (editor := editorCommand) isNil ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   135
        editor := OperatingSystem getEnvironment:'STX_EDITOR'.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   136
        editor isNil ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   137
            editor := OperatingSystem getEnvironment:'EDITOR'.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   138
            editor isNil ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   139
                OperatingSystem isMSWINDOWSlike ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   140
                    editor := 'notepad'.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   141
                ] ifFalse:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   142
                    editor := 'vi'.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   143
                ].    
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   144
            ].    
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   145
        ].    
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   146
    ].
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   147
    ^ editor
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   148
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   149
    "Created: / 08-11-2016 / 22:45:22 / cg"
21934
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   150
    "Modified: / 24-06-2017 / 09:54:10 / cg"
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   151
!
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   152
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   153
error:aStream
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   154
    "assign an error stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   155
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   156
    errorStream := aStream.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    "Created: / 07-12-2006 / 17:33:39 / cg"
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   161
errorStream
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   162
    "return the current error stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   163
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   164
    errorStream notNil ifTrue:[^ errorStream].
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   165
    ^ Processor activeProcess stderr
10256
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   166
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   167
    "Created: / 07-12-2006 / 19:12:27 / cg"
10256
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   168
!
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   169
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   170
input:aStream
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   171
    "assign an input stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   172
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   173
    inputStream := aStream asLineNumberReadStream.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    "Modified: / 07-12-2006 / 17:33:31 / cg"
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   178
inputStream
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   179
    "get the current input stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   180
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   181
    inputStream notNil ifTrue:[^ inputStream].
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   182
    ^ Processor activeProcess stdin
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   183
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   184
    "Created: / 07-12-2006 / 19:12:13 / cg"
10256
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   185
!
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   186
22746
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   187
noDebugger
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   188
    "true if no debugger should be activated on errors (aborts)"
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   189
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   190
    ^ noDebugger ? false
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   191
!
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   192
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   193
noDebugger:aBoolean
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   194
    "true if no debugger should be activated on errors (aborts)"
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   195
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   196
    noDebugger := aBoolean
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   197
!
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   198
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   199
output:aStream
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   200
    "assign an output stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   201
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   202
    outputStream := aStream.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    "Created: / 07-12-2006 / 17:27:48 / cg"
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   207
outputStream
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   208
    "return the current output stream"
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   209
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   210
    outputStream notNil ifTrue:[^ outputStream].
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   211
    ^ Processor activeProcess stdout
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   212
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   213
    "Created: / 07-12-2006 / 19:12:27 / cg"
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   214
!
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   215
22743
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   216
printFlag
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   217
    "true if the return value of expressions should be printed"
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   218
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   219
    ^ printFlag ? true
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   220
!
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   221
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   222
printFlag:aBoolean
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   223
    "true if the return value of expressions should be printed"
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   224
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   225
    printFlag := aBoolean
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   226
!
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   227
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   228
prompt:aString
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   229
    "set the prompt"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   230
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   231
    prompt := aString.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
! !
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
10631
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   234
!ReadEvalPrintLoop methodsFor:'compiler interface-error handling'!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   235
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   236
correctableError:message position:pos1 to:pos2 from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   237
    "compiler notifies us of an error - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   238
15702
01c33c1f4990 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 15365
diff changeset
   239
    ^ false "/ no correction
10631
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   240
!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   241
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   242
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   243
    "compiler notifies us of a warning - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   244
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   245
    ^ false
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   246
!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   247
13121
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   248
correctableWarning:message position:pos1 to:pos2 from:aCompiler
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   249
    "compiler notifies us of an error - ignore it"
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   250
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   251
    ^ false
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   252
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   253
    "Created: / 02-11-2010 / 13:29:22 / cg"
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   254
!
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   255
10631
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   256
error:aString position:relPos to:relEndPos from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   257
    "compiler notifies us of a warning - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   258
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   259
    ^ false
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   260
!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   261
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   262
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   263
    "compiler notifies us of a warning - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   264
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   265
    ^ false
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   266
!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   267
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   268
warning:aString position:relPos to:relEndPos from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   269
    "compiler notifies us of a warning - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   270
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   271
    ^ self
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   272
! !
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   273
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   274
!ReadEvalPrintLoop methodsFor:'directives'!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   275
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   276
askYesNo:message
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   277
    self errorStream show:message.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   278
    ^ (self inputStream nextLine withoutSeparators startsWith:'y').
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   279
!
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   280
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   281
cmd_apropos:lineStream
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   282
    "apropos directive; i.e.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   283
        #apropos collection [;more]
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   284
    "
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   285
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   286
    |words classNamesMatching selectorsMatching showList|
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   287
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   288
    lineStream skipSeparators.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   289
    words := lineStream upToEnd asCollectionOfSubstringsSeparatedBy:$;.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   290
    words := words select:[:each | each notEmpty].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   291
    words := words select:[:each | each isBlank not].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   292
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   293
    (words isEmpty) ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   294
        self errorStream showCR:'? usage: #apropos <word> [; morewords]'.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   295
        ^ self.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   296
    ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   297
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   298
    "/ search in classes:
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   299
    classNamesMatching := Smalltalk allClasses 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   300
                            select:[:cls | 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   301
                                cls isPrivate not
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   302
                                and:[ words conform:[:word | 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   303
                                        cls name matches:word caseSensitive:false]]]
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   304
                            thenCollect:#name.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   305
    "/ search in method names:
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   306
    selectorsMatching := (Smalltalk allClasses
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   307
                            collectAll:[:cls |
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   308
                                cls isPrivate 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   309
                                    ifTrue:[#()]
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   310
                                    ifFalse:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   311
                                        cls selectors 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   312
                                            select:[:sel |
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   313
                                                words conform:[:word | 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   314
                                                    sel matches:word caseSensitive:false]]]]
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   315
                         ) asSet.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   316
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   317
    showList :=
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   318
        [:list :listName |
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   319
            |showIt sortedList longest limit numCols|
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   320
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   321
            showIt := true.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   322
            list notEmpty ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   323
                list size > 20 ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   324
                    showIt := self askYesNo:( 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   325
                        'apropos: there are %1 matching %2; list them all (y/n)? '
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   326
                            bindWith:list size
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   327
                            with:listName)
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   328
                ] ifFalse:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   329
                    self errorStream showCR:'matching %1:' with:listName.  
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   330
                ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   331
                showIt ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   332
                    sortedList := list asOrderedCollection sort.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   333
                    longest := (list collect:[:nm | nm size]) max.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   334
                    limit := 78.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   335
                    numCols := (80 // (longest min:limit)) max:1.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   336
                    sortedList slicesOf:numCols do:[:eachGroupOfN |
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   337
                        self errorStream
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   338
                            spaces:2;
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   339
                            nextPutLine:(
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   340
                                (eachGroupOfN 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   341
                                    collect:[:nm | 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   342
                                        (nm contractTo:limit) paddedTo:limit
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   343
                                    ] 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   344
                                ) asStringWith:' ').
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   345
                    ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   346
                ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   347
            ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   348
        ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   349
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   350
    showList value:classNamesMatching value:'classes'.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   351
    showList value:selectorsMatching value:'method names'.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   352
    "
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   353
     self basicNew 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   354
        input:Stdin;
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   355
        cmd_apropos:'Array' readStream
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   356
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   357
     self basicNew 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   358
        input:Stdin;
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   359
        cmd_apropos:'at:' readStream
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
     self basicNew 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   362
        input:Stdin;
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   363
        cmd_apropos:'*at:' readStream
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
!
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   366
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   367
cmd_clear:lineStream
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   368
    self cmd_setOrClear:lineStream to:false
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   369
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   370
    "Created: / 07-12-2006 / 19:04:50 / cg"
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   371
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   372
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   373
cmd_debug:lineStream
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   374
    MiniDebugger enter.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   375
!
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   376
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   377
cmd_edit:lineStream
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   378
    "edit a class or selector in an external editor"
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   379
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   380
    |errStream classOrMethodName cls methodName selector 
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   381
     code isNewClass editFullClass tmpFile modifiedTime|
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   382
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   383
    errStream := self errorStream.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   384
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   385
    isNewClass := editFullClass := false.
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   386
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   387
    lineStream skipSeparators.
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   388
    lineStream atEnd ifTrue:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   389
        cls := lastEditedClass.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   390
        methodName := lastEditedSelector.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   391
    ] ifFalse:[    
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   392
        classOrMethodName := lineStream 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   393
                                upToElementForWhich:[:ch | 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   394
                                    ch isLetterOrDigit not and:[ch ~~ $_]
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   395
                                ].
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   396
        "/ 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   397
        (classOrMethodName isUppercaseFirst) ifTrue:[ 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   398
            (cls := Smalltalk classNamed:classOrMethodName) isNil ifTrue:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   399
                errStream show:'edit: no such class: ',classOrMethodName,' ; create (y/n)? '.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   400
                (self inputStream nextLine withoutSeparators startsWith:'y') ifFalse:[^ self].
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   401
                isNewClass := true.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   402
                code := 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   403
'"/ change the code as required, then save and exit the editor.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   404
"/ To cancel this edit, leave the editor WITHOUT saving.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   405
"/
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   406
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   407
Object
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   408
  subclass:#%1
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   409
  instanceVariableNames:''''
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   410
  classVariableNames:''''
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   411
  poolDictionaries:''''
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   412
  category:''user classes''
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   413
'                   bindWith:classOrMethodName.
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   414
            ] ifFalse:[ 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   415
                lineStream skipSeparators.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   416
                lineStream atEnd ifFalse:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   417
                    methodName := lineStream upToSeparator.
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   418
                    methodName = 'class' ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   419
                        cls := cls theMetaclass.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   420
                        lineStream skipSeparators.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   421
                        methodName := lineStream upToSeparator.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   422
                    ].
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   423
                ].
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   424
            ].
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   425
        ] ifFalse:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   426
            methodName := classOrMethodName   
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   427
        ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   428
    ].
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   429
    
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   430
    isNewClass ifFalse:[
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   431
        cls := cls ? lastEditedClass.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   432
        cls isNil ifTrue:[
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   433
            errStream showCR:'edit usage:'.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   434
            errStream showCR:'   #edit className selector'.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   435
            errStream showCR:'   #edit className '.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   436
            errStream showCR:'   #edit selector (class as in previous edit)'.
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   437
            errStream showCR:'   #edit          (class/method as in previous edit)'.
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   438
            ^ self.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   439
        ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   440
        lastEditedClass := cls.
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   441
        lastEditedSelector := methodName.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   442
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   443
        methodName isNil ifTrue:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   444
            editFullClass := true.
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   445
            code := cls source asString
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   446
        ] ifFalse:[    
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   447
            ((selector := methodName asSymbolIfInterned) isNil 
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   448
            or:[ (cls implements:selector) not]) ifTrue:[
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   449
                (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
   450
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   451
                code := 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   452
'"/ change the code as required, then save and exit the editor.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   453
"/ To cancel this edit, leave the editor WITHOUT saving.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   454
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   455
%1
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   456
    "this is a new method"
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   457
    self halt
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   458
'                   bindWith:methodName.
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   459
            ] ifFalse:[
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   460
                code := (cls compiledMethodAt:selector) source.
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   461
            ].    
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   462
        ].    
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   463
    ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   464
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   465
    [
20936
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   466
        |ok cmd|
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   467
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   468
        tmpFile := Filename newTemporary.
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   469
        tmpFile contents:code.
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   470
        modifiedTime := tmpFile modificationTime.
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   471
20936
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   472
        cmd := '%1 "%2"'.
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   473
        OperatingSystem isUNIXlike ifTrue:[
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   474
            cmd := '%1 "%2" </dev/tty'.
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   475
        ].
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   476
        
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   477
        ok := OperatingSystem 
20936
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   478
                executeCommand:(cmd bindWith:(self editorCommand) with:tmpFile pathName)
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   479
                inputFrom:Stdin 
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   480
                outputTo:Stdout 
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   481
                errorTo:Stderr
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   482
                auxFrom:nil
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   483
                environment:nil
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   484
                inDirectory:nil
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   485
                lineWise:false
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   486
                newPgrp:false
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   487
                showWindow:true
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   488
                onError:[:status | false].
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   489
                
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   490
        (ok and:[tmpFile modificationTime ~= modifiedTime]) ifTrue:[
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   491
            isNewClass ifTrue:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   492
                Compiler evaluate:tmpFile contentsOfEntireFile.    
20937
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   493
                errStream showCR:'Class (re)defined.'
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   494
            ] ifFalse:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   495
                editFullClass ifTrue:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   496
                    tmpFile fileIn.
20937
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   497
                    errStream showCR:'Class (re)compiled.'
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   498
                ] ifFalse:[    
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   499
                    cls compile:tmpFile contentsOfEntireFile classified:'*as yet uncategorized'.    
20937
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   500
                    errStream showCR:'Method (re)compiled.'
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   501
                ].    
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   502
            ].    
20937
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   503
        ] ifFalse:[
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   504
            errStream showCR:'No change.'
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   505
        ].    
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   506
    ] ensure:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   507
        tmpFile notNil ifTrue:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   508
            tmpFile remove
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   509
        ]
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   510
    ].
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   511
    
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   512
    "
20934
36e46558156d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20933
diff changeset
   513
     Smalltalk readEvalPrintLoop
36e46558156d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20933
diff changeset
   514
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   515
     self new 
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   516
        input:Stdin;
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   517
        cmd_edit:'MyClass foo' readStream
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   518
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   519
     self new 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   520
        input:Stdin;
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   521
        cmd_edit:'Array class new:' readStream
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   522
    "
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   523
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   524
    "Modified: / 08-11-2016 / 22:46:12 / cg"
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   525
!
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   526
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   527
cmd_exit:lineStream
22576
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
   528
    "exit directive - leaves the repl"
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
   529
10628
284266d54dbe #exit only leaves the rep-loop
Claus Gittinger <cg@exept.de>
parents: 10500
diff changeset
   530
    exitAction value
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   531
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   532
    "Created: / 07-12-2006 / 18:55:46 / cg"
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   533
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   534
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   535
cmd_help:lineStream
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   536
    self errorStream
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   537
        nextPutAll:
16084
8fc6fc71a8cb class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16081
diff changeset
   538
'Everything entered up to an empty line or a line ending in "." is called a "chunk" and evaluated.
22742
4ca48fa9c122 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22741
diff changeset
   539
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
   540
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   541
Valid commands are:
10635
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   542
    #help ............... this text
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   543
    #exit ............... exit interpreter loop
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   544
    #use <package>....... use (load) a package
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   545
        stx:libwidg .............. GUI package
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   546
        stx:libtool .............. IDE tool package
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   547
        stx:goodies/regex ........ regex package
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   548
        stx:goodies/petitparser .. peg parser package
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   549
    #read <filename>..... read another script or source file
10635
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   550
    #show <what> ........ show info
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   551
        variables .......... interpreter variables
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   552
        processes .......... processes
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   553
        memory ............. memory usage
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   554
        flags .............. flags
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   555
        modules ............ loaded modules
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   556
        packages ........... available packages to load
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   557
        all ................ all of the above
10635
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   558
    #set/clear <flag> ... set or clear a flag
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   559
        trace .............. tracing execution
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   560
        timing ............. timing execution
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   561
        profiling .......... show execution profile
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   562
        chunkFormat ........ traditional bang chunk format input mode
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   563
        editor ............. command used with #edit directive
22747
4d2e4587edb1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22746
diff changeset
   564
        noDebugger ......... no debugger on error
4d2e4587edb1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22746
diff changeset
   565
        confirmDebugger .... ask for debugger on error
22743
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   566
        print .............. print return values
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   567
    #debug ................. enter a MiniDebugger
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   568
    #edit <what> ........ open an external editor 
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   569
        class .............. on a class
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   570
        class selector ..... on a method
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   571
        <empty> ............ on previously edited method/last class
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   572
    #apropos word ....... list classes/selectors matching word
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   573
    #list <what> ........ show source
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   574
        class .............. class definition and comment
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   575
        class selector ..... method source
10257
2bc06451585b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10256
diff changeset
   576
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   577
The MiniDebugger (if entered) shows its own help with "?".
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   578
'
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   579
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   580
    "Created: / 07-12-2006 / 18:54:20 / cg"
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   581
    "Modified: / 08-11-2016 / 22:53:53 / cg"
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   582
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   583
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   584
cmd_list:lineStream
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   585
    "list directive; i.e.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   586
        #list <classname> ['class'] <selector>
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   587
    "
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   588
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   589
    |class selector source errStream|
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   590
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   591
    errStream := self errorStream.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   592
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   593
    (self 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   594
        getClassNameAndSelectorFrom:lineStream 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   595
        into:[:classArg :selectorArg |
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   596
            class := classArg.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   597
            selector := selectorArg.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   598
        ]) ifFalse:[^ self].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   599
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   600
    selector isNil ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   601
        errStream nextPutAll:(class definition).
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   602
        errStream nextPutAll:(class commentOrDocumentationString).
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   603
    ] ifFalse:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   604
        source := class sourceCodeAt:selector asSymbol.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   605
        source isEmptyOrNil ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   606
            errStream nextPutLine:'Sorry, no sourcecode found'
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   607
        ] ifFalse:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   608
            errStream nextPutAll:source
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   609
        ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   610
    ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   611
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   612
    "
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   613
     self basicNew 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   614
        input:Stdin;
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   615
        cmd_list:'Array' readStream
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   616
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   617
     self basicNew 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   618
        input:Stdin;
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   619
        cmd_list:'Array at:put:' readStream
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   620
    "
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   621
!
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   622
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   623
cmd_read:lineStream
22577
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   624
    "read directive; i.e.
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   625
        #read scriptFile
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   626
    "
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   627
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
   628
    |filename newInput savedPrompt savedPrint savedInput savedCurrentDirectory savedDoChunkFormat|
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   629
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   630
    lineStream skipSeparators.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   631
    filename := lineStream upToEnd withoutSeparators.
22577
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   632
    filename isEmptyOrNil ifTrue:[
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   633
        self errorStream showCR:'? usage: #read <filename>'.
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   634
        ^ self.
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   635
    ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   636
20915
f7ef8fa16261 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20914
diff changeset
   637
    currentDirectory := currentDirectory ? (Filename currentDirectory).
f7ef8fa16261 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20914
diff changeset
   638
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   639
    filename := filename asFilename.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   640
    filename isAbsolute ifFalse:[
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   641
        filename := currentDirectory construct:filename.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   642
    ].
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   643
20922
26a835f3689a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20920
diff changeset
   644
    StreamError ignoreIn:[
26a835f3689a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20920
diff changeset
   645
        newInput := filename readStream.
26a835f3689a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20920
diff changeset
   646
    ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   647
    newInput isNil ifTrue:[
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   648
        self errorStream showCR:('Could not find file: "',filename pathName,'"').
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   649
        ^ self.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   650
    ].
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   651
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   652
    [
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   653
        savedCurrentDirectory := currentDirectory.
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
   654
        savedDoChunkFormat := doChunkFormat.
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   655
        savedInput := inputStream.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   656
        savedPrint := printFlag.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   657
        savedPrompt := prompt.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   658
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   659
        currentDirectory := filename directory.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   660
        inputStream := newInput.
20910
d97034358023 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20909
diff changeset
   661
        
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   662
        self
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   663
            basicReadEvalPrintLoopWithInput:newInput
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   664
            output:outputStream
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   665
            error:errorStream
20910
d97034358023 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20909
diff changeset
   666
            compiler:(compiler ? Compiler ? Parser)
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   667
            prompt:false
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   668
            print:false.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   669
    ] ensure:[
20914
79b75bb6f696 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20913
diff changeset
   670
        newInput close.
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
   671
        doChunkFormat := savedDoChunkFormat.
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   672
        currentDirectory := savedCurrentDirectory.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   673
        inputStream := savedInput.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   674
        printFlag := savedPrint.
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
   675
        prompt := savedPrompt.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   676
    ].
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   677
!
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   678
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   679
cmd_set:lineStream
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   680
    self cmd_setOrClear:lineStream to:true
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   681
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   682
    "Modified: / 07-12-2006 / 19:04:46 / cg"
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   683
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   684
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   685
cmd_setOrClear:lineStream to:aBoolean
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   686
    "set/clear one of my internal flags"
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   687
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   688
    |what|
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   689
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   690
    lineStream skipSeparators.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   691
    what := lineStream nextAlphaNumericWord.
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   692
    what notNil ifTrue:[
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   693
        (what startsWith:'tra') ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   694
            traceFlag := aBoolean.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   695
            ^ self.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   696
        ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   697
        (what startsWith:'tim') ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   698
            timingFlag := aBoolean.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   699
            ^ self.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   700
        ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   701
        (what startsWith:'pro') ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   702
            profilingFlag := aBoolean.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   703
            ^ self.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   704
        ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   705
        (what startsWith:'chunk') ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   706
            doChunkFormat := aBoolean.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   707
            ^ self.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   708
        ].
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   709
        (what startsWith:'edi') ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   710
            aBoolean ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   711
                "/ set editor cmd
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   712
                lineStream skipSeparators.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   713
                editorCommand := lineStream upToEnd.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   714
            ] ifFalse:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   715
                editorCommand := nil.
20938
9532ecca5967 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20937
diff changeset
   716
            ].
9532ecca5967 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20937
diff changeset
   717
            ^ self.
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   718
        ].
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   719
        (what startsWith:'con') ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   720
            confirmDebugger := aBoolean.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   721
            ^ self.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   722
        ].
22747
4d2e4587edb1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22746
diff changeset
   723
        (what startsWith:'node') ifTrue:[
4d2e4587edb1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22746
diff changeset
   724
            noDebugger := aBoolean.
22746
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   725
            ^ self.
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   726
        ].
22743
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   727
        (what startsWith:'pri') ifTrue:[
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   728
            printFlag := aBoolean.
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   729
            ^ self.
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   730
        ].
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   731
    ].
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   732
    self errorStream 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   733
        showCR:'? usage: set/clear <flag>';
22743
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
   734
        showCR:'? (<flag> must be one of: trace, times, profile, chunk, editor, confirmDebug, print)'.
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   735
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   736
    "Modified: / 08-11-2016 / 22:49:17 / cg"
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   737
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   738
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   739
cmd_show:lineStream
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   740
    "show directive:
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   741
        show packages
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   742
        show modules (= loaded packages)
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   743
        show variables 
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   744
        etc.
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   745
    "
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   746
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   747
    |errStream what showAll ok|
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   748
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   749
    errStream := self errorStream.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   750
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   751
    lineStream skipSeparators.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   752
    what := lineStream nextAlphaNumericWord.
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   753
    ok := false.
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   754
    
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   755
    what notNil ifTrue:[
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   756
        showAll := (what startsWith:'all').
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   757
        
20835
ce8d50491138 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20834
diff changeset
   758
        (showAll or:[ what startsWith:'var' ]) ifTrue:[                      
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   759
            errStream showCR:'Variables:'; showCR:'----------'.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   760
            self showVariables.
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   761
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   762
        ].
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   763
        
20835
ce8d50491138 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20834
diff changeset
   764
        (showAll or:[ what startsWith:'proc' ]) ifTrue:[                    
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   765
            errStream cr; showCR:'Threads:'; showCR:'--------'.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   766
            MiniDebugger basicNew showProcesses.
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   767
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   768
        ].
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   769
        
20902
342c68aa8e9a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20901
diff changeset
   770
        ("showAll or:[" what startsWith:'pack' "]") ifTrue:[                    
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   771
            errStream cr; showCR:'Available Packages:'; showCR:'--------'.
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   772
            self showPackages.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   773
            ok := true.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   774
        ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   775
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   776
        (showAll or:[ what startsWith:'mod' ]) ifTrue:[
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   777
            errStream cr; showCR:'Modules:'; showCR:'--------'.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   778
            self showModules.
13865
8a42d5528cc4 changed:
Claus Gittinger <cg@exept.de>
parents: 13859
diff changeset
   779
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   780
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   781
        ].
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   782
        
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   783
        (showAll or:[ what startsWith:'mem' ]) ifTrue:[
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   784
            |allMem|
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   785
            
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   786
            errStream cr; showCR:'Memory:'; showCR:'-------'.
20891
8d94557ec419 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20890
diff changeset
   787
            "/ allMem := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed
8d94557ec419 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20890
diff changeset
   788
            "/                                     + ObjectMemory newSpaceUsed.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   789
            errStream
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   790
                "/ showCR:('overall: ',(allMem // 1024) printString,' Kb');
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   791
                showCR:('used   : ',(ObjectMemory bytesUsed // 1024) printString,' Kb');
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   792
                showCR:('free   : ',(ObjectMemory freeSpace // 1024) printString,' Kb');
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   793
                show:('minorGC: ',(ObjectMemory scavengeCount) printString);
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   794
                showCR:(' majorGC: ',(ObjectMemory garbageCollectCount) printString).
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   795
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   796
        ].
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   797
        
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   798
        (showAll or:[ what startsWith:'flag' ]) ifTrue:[
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   799
            errStream cr; showCR:'Flags:'; showCR:'------'.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   800
            errStream
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   801
                showCR:('trace :      ',(traceFlag ? false) printString);
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   802
                showCR:('timing:      ',(timingFlag ? false) printString);
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   803
                showCR:('profiling:   ',(profilingFlag ? false) printString);
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   804
                showCR:('chunkFormat: ',(doChunkFormat ? false) printString);
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   805
                showCR:('editor:      ',self editorCommand printString);
22746
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
   806
                showCR:('noDebug:     ',self noDebugger printString);
22745
bce35bb4a72f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22744
diff changeset
   807
                showCR:('confirmDebug:',self confirmDebugger printString);
bce35bb4a72f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22744
diff changeset
   808
                showCR:('print:       ',self printFlag printString).
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   809
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   810
        ].
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   811
    ].
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   812
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   813
    ok ifFalse:[
22576
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
   814
        errStream showCR:'? usage: show <what>'.
22577
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   815
        errStream 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
   816
    ].
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   817
    
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   818
    "
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   819
     self basicNew cmd_show:'packages' readStream
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   820
    "
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   821
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   822
    "Modified: / 08-11-2016 / 22:46:51 / cg"
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   823
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   824
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   825
cmd_use:lineStream
22574
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   826
    "use directive; i.e.
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   827
        #use stx:goodies/xml
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   828
        #use exept:mqtt
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   829
    "
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   830
16145
8687a6524d21 class: ReadEvalPrintLoop
Stefan Vogel <sv@exept.de>
parents: 16133
diff changeset
   831
    |pkg|
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   832
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   833
    lineStream skipSeparators.
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   834
    pkg := lineStream upToEnd.
22736
db668a5e0106 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22735
diff changeset
   835
    (pkg isEmptyOrNil or:[(pkg := pkg withoutSeparators) isEmpty]) ifTrue:[
22577
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   836
        self errorStream showCR:'? usage: #use <package>'.
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   837
        ^ self.
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   838
    ].
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   839
16145
8687a6524d21 class: ReadEvalPrintLoop
Stefan Vogel <sv@exept.de>
parents: 16133
diff changeset
   840
    [
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   841
        Smalltalk loadPackage:pkg.
16145
8687a6524d21 class: ReadEvalPrintLoop
Stefan Vogel <sv@exept.de>
parents: 16133
diff changeset
   842
    ] on:PackageLoadError do:[:ex|
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   843
        "/ allow for some shortcuts...
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   844
        (pkg includes:$:) ifTrue:[
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   845
            self errorStream showCR:('Failed to load package: "',pkg,'"').
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   846
        ] ifFalse:[
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   847
            "/ try stx standard package
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   848
            pkg := 'stx:', pkg.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   849
            ex restart.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   850
        ].
13852
4bdc4f1dc3e3 changed: #cmd_use:
Claus Gittinger <cg@exept.de>
parents: 13768
diff changeset
   851
    ].
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   852
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   853
    "Created: / 07-12-2006 / 19:07:56 / cg"
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   854
!
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   855
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   856
directive:line
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   857
    |s cmd|
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   858
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   859
    s := line readStream.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   860
    s next. "/ skip the hash
20913
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   861
    s peek == $!! ifTrue:[
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   862
        "/ skip shebang line 
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   863
        ^ self.
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   864
    ].    
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   865
    s skipSeparators.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   866
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   867
    cmd := s nextAlphaNumericWord.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   868
    cmd notNil ifTrue:[
20919
3c3e236e39d7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20918
diff changeset
   869
        AbortAllOperationRequest handle:[:ex |
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   870
            self errorStream showCR:('Directive aborted: ', ex description)
20919
3c3e236e39d7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20918
diff changeset
   871
        ] do:[
20920
41aec62f6587 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20919
diff changeset
   872
            Error handle:[:ex |
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   873
                self errorStream showCR:('Caught in directive: ', ex description).
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   874
                ex suspendedContext fullPrintAll.
20919
3c3e236e39d7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20918
diff changeset
   875
            ] do:[    
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   876
                ControlInterrupt handle:[:ex |
20936
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   877
                    MiniDebugger enter.
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   878
                    "/ self errorStream showCR:('Ignored in directive: ', ex description).
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   879
                    "/ ex reject. 
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   880
                    "/ ex proceed. 
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   881
                ] do:[    
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   882
                    self
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   883
                        perform:('cmd_',cmd) asMutator with:s
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   884
                        ifNotUnderstood:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   885
                            self errorStream
22739
d39b0b0008ce #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 22738
diff changeset
   886
                                showCR:'?? invalid command: %1. Type "#help" for help.' with:cmd.
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   887
                        ].
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   888
                ].
20913
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   889
            ].
20919
3c3e236e39d7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20918
diff changeset
   890
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   891
    ].
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   892
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   893
    "Created: / 07-12-2006 / 18:49:17 / cg"
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   894
    "Modified: / 08-11-2016 / 21:59:16 / cg"
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   895
!
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   896
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   897
getClassNameAndSelectorFrom:lineStream into:aBlock
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   898
    "a helper for list and edit; parses class and selector name.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   899
     returns false if nothing reasonable was entered"
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   900
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   901
    |words wordStream className class selector|
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   902
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   903
    lineStream skipSeparators.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   904
    words := lineStream upToEnd asCollectionOfWords.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   905
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   906
    (words isEmpty) ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   907
        ^ false.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   908
    ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   909
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   910
    wordStream := words readStream.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   911
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   912
    "/ search in classes:
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   913
    className := wordStream next.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   914
    class := Smalltalk classNamed:className.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   915
    class isNil ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   916
        self errorStream showCR:'no such class: ',className.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   917
        ^ false.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   918
    ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   919
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   920
    (wordStream atEnd not and:[wordStream peek = 'class']) ifTrue:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   921
        wordStream next.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   922
        class := class theMetaclass
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   923
    ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   924
    (wordStream atEnd) ifFalse:[
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   925
        selector := wordStream next.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   926
    ].
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   927
    aBlock value:class value:selector.
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   928
    ^ true
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   929
!
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
   930
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   931
showModules
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   932
    |errStream printModule|
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   933
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   934
    errStream := self errorStream.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   935
    
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   936
    printModule :=
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   937
        [:mod |
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   938
            errStream
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   939
                show:'  ';
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   940
                show:(mod package "libraryName");
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   941
                showCR:' (',(mod type),')'.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   942
        ].
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   943
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   944
    errStream nextPutLine:'builtIn:'.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   945
    ((ObjectMemory binaryModuleInfo
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   946
        reject:[:m | m dynamic])
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   947
            asSortedCollection:[:a :b | a name < b name]) do:printModule.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   948
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   949
    errStream nextPutLine:'dynamic:'.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   950
    ((ObjectMemory binaryModuleInfo
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   951
        select:[:m | m dynamic])
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   952
            asSortedCollection:[:a :b | a name < b name]) do:printModule.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   953
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   954
    "
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   955
     ReadEvalPrintLoop basicNew showModules
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   956
    "
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   957
!
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   958
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   959
showPackages
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   960
    |all|
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   961
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   962
    all := Set new.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   963
    Smalltalk knownLoadablePackagesDo:[:packageID :type :path |
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   964
        all add:packageID
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   965
    ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   966
    all := all asOrderedCollection sort.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   967
    all do:[:eachPackage |
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   968
        self errorStream show:eachPackage.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   969
        (Smalltalk isPackageLoaded:eachPackage) ifTrue:[
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   970
            self errorStream show:' (loaded)'.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   971
        ].    
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   972
        self errorStream cr.
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   973
    ].    
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   974
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   975
    "
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   976
     ReadEvalPrintLoop basicNew showPackages
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   977
     ReadEvalPrintLoop basicNew showModules
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   978
    "
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   979
!
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   980
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   981
showVariables
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   982
    Workspace notNil ifTrue:[
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   983
        Workspace workspaceVariables keys asOrderedCollection sort do:[:nm |
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   984
            |holder|
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   985
            holder := Workspace workspaceVariables at:nm.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   986
            self errorStream 
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   987
                show:nm;  
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   988
                show:' -> '; 
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   989
                showCR:holder value printString.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   990
        ].
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   991
    ].
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   992
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   993
    "
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   994
     ReadEvalPrintLoop basicNew showVariables
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   995
    "
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   996
! !
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   997
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
!ReadEvalPrintLoop methodsFor:'evaluation'!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
16565
Claus Gittinger <cg@exept.de>
parents: 16482
diff changeset
  1000
basicReadEvalPrintLoopWithInput:input output:output error:error
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1001
    compiler:compilerClass prompt:prompt print:doPrint
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1002
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1003
    "{ Pragma: +optSpace }"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1004
22735
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
  1005
    "the core of the interpreter loop; 
15ce04593d54 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22577
diff changeset
  1006
     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
  1007
     If chunkFormat is true, chunks are read.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1008
     Otherwise, lines up to an empty line (or EOF) or a line ending in '.' are read.
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1009
     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
  1010
     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
  1011
20911
1c11be64f4a1 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20910
diff changeset
  1012
    exitAction := [^ self].
1c11be64f4a1 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20910
diff changeset
  1013
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1014
    [
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1015
        |lines chunk|
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1016
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1017
        prompt notNil ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1018
            error show:prompt.
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1019
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1020
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1021
        input atEnd ifTrue:[
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
  1022
            doPrint ifTrue:[ error cr ].
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1023
            ^ self.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1024
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1025
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1026
        input peek == $# ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1027
            self doChunkFormat:false.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1028
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1029
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1030
        self doChunkFormat ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1031
            input skipSeparators.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1032
            chunk := input nextChunk.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1033
        ] ifFalse:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1034
            lines := OrderedCollection new.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1035
            [
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1036
                |line|
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1037
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1038
                line := input nextLine.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1039
                line notEmptyOrNil ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1040
                    line = '?' ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1041
                        self cmd_help:nil.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1042
                        prompt notNil ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1043
                            error show:prompt.
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1044
                        ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1045
                    ] ifFalse:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1046
                        (line startsWith:'#') ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1047
                            self directive:line.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1048
                            prompt notNil ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1049
                                error show:prompt.
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1050
                            ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1051
                        ] ifFalse:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1052
                            lines add:line.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1053
                        ]
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1054
                    ]
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1055
                ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1056
                line notEmptyOrNil and:[(line endsWith:$.) not].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1057
            ] whileTrue.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1058
            chunk := lines asStringWith:Character cr.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1059
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1060
20890
935d14488b6d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20845
diff changeset
  1061
        (chunk notEmptyOrNil 
935d14488b6d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20845
diff changeset
  1062
          and:[chunk withoutSeparators notEmpty
935d14488b6d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20845
diff changeset
  1063
          and:[chunk withoutSeparators ~= '.']]
935d14488b6d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20845
diff changeset
  1064
        ) ifTrue:[
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1065
            "abortAll is handled, but not asked for here!!"
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1066
            AbortAllOperationRequest handle:[:ex |
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1067
                error nextPutLine:('Evaluation aborted: ', ex description)
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1068
            ] do:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1069
                (Error, ControlInterrupt) handle:[:ex |
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1070
                    prompt isNil ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1071
                        ex reject
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1072
                    ].
22746
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
  1073
                    self noDebugger ifTrue:[
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
  1074
                        ex creator isControlInterrupt ifFalse:[
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
  1075
                            ex return
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
  1076
                        ]
a90ff4ff37c0 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22745
diff changeset
  1077
                    ].
22738
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1078
                    (self confirmDebugger not
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1079
                    or:[ ex creator isControlInterrupt
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1080
                    or:[ self askYesNo:('Error encountered: %1\Debug? '
22743
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
  1081
                                        withCRs bindWith:ex description)]]
22738
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1082
                    ) ifTrue:[
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1083
                        MiniDebugger enterWithMessage:(ex errorString) mayProceed:true.
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1084
                        "/ if we arrive here, user typed 'c' - continue
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1085
                        ex mayProceed ifTrue:[
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1086
                            ex proceed.
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1087
                        ].
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1088
                    ].
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1089
                    error showCR:('Evaluation aborted: ', ex description).
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1090
                    ex return.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1091
                ] do:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1092
                    |value ms us|
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1093
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1094
                    profilingFlag == true ifTrue:[ 
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1095
                        MessageTally spyDetailedOn:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1096
                            value := (compilerClass new requestor:self) 
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1097
                                        evaluate:chunk
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1098
                                        compile:true.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1099
                        ].    
22744
094f84acd701 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22743
diff changeset
  1100
                        (doPrint and:[self printFlag]) ifTrue:[
22741
21d4356fc5a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22740
diff changeset
  1101
                            '-> (Return value): ' print.
22740
1511ab65828f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22739
diff changeset
  1102
                            value displayString printOn:output. output cr.
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1103
                            output flush.
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1104
                        ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1105
                    ] ifFalse:[    
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1106
                        us := Time microsecondsToRun:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1107
                            value := (compilerClass new requestor:self)
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1108
                                        evaluate:chunk compile:true.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1109
                        ].
22744
094f84acd701 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22743
diff changeset
  1110
                        (doPrint and:[self printFlag]) ifTrue:[
20949
14f5982c2aee #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20938
diff changeset
  1111
                            value isVoid ifFalse:[
22741
21d4356fc5a8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22740
diff changeset
  1112
                                '-> (Return value): ' print.
22740
1511ab65828f #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22739
diff changeset
  1113
                                value displayString printOn:output. output cr.
22738
0de46478c392 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22736
diff changeset
  1114
                                output flush.
20949
14f5982c2aee #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20938
diff changeset
  1115
                            ].
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1116
                        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1117
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1118
                        timingFlag == true ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1119
                            'execution time: ' printOn:error.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1120
                            us < 1000 ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1121
                                us < 1 ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1122
                                    'too small to measure (<1us)' printOn:error.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1123
                                ] ifFalse:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1124
                                    us printOn:output. 'us' printOn:error.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1125
                                ]
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1126
                            ] ifFalse:[
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1127
                                ((us / 1000) asFixedPoint:2) printOn:output. 'ms' printOn:error.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1128
                            ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
  1129
                            error cr.
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1130
                        ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1131
                    ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1132
                    Workspace notNil ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1133
                        Workspace rememberResultAsWorkspaceVariable:value.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1134
                    ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1135
                ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1136
            ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
  1137
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1138
    ] loop.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1139
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1140
    "
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1141
     Smalltalk readEvalPrintLoop.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1142
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1143
     (ReadEvalPrintLoop new prompt:'>') readEvalPrintLoop
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1144
    "
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1145
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1146
    "Created: / 07-12-2006 / 17:27:21 / cg"
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1147
    "Modified: / 08-11-2016 / 22:41:47 / cg"
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1148
!
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1149
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1150
readEvalPrintLoop
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1151
    "{ Pragma: +optSpace }"
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1152
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1153
    "simple read-eval-print loop for non-graphical Minitalk.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1154
     If the chunkFormat-argument is true, chunks are read.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1155
     Otherwise, lines up to an empty line (or EOF) are read.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1156
     A '#' character appearing in the first column of the first line
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
  1157
     switches to chunkmode."
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1158
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1159
    ControlInterrupt handle:[:ex |
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1160
        self errorStream showCR:('Caught: ', ex description).
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
  1161
        self inputStream atEnd ifTrue:[
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
  1162
            ex return.
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
  1163
        ].    
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
  1164
        MiniDebugger enter.
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
  1165
        ex proceed.
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
  1166
        "/ ex restart.
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1167
    ] do:[
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1168
        |input output error compilerClass|
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1169
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1170
        "/ re-evaluate these in the loop, so they can be changed dynamically
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1171
        input := self inputStream.
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1172
        output := self outputStream.
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1173
        error := self errorStream.
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1174
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1175
        compilerClass := compiler ? Compiler ? Parser.
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1176
        compilerClass isNil ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1177
            error showCR:('oops - no Compiler class found').
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1178
            ^ self.
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1179
        ].
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1180
        StreamError handle:[:ex |
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1181
            (input isOpen not or:[input atEnd]) ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1182
                error showCR:'EOF on input'.
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
  1183
                ex return.
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1184
            ].    
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1185
            (output isOpen not) ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1186
                error showCR:'no output'.
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1187
            ].    
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1188
            (error isOpen not) ifTrue:[
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1189
            ].    
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1190
        ] do:[    
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1191
            input signalAtEnd:true.
22743
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
  1192
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1193
            self
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
  1194
                basicReadEvalPrintLoopWithInput:input output:output error:error
22743
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
  1195
                compiler:compilerClass prompt:prompt print:true.
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
  1196
43cc0113e23a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 22742
diff changeset
  1197
        ].
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
  1198
    ].
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1199
    "/ self errorStream showCR:('done.').
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1200
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1201
    "
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
  1202
     Stdin atEnd 
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
  1203
     Stdin clearEOF
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
  1204
     Smalltalk readEvalPrintLoop
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1205
     (ReadEvalPrintLoop new prompt:'>') readEvalPrintLoop
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1206
    "
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1207
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
  1208
    "Created: / 07-12-2006 / 17:27:21 / cg"
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
  1209
    "Modified: / 08-11-2016 / 22:42:21 / cg"
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1210
! !
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1211
16089
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
  1212
!ReadEvalPrintLoop methodsFor:'queries'!
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
  1213
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
  1214
autoDefineVariables
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
  1215
    "when evaluating with --eval, auto define any variables"
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
  1216
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
  1217
    ^ #workspace
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
  1218
! !
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
  1219
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1220
!ReadEvalPrintLoop class methodsFor:'documentation'!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
version
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
  1223
    ^ '$Header$'
13121
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
  1224
!
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
  1225
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
  1226
version_CVS
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
  1227
    ^ '$Header$'
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
! !
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
  1229