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