ReadEvalPrintLoop.st
author Claus Gittinger <cg@exept.de>
Mon, 05 Mar 2018 15:01:10 +0100
changeset 22577 d47c7e41eda5
parent 22576 d774834d53fc
child 22735 15ce04593d54
permissions -rw-r--r--
#FEATURE by cg class: ReadEvalPrintLoop changed: #cmd_read: #cmd_setOrClear:to: #cmd_show: #cmd_use:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22574
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
     1
"{ Encoding: utf8 }"
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
     2
10249
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
     3
"
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
     4
 COPYRIGHT (c) 2006 by eXept Software AG
16565
Claus Gittinger <cg@exept.de>
parents: 16482
diff changeset
     5
	      All Rights Reserved
10249
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
     6
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
     7
 This software is furnished under a license and may be used
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
     8
 only in accordance with the terms of that license and with the
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    10
 be provided or otherwise made available to, or used by, any
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    11
 other person.  No title to or ownership of the software is
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    12
 hereby transferred.
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    13
"
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libbasic' }"
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
    16
"{ NameSpace: Smalltalk }"
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
    17
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
Object subclass:#ReadEvalPrintLoop
16228
85589db2091a class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16145
diff changeset
    19
	instanceVariableNames:'inputStream outputStream errorStream compiler prompt
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
    20
		doChunkFormat traceFlag timingFlag profilingFlag printFlag
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
    21
		exitAction currentDirectory lastEditedClass lastEditedSelector
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
    22
		editorCommand'
16228
85589db2091a class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16145
diff changeset
    23
	classVariableNames:''
85589db2091a class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16145
diff changeset
    24
	poolDictionaries:''
85589db2091a class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16145
diff changeset
    25
	category:'System-Support'
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
10249
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    28
!ReadEvalPrintLoop class methodsFor:'documentation'!
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    29
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    30
copyright
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 (c) 2006 by eXept Software AG
16565
Claus Gittinger <cg@exept.de>
parents: 16482
diff changeset
    33
	      All Rights Reserved
10249
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    34
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    35
 This software is furnished under a license and may be used
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    36
 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
    37
 inclusion of the above copyright notice.   This software may not
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    38
 be provided or otherwise made available to, or used by, any
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    39
 other person.  No title to or ownership of the software is
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    40
 hereby transferred.
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    41
"
10461
0b2935207fec +correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents: 10277
diff changeset
    42
!
0b2935207fec +correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents: 10277
diff changeset
    43
0b2935207fec +correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents: 10277
diff changeset
    44
documentation
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
    A simple read-eval-print loop for non-GUI or stscript operation.
16081
a61f3489d983 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 15702
diff changeset
    47
    Invoked, for example if stx is started with a --repl argument.
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    48
10628
284266d54dbe #exit only leaves the rep-loop
Claus Gittinger <cg@exept.de>
parents: 10500
diff changeset
    49
    A line starting with '?' shows the usage message.
284266d54dbe #exit only leaves the rep-loop
Claus Gittinger <cg@exept.de>
parents: 10500
diff changeset
    50
    Lines starting with '#' are directives:
22576
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
    51
        #exit           - exit the rep-loop
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
    52
        #show ...       - show various infos
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
    53
        #use package    - show various infos
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    54
        type '?' to see more.
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    55
        
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    56
    The input can be in one of two formats:
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    57
        1) traditional chunk format (bang-separated chunks, bangs duplicated)
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    58
          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
    59
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    60
        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
    61
          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
    62
          are entered linewise by a user.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    63
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    64
    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
    65
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
    66
    Try it (but only if you have a console):
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
    67
        Smalltalk readEvalPrintLoop
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
    68
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    69
    [Author:]
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
    70
        Claus Gittinger
10461
0b2935207fec +correctableError:position:to:
Claus Gittinger <cg@exept.de>
parents: 10277
diff changeset
    71
"
10249
4f4b81940a34 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10248
diff changeset
    72
! !
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
!ReadEvalPrintLoop methodsFor:'accessing'!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
    76
compiler:something
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    77
    "assign a compiler to use;could be used to change the language"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    78
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
    79
    compiler := something.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
10632
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
    82
doChunkFormat
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    83
    "true if currently reading chunk format"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    84
10632
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
    85
    ^ doChunkFormat ? true
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
    86
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
    87
    "Created: / 07-12-2006 / 18:24:04 / cg"
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
    88
!
a4f695f8e0f9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10631
diff changeset
    89
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    90
doChunkFormat:aBoolean
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    91
    "enable/disable chunk format"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    92
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
    93
    doChunkFormat := aBoolean.
10254
e576d49220c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10253
diff changeset
    94
e576d49220c2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10253
diff changeset
    95
    "Created: / 07-12-2006 / 18:24:04 / cg"
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
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
    98
editorCommand
21934
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
    99
    "the editor command to use with the #edit directive.
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   100
     Uses the STX_EDITOR or EDITOR shell variables' value, if defined;
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   101
     if not, the value in the classvar EDITORCOMMAND if non-nil; 
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   102
     otheriwse vi (notepad on windows)"
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   103
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   104
    |editor|
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   105
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   106
    (editor := editorCommand) isNil ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   107
        editor := OperatingSystem getEnvironment:'STX_EDITOR'.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   108
        editor isNil ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   109
            editor := OperatingSystem getEnvironment:'EDITOR'.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   110
            editor isNil ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   111
                OperatingSystem isMSWINDOWSlike ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   112
                    editor := 'notepad'.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   113
                ] ifFalse:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   114
                    editor := 'vi'.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   115
                ].    
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   116
            ].    
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   117
        ].    
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   118
    ].
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   119
    ^ editor
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   120
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   121
    "Created: / 08-11-2016 / 22:45:22 / cg"
21934
2ceafc60e0cc #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20949
diff changeset
   122
    "Modified: / 24-06-2017 / 09:54:10 / cg"
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   123
!
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   124
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   125
error:aStream
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   126
    "assign an error stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   127
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   128
    errorStream := aStream.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    "Created: / 07-12-2006 / 17:33:39 / cg"
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   133
errorStream
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   134
    "return the current error stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   135
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   136
    errorStream notNil ifTrue:[^ errorStream].
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   137
    ^ Processor activeProcess stderr
10256
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   138
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   139
    "Created: / 07-12-2006 / 19:12:27 / cg"
10256
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   140
!
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   141
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   142
input:aStream
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   143
    "assign an input stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   144
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   145
    inputStream := aStream asLineNumberReadStream.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    "Modified: / 07-12-2006 / 17:33:31 / cg"
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   150
inputStream
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   151
    "get the current input stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   152
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   153
    inputStream notNil ifTrue:[^ inputStream].
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   154
    ^ Processor activeProcess stdin
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   155
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   156
    "Created: / 07-12-2006 / 19:12:13 / cg"
10256
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   157
!
63993a2b4d15 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10255
diff changeset
   158
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   159
output:aStream
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   160
    "assign an output stream"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   161
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   162
    outputStream := aStream.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    "Created: / 07-12-2006 / 17:27:48 / cg"
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   167
outputStream
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   168
    "return the current output stream"
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   169
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   170
    outputStream notNil ifTrue:[^ outputStream].
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   171
    ^ Processor activeProcess stdout
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   172
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   173
    "Created: / 07-12-2006 / 19:12:27 / cg"
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   174
!
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   175
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   176
prompt:aString
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   177
    "set the prompt"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   178
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   179
    prompt := aString.
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
! !
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
10631
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   182
!ReadEvalPrintLoop methodsFor:'compiler interface-error handling'!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   183
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   184
correctableError:message position:pos1 to:pos2 from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   185
    "compiler notifies us of an error - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   186
15702
01c33c1f4990 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 15365
diff changeset
   187
    ^ false "/ no correction
10631
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   188
!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   189
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   190
correctableSelectorWarning:aString position:relPos to:relEndPos from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   191
    "compiler notifies us of a warning - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   192
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   193
    ^ false
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   194
!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   195
13121
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   196
correctableWarning:message position:pos1 to:pos2 from:aCompiler
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   197
    "compiler notifies us of an error - ignore it"
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   198
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   199
    ^ false
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   200
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   201
    "Created: / 02-11-2010 / 13:29:22 / cg"
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   202
!
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   203
10631
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   204
error:aString position:relPos to:relEndPos from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   205
    "compiler notifies us of a warning - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   206
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   207
    ^ false
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   208
!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   209
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   210
unusedVariableWarning:aString position:relPos to:relEndPos from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   211
    "compiler notifies us of a warning - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   212
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   213
    ^ false
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   214
!
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   215
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   216
warning:aString position:relPos to:relEndPos from:aCompiler
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   217
    "compiler notifies us of a warning - ignore it"
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   218
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   219
    ^ self
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   220
! !
39ebd04452ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10628
diff changeset
   221
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   222
!ReadEvalPrintLoop methodsFor:'directives'!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   223
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   224
cmd_clear:lineStream
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   225
    self cmd_setOrClear:lineStream to:false
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   226
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   227
    "Created: / 07-12-2006 / 19:04:50 / cg"
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   228
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   229
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   230
cmd_debug:lineStream
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   231
    MiniDebugger enter.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   232
!
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   233
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   234
cmd_edit:lineStream
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   235
    "edit a class or selector in an external editor"
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   236
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   237
    |errStream classOrMethodName cls methodName selector 
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   238
     code isNewClass editFullClass tmpFile modifiedTime|
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   239
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   240
    errStream := self errorStream.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   241
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   242
    isNewClass := editFullClass := false.
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   243
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   244
    lineStream skipSeparators.
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   245
    lineStream atEnd ifTrue:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   246
        cls := lastEditedClass.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   247
        methodName := lastEditedSelector.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   248
    ] ifFalse:[    
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   249
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   250
        classOrMethodName := lineStream 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   251
                                upToElementForWhich:[:ch | 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   252
                                    ch isLetterOrDigit not and:[ch ~~ $_]
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   253
                                ].
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   254
        "/ 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   255
        (classOrMethodName isUppercaseFirst) ifTrue:[ 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   256
            (cls := Smalltalk classNamed:classOrMethodName) isNil ifTrue:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   257
                errStream show:'edit: no such class: ',classOrMethodName,' ; create (y/n)? '.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   258
                (self inputStream nextLine withoutSeparators startsWith:'y') ifFalse:[^ self].
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   259
                isNewClass := true.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   260
                code := 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   261
'"/ change the code as required, then save and exit the editor.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   262
"/ To cancel this edit, leave the editor WITHOUT saving.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   263
"/
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   264
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   265
Object
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   266
  subclass:#%1
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   267
  instanceVariableNames:''''
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   268
  classVariableNames:''''
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   269
  poolDictionaries:''''
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   270
  category:''user classes''
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   271
'                   bindWith:classOrMethodName.
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   272
            ] ifFalse:[ 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   273
                lineStream skipSeparators.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   274
                lineStream atEnd ifFalse:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   275
                    methodName := lineStream upToSeparator.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   276
                ].
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   277
            ].
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   278
        ] ifFalse:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   279
            methodName := classOrMethodName   
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   280
        ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   281
    ].
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   282
    
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   283
    isNewClass ifFalse:[
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   284
        cls := cls ? lastEditedClass.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   285
        cls isNil ifTrue:[
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   286
            errStream showCR:'edit usage:'.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   287
            errStream showCR:'   #edit className selector'.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   288
            errStream showCR:'   #edit className '.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   289
            errStream showCR:'   #edit selector (class as in previous edit)'.
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   290
            errStream showCR:'   #edit          (class/method as in previous edit)'.
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   291
            ^ self.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   292
        ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   293
        lastEditedClass := cls.
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   294
        lastEditedSelector := methodName.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   295
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   296
        methodName isNil ifTrue:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   297
            editFullClass := true.
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   298
            code := cls source asString
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   299
        ] ifFalse:[    
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   300
            ((selector := methodName asSymbolIfInterned) isNil 
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   301
            or:[ (cls implements:selector) not]) ifTrue:[
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   302
                errStream show:('"',methodName,'" is a new method; create (y/n)? ').
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   303
                (self inputStream nextLine withoutSeparators startsWith:'y') ifFalse:[^ self].
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   304
                code := 
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   305
'"/ change the code as required, then save and exit the editor.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   306
"/ To cancel this edit, leave the editor WITHOUT saving.
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   307
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   308
%1
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   309
    "this is a new method"
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   310
    self halt
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   311
'                   bindWith:methodName.
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   312
            ] ifFalse:[
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   313
                code := (cls compiledMethodAt:selector) source.
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   314
            ].    
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   315
        ].    
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   316
    ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   317
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   318
    [
20936
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   319
        |ok cmd|
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   320
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   321
        tmpFile := Filename newTemporary.
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   322
        tmpFile contents:code.
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   323
        modifiedTime := tmpFile modificationTime.
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   324
20936
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   325
        cmd := '%1 "%2"'.
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   326
        OperatingSystem isUNIXlike ifTrue:[
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   327
            cmd := '%1 "%2" </dev/tty'.
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   328
        ].
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   329
        
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   330
        ok := OperatingSystem 
20936
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   331
                executeCommand:(cmd bindWith:(self editorCommand) with:tmpFile pathName)
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   332
                inputFrom:Stdin 
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   333
                outputTo:Stdout 
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   334
                errorTo:Stderr
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   335
                auxFrom:nil
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   336
                environment:nil
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   337
                inDirectory:nil
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   338
                lineWise:false
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   339
                newPgrp:false
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   340
                showWindow:true
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   341
                onError:[:status | false].
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   342
                
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   343
        (ok and:[tmpFile modificationTime ~= modifiedTime]) ifTrue:[
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   344
            isNewClass ifTrue:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   345
                Compiler evaluate:tmpFile contentsOfEntireFile.    
20937
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   346
                errStream showCR:'Class (re)defined.'
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   347
            ] ifFalse:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   348
                editFullClass ifTrue:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   349
                    tmpFile fileIn.
20937
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   350
                    errStream showCR:'Class (re)compiled.'
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   351
                ] ifFalse:[    
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   352
                    cls compile:tmpFile contentsOfEntireFile classified:'*as yet uncategorized'.    
20937
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   353
                    errStream showCR:'Method (re)compiled.'
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   354
                ].    
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   355
            ].    
20937
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   356
        ] ifFalse:[
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   357
            errStream showCR:'No change.'
fad9938ce942 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20936
diff changeset
   358
        ].    
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   359
    ] ensure:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   360
        tmpFile notNil ifTrue:[
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   361
            tmpFile remove
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   362
        ]
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   363
    ].
20906
c718e433b416 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20905
diff changeset
   364
    
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   365
    "
20934
36e46558156d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20933
diff changeset
   366
     Smalltalk readEvalPrintLoop
36e46558156d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20933
diff changeset
   367
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   368
     self new 
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   369
        input:Stdin;
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   370
        cmd_edit:'MyClass foo' readStream
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   371
    "
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   372
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   373
    "Modified: / 08-11-2016 / 22:46:12 / cg"
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   374
!
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   375
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   376
cmd_exit:lineStream
22576
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
   377
    "exit directive - leaves the repl"
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
   378
10628
284266d54dbe #exit only leaves the rep-loop
Claus Gittinger <cg@exept.de>
parents: 10500
diff changeset
   379
    exitAction value
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   380
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   381
    "Created: / 07-12-2006 / 18:55:46 / cg"
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   382
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   383
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   384
cmd_help:lineStream
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   385
    self errorStream
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   386
        nextPutAll:
16084
8fc6fc71a8cb class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16081
diff changeset
   387
'Everything entered up to an empty line or a line ending in "." is called a "chunk" and evaluated.
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   388
Lines starting with "#" are commands to the read-eval-print interpreter.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   389
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   390
Valid commands are:
10635
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   391
    #help ............... this text
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   392
    #exit ............... exit interpreter loop
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   393
    #use <package>....... use (load) a package
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   394
        stx:libwidg .............. GUI package
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   395
        stx:libtool .............. IDE tool package
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   396
        stx:goodies/regex ........ regex package
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   397
        stx:goodies/petitparser .. peg parser package
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   398
    #read <filename>..... read another script or source file
10635
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   399
    #show <what> ........ show info
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   400
        variables .......... interpreter variables
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   401
        processes .......... processes
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   402
        memory ............. memory usage
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   403
        flags .............. flags
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   404
        modules ............ loaded modules
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   405
        packages ........... available packages to load
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   406
        all ................ all of the above
10635
c3c4fc186068 changed #interpreterLoopWith:
Claus Gittinger <cg@exept.de>
parents: 10632
diff changeset
   407
    #set/clear <flag> ... set or clear a flag
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   408
        trace .............. tracing execution
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   409
        timing ............. timing execution
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   410
        profiling .......... show execution profile
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   411
        chunkFormat ........ traditional bang chunk format input mode
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   412
        editor ............. command used with #edit directive
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   413
    #debug ................. enter a MiniDebugger
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   414
    #edit <what> ........ open an external editor 
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   415
        class .............. on a class
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   416
        class selector ..... on a method
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   417
        <empty> ............ on previously edited method/last class
10257
2bc06451585b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10256
diff changeset
   418
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   419
The MiniDebugger (if entered) shows its own help with "?".
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   420
'
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   421
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   422
    "Created: / 07-12-2006 / 18:54:20 / cg"
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   423
    "Modified: / 08-11-2016 / 22:53:53 / cg"
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   424
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   425
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   426
cmd_read:lineStream
22577
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   427
    "read directive; i.e.
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   428
        #read scriptFile
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   429
    "
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   430
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
   431
    |filename newInput savedPrompt savedPrint savedInput savedCurrentDirectory savedDoChunkFormat|
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   432
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   433
    lineStream skipSeparators.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   434
    filename := lineStream upToEnd withoutSeparators.
22577
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   435
    filename isEmptyOrNil ifTrue:[
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   436
        self errorStream showCR:'? usage: #read <filename>'.
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   437
        ^ self.
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   438
    ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   439
20915
f7ef8fa16261 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20914
diff changeset
   440
    currentDirectory := currentDirectory ? (Filename currentDirectory).
f7ef8fa16261 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20914
diff changeset
   441
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   442
    filename := filename asFilename.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   443
    filename isAbsolute ifFalse:[
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   444
        filename := currentDirectory construct:filename.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   445
    ].
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   446
20922
26a835f3689a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20920
diff changeset
   447
    StreamError ignoreIn:[
26a835f3689a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20920
diff changeset
   448
        newInput := filename readStream.
26a835f3689a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20920
diff changeset
   449
    ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   450
    newInput isNil ifTrue:[
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   451
        self errorStream showCR:('Could not find file: "',filename pathName,'"').
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   452
        ^ self.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   453
    ].
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   454
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   455
    [
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   456
        savedCurrentDirectory := currentDirectory.
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
   457
        savedDoChunkFormat := doChunkFormat.
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   458
        savedInput := inputStream.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   459
        savedPrint := printFlag.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   460
        savedPrompt := prompt.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   461
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   462
        currentDirectory := filename directory.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   463
        inputStream := newInput.
20910
d97034358023 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20909
diff changeset
   464
        
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   465
        self
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   466
            basicReadEvalPrintLoopWithInput:newInput
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   467
            output:outputStream
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   468
            error:errorStream
20910
d97034358023 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20909
diff changeset
   469
            compiler:(compiler ? Compiler ? Parser)
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   470
            prompt:false
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   471
            print:false.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   472
    ] ensure:[
20914
79b75bb6f696 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20913
diff changeset
   473
        newInput close.
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
   474
        doChunkFormat := savedDoChunkFormat.
20909
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   475
        currentDirectory := savedCurrentDirectory.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   476
        inputStream := savedInput.
e9950b1f79d0 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20907
diff changeset
   477
        printFlag := savedPrint.
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
   478
        prompt := savedPrompt.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   479
    ].
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   480
!
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   481
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   482
cmd_set:lineStream
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   483
    self cmd_setOrClear:lineStream to:true
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   484
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   485
    "Modified: / 07-12-2006 / 19:04:46 / cg"
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   486
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   487
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   488
cmd_setOrClear:lineStream to:aBoolean
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   489
    |what|
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   490
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   491
    lineStream skipSeparators.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   492
    what := lineStream nextAlphaNumericWord.
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   493
    what notNil ifTrue:[
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   494
        (what startsWith:'tra') ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   495
            traceFlag := aBoolean.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   496
            ^ self.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   497
        ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   498
        (what startsWith:'tim') ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   499
            timingFlag := aBoolean.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   500
            ^ self.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   501
        ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   502
        (what startsWith:'pro') ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   503
            profilingFlag := aBoolean.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   504
            ^ self.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   505
        ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   506
        (what startsWith:'chunk') ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   507
            doChunkFormat := aBoolean.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   508
            ^ self.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   509
        ].
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   510
        (what startsWith:'edi') ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   511
            aBoolean ifTrue:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   512
                "/ set editor cmd
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   513
                lineStream skipSeparators.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   514
                editorCommand := lineStream upToEnd.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   515
            ] ifFalse:[
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   516
                editorCommand := nil.
20938
9532ecca5967 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20937
diff changeset
   517
            ].
9532ecca5967 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20937
diff changeset
   518
            ^ self.
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   519
        ].
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   520
    ].
22577
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   521
    self errorStream showCR:'? usage: set/clear <flag>'.
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   522
    self errorStream showCR:'? (<flag> must be one of: trace, times, profile, chunk, editor)'.
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   523
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   524
    "Modified: / 08-11-2016 / 22:49:17 / cg"
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   525
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   526
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   527
cmd_show:lineStream
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   528
    "show directive:
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   529
        show packages
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   530
        show modules (= loaded packages)
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   531
        show variables 
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   532
        etc.
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   533
    "
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   534
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   535
    |errStream what showAll ok|
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   536
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   537
    errStream := self errorStream.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   538
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   539
    lineStream skipSeparators.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   540
    what := lineStream nextAlphaNumericWord.
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   541
    ok := false.
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   542
    
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   543
    what notNil ifTrue:[
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   544
        showAll := (what startsWith:'all').
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   545
        
20835
ce8d50491138 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20834
diff changeset
   546
        (showAll or:[ what startsWith:'var' ]) ifTrue:[                      
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   547
            errStream showCR:'Variables:'; showCR:'----------'.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   548
            self showVariables.
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   549
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   550
        ].
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   551
        
20835
ce8d50491138 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20834
diff changeset
   552
        (showAll or:[ what startsWith:'proc' ]) ifTrue:[                    
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   553
            errStream cr; showCR:'Threads:'; showCR:'--------'.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   554
            MiniDebugger basicNew showProcesses.
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   555
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   556
        ].
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   557
        
20902
342c68aa8e9a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20901
diff changeset
   558
        ("showAll or:[" what startsWith:'pack' "]") ifTrue:[                    
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   559
            errStream cr; showCR:'Available Packages:'; showCR:'--------'.
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   560
            self showPackages.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   561
            ok := true.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   562
        ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   563
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   564
        (showAll or:[ what startsWith:'mod' ]) ifTrue:[
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   565
            errStream cr; showCR:'Modules:'; showCR:'--------'.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   566
            self showModules.
13865
8a42d5528cc4 changed:
Claus Gittinger <cg@exept.de>
parents: 13859
diff changeset
   567
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   568
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   569
        ].
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   570
        
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   571
        (showAll or:[ what startsWith:'mem' ]) ifTrue:[
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   572
            |allMem|
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   573
            
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   574
            errStream cr; showCR:'Memory:'; showCR:'-------'.
20891
8d94557ec419 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20890
diff changeset
   575
            "/ allMem := ObjectMemory oldSpaceUsed + ObjectMemory symSpaceUsed
8d94557ec419 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20890
diff changeset
   576
            "/                                     + ObjectMemory newSpaceUsed.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   577
            errStream
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   578
                "/ showCR:('overall: ',(allMem // 1024) printString,' Kb');
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   579
                showCR:('used   : ',(ObjectMemory bytesUsed // 1024) printString,' Kb');
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   580
                showCR:('free   : ',(ObjectMemory freeSpace // 1024) printString,' Kb');
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   581
                show:('minorGC: ',(ObjectMemory scavengeCount) printString);
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   582
                showCR:(' majorGC: ',(ObjectMemory garbageCollectCount) printString).
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   583
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   584
        ].
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   585
        
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   586
        (showAll or:[ what startsWith:'flag' ]) ifTrue:[
22575
cd5f0602a863 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22574
diff changeset
   587
            errStream cr; showCR:'Flags:'; showCR:'------'.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   588
            errStream
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   589
                showCR:('trace :      ',(traceFlag ? false) printString);
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   590
                showCR:('timing:      ',(timingFlag ? false) printString);
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   591
                showCR:('profiling:   ',(profilingFlag ? false) printString);
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   592
                showCR:('chunkFormat: ',(doChunkFormat ? false) printString);
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   593
                showCR:('editor:      ',self editorCommand printString).
20845
d192dae88051 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20836
diff changeset
   594
            ok := true.
20768
e4c38b21e74c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 19379
diff changeset
   595
        ].
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   596
    ].
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   597
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   598
    ok ifFalse:[
22576
d774834d53fc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22575
diff changeset
   599
        errStream showCR:'? usage: show <what>'.
22577
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   600
        errStream showCR:'? (<what> must be one of: packages, modules, variables, flags, memory, processes)'.
20834
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   601
    ].
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   602
    
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   603
    "
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   604
     self basicNew cmd_show:'packages' readStream
92fe48284264 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20833
diff changeset
   605
    "
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   606
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   607
    "Modified: / 08-11-2016 / 22:46:51 / cg"
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   608
!
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   609
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   610
cmd_use:lineStream
22574
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   611
    "use directive; i.e.
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   612
        #use stx:goodies/xml
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   613
        #use exept:mqtt
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   614
    "
2657d849761e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21934
diff changeset
   615
16145
8687a6524d21 class: ReadEvalPrintLoop
Stefan Vogel <sv@exept.de>
parents: 16133
diff changeset
   616
    |pkg|
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   617
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   618
    lineStream skipSeparators.
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   619
    pkg := lineStream upToEnd.
22577
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   620
    (pkg isEmptyOrNil or:[pkg := pkg withoutSeparators isEmpty]) ifTrue:[
d47c7e41eda5 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22576
diff changeset
   621
        self errorStream showCR:'? usage: #use <package>'.
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   622
        ^ self.
16133
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   623
    ].
dc573e06581e class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16119
diff changeset
   624
16145
8687a6524d21 class: ReadEvalPrintLoop
Stefan Vogel <sv@exept.de>
parents: 16133
diff changeset
   625
    [
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   626
        Smalltalk loadPackage:pkg.
16145
8687a6524d21 class: ReadEvalPrintLoop
Stefan Vogel <sv@exept.de>
parents: 16133
diff changeset
   627
    ] on:PackageLoadError do:[:ex|
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   628
        "/ allow for some shortcuts...
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   629
        (pkg includes:$:) ifTrue:[
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   630
            self errorStream showCR:('Failed to load package: "',pkg,'"').
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   631
        ] ifFalse:[
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   632
            "/ try stx standard package
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   633
            pkg := 'stx:', pkg.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   634
            ex restart.
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   635
        ].
13852
4bdc4f1dc3e3 changed: #cmd_use:
Claus Gittinger <cg@exept.de>
parents: 13768
diff changeset
   636
    ].
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   637
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   638
    "Created: / 07-12-2006 / 19:07:56 / cg"
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   639
!
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   640
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   641
directive:line
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   642
    |s cmd|
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   643
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   644
    s := line readStream.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   645
    s next. "/ skip the hash
20913
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   646
    s peek == $!! ifTrue:[
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   647
        "/ skip shebang line 
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   648
        ^ self.
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   649
    ].    
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   650
    s skipSeparators.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   651
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   652
    cmd := s nextAlphaNumericWord.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   653
    cmd notNil ifTrue:[
20919
3c3e236e39d7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20918
diff changeset
   654
        AbortAllOperationRequest handle:[:ex |
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   655
            self errorStream showCR:('Directive aborted: ', ex description)
20919
3c3e236e39d7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20918
diff changeset
   656
        ] do:[
20920
41aec62f6587 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20919
diff changeset
   657
            Error handle:[:ex |
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   658
                self errorStream showCR:('Caught in directive: ', ex description).
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   659
                ex suspendedContext fullPrintAll.
20919
3c3e236e39d7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20918
diff changeset
   660
            ] do:[    
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   661
                ControlInterrupt handle:[:ex |
20936
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   662
                    MiniDebugger enter.
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   663
                    "/ self errorStream showCR:('Ignored in directive: ', ex description).
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   664
                    "/ ex reject. 
06ccf7cc734a #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20935
diff changeset
   665
                    "/ ex proceed. 
20926
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   666
                ] do:[    
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   667
                    self
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   668
                        perform:('cmd_',cmd) asMutator with:s
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   669
                        ifNotUnderstood:[
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   670
                            self errorStream
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   671
                                show:'?? invalid command: '; show:cmd;
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   672
                                showCR:'. Type "#help" for help.'
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   673
                        ].
238218aac7c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20925
diff changeset
   674
                ].
20913
58dc377d1211 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20912
diff changeset
   675
            ].
20919
3c3e236e39d7 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20918
diff changeset
   676
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   677
    ].
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   678
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   679
    "Created: / 07-12-2006 / 18:49:17 / cg"
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   680
    "Modified: / 08-11-2016 / 21:59:16 / cg"
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   681
!
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   682
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   683
showModules
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   684
    |errStream printModule|
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   685
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   686
    errStream := self errorStream.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   687
    
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   688
    printModule :=
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   689
        [:mod |
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   690
            errStream
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   691
                show:'  ';
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   692
                show:(mod package "libraryName");
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   693
                showCR:' (',(mod type),')'.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   694
        ].
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   695
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   696
    errStream nextPutLine:'builtIn:'.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   697
    ((ObjectMemory binaryModuleInfo
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   698
        reject:[:m | m dynamic])
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   699
            asSortedCollection:[:a :b | a name < b name]) do:printModule.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   700
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   701
    errStream nextPutLine:'dynamic:'.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   702
    ((ObjectMemory binaryModuleInfo
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   703
        select:[:m | m dynamic])
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   704
            asSortedCollection:[:a :b | a name < b name]) do:printModule.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   705
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   706
    "
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   707
     ReadEvalPrintLoop basicNew showModules
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   708
    "
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   709
!
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   710
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   711
showPackages
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   712
    |all|
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   713
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   714
    all := Set new.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   715
    Smalltalk knownLoadablePackagesDo:[:packageID :type :path |
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   716
        all add:packageID
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   717
    ].
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   718
    all := all asOrderedCollection sort.
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   719
    all do:[:eachPackage |
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   720
        self errorStream show:eachPackage.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   721
        (Smalltalk isPackageLoaded:eachPackage) ifTrue:[
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   722
            self errorStream show:' (loaded)'.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   723
        ].    
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   724
        self errorStream cr.
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   725
    ].    
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   726
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   727
    "
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   728
     ReadEvalPrintLoop basicNew showPackages
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   729
     ReadEvalPrintLoop basicNew showModules
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   730
    "
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   731
!
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   732
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   733
showVariables
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   734
    Workspace notNil ifTrue:[
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   735
        Workspace workspaceVariables keys asOrderedCollection sort do:[:nm |
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   736
            |holder|
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   737
            holder := Workspace workspaceVariables at:nm.
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   738
            self errorStream 
20923
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   739
                show:nm;  
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   740
                show:' -> '; 
ce3f5d5e8b54 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20922
diff changeset
   741
                showCR:holder value printString.
20901
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   742
        ].
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   743
    ].
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   744
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   745
    "
56be0b5cd5d7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20900
diff changeset
   746
     ReadEvalPrintLoop basicNew showVariables
20900
f2e647fa7eb1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20892
diff changeset
   747
    "
10255
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   748
! !
a50472b6354a directives
Claus Gittinger <cg@exept.de>
parents: 10254
diff changeset
   749
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
!ReadEvalPrintLoop methodsFor:'evaluation'!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
16565
Claus Gittinger <cg@exept.de>
parents: 16482
diff changeset
   752
basicReadEvalPrintLoopWithInput:input output:output error:error
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   753
    compiler:compilerClass prompt:prompt print:doPrint
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   754
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   755
    "{ Pragma: +optSpace }"
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   756
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   757
    "the core of the interpreter loop; extracted and parametrized, so it can be called recursive
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   758
     for included scripts.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   759
     If chunkFormat is true, chunks are read.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   760
     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
   761
     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
   762
     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
   763
20911
1c11be64f4a1 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20910
diff changeset
   764
    exitAction := [^ self].
1c11be64f4a1 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20910
diff changeset
   765
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   766
    [
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   767
        |lines chunk|
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   768
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   769
        prompt notNil ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   770
            error show:prompt.
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   771
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   772
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   773
        input atEnd ifTrue:[
20912
fc5c40cbdb26 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20911
diff changeset
   774
            doPrint ifTrue:[ error cr ].
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   775
            ^ self.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   776
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   777
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   778
        input peek == $# ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   779
            self doChunkFormat:false.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   780
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   781
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   782
        self doChunkFormat ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   783
            input skipSeparators.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   784
            chunk := input nextChunk.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   785
        ] ifFalse:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   786
            lines := OrderedCollection new.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   787
            [
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   788
                |line|
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   789
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   790
                line := input nextLine.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   791
                line notEmptyOrNil ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   792
                    line = '?' ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   793
                        self cmd_help:nil.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   794
                        prompt notNil ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   795
                            error show:prompt.
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   796
                        ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   797
                    ] ifFalse:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   798
                        (line startsWith:'#') ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   799
                            self directive:line.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   800
                            prompt notNil ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   801
                                error show:prompt.
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   802
                            ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   803
                        ] ifFalse:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   804
                            lines add:line.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   805
                        ]
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   806
                    ]
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   807
                ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   808
                line notEmptyOrNil and:[(line endsWith:$.) not].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   809
            ] whileTrue.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   810
            chunk := lines asStringWith:Character cr.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   811
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   812
20890
935d14488b6d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20845
diff changeset
   813
        (chunk notEmptyOrNil 
935d14488b6d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20845
diff changeset
   814
          and:[chunk withoutSeparators notEmpty
935d14488b6d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20845
diff changeset
   815
          and:[chunk withoutSeparators ~= '.']]
935d14488b6d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20845
diff changeset
   816
        ) ifTrue:[
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   817
            "abortAll is handled, but not asked for here!!"
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   818
            AbortAllOperationRequest handle:[:ex |
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   819
                error nextPutLine:('Evaluation aborted: ', ex description)
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   820
            ] do:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   821
                (Error, ControlInterrupt) handle:[:ex |
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   822
                    prompt isNil ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   823
                        ex reject
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   824
                    ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   825
                    MiniDebugger enterWithMessage:(ex errorString) mayProceed:true.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   826
                    ex mayProceed ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   827
                        ex proceed.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   828
                    ].
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   829
                    error showCR:('Evaluation aborted: ', ex description).
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   830
                    ex return.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   831
                ] do:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   832
                    |value ms us|
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   833
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   834
                    profilingFlag == true ifTrue:[ 
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   835
                        MessageTally spyDetailedOn:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   836
                            value := (compilerClass new requestor:self) 
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   837
                                        evaluate:chunk
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   838
                                        compile:true.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   839
                        ].    
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   840
                        doPrint ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   841
                            value printOn:output. output cr.
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   842
                            output flush.
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   843
                        ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   844
                    ] ifFalse:[    
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   845
                        us := Time microsecondsToRun:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   846
                            value := (compilerClass new requestor:self)
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   847
                                        evaluate:chunk compile:true.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   848
                        ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   849
                        doPrint ifTrue:[
20949
14f5982c2aee #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20938
diff changeset
   850
                            value isVoid ifFalse:[
14f5982c2aee #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20938
diff changeset
   851
                                value printOn:output. output cr.
14f5982c2aee #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 20938
diff changeset
   852
                            ].
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   853
                        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   854
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   855
                        timingFlag == true ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   856
                            'execution time: ' printOn:error.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   857
                            us < 1000 ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   858
                                us < 1 ifTrue:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   859
                                    'too small to measure (<1us)' printOn:error.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   860
                                ] ifFalse:[
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   861
                                    us printOn:output. 'us' printOn:error.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   862
                                ]
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   863
                            ] ifFalse:[
20771
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   864
                                ((us / 1000) asFixedPoint:2) printOn:output. 'ms' printOn:error.
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   865
                            ].
bc02f6854efa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20770
diff changeset
   866
                            error cr.
20769
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   867
                        ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   868
                    ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   869
                    Workspace notNil ifTrue:[
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   870
                        Workspace rememberResultAsWorkspaceVariable:value.
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   871
                    ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   872
                ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   873
            ].
174ac2f6d41d #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20768
diff changeset
   874
        ].
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   875
    ] loop.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   876
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   877
    "
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   878
     Smalltalk readEvalPrintLoop.
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   879
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   880
     (ReadEvalPrintLoop new prompt:'>') readEvalPrintLoop
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   881
    "
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   882
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   883
    "Created: / 07-12-2006 / 17:27:21 / cg"
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   884
    "Modified: / 08-11-2016 / 22:41:47 / cg"
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   885
!
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   886
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   887
readEvalPrintLoop
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   888
    "{ Pragma: +optSpace }"
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   889
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   890
    "simple read-eval-print loop for non-graphical Minitalk.
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   891
     If the chunkFormat-argument is true, chunks are read.
16087
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   892
     Otherwise, lines up to an empty line (or EOF) are read.
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   893
     A '#' character appearing in the first column of the first line
ba981c147e6c class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16084
diff changeset
   894
     switches to chunkmode."
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   895
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   896
    ControlInterrupt handle:[:ex |
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   897
        self errorStream showCR:('Caught: ', ex description).
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
   898
        self inputStream atEnd ifTrue:[
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
   899
            ex return.
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
   900
        ].    
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   901
        MiniDebugger enter.
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   902
        ex proceed.
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   903
        "/ ex restart.
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   904
    ] do:[
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   905
        |input output error compilerClass|
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   906
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   907
        "/ re-evaluate these in the loop, so they can be changed dynamically
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   908
        input := self inputStream.
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   909
        output := self outputStream.
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   910
        error := self errorStream.
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   911
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   912
        compilerClass := compiler ? Compiler ? Parser.
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   913
        compilerClass isNil ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   914
            error showCR:('oops - no Compiler class found').
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   915
            ^ self.
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   916
        ].
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   917
        StreamError handle:[:ex |
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   918
            (input isOpen not or:[input atEnd]) ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   919
                error showCR:'EOF on input'.
20833
58ae6ff92df5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20774
diff changeset
   920
                ex return.
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   921
            ].    
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   922
            (output isOpen not) ifTrue:[
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   923
                error showCR:'no output'.
20774
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   924
            ].    
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   925
            (error isOpen not) ifTrue:[
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   926
            ].    
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   927
        ] do:[    
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   928
            input signalAtEnd:true.
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   929
            self
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   930
                basicReadEvalPrintLoopWithInput:input output:output error:error
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   931
                compiler:compilerClass prompt:prompt print:(printFlag ? true).
a29ae1f5f429 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20771
diff changeset
   932
        ]
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   933
    ].
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   934
    "/ self errorStream showCR:('done.').
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   935
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   936
    "
20933
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   937
     Stdin atEnd 
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   938
     Stdin clearEOF
2a6274961920 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 20926
diff changeset
   939
     Smalltalk readEvalPrintLoop
10463
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   940
     (ReadEvalPrintLoop new prompt:'>') readEvalPrintLoop
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   941
    "
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   942
90c8fd90d3fc oops - corrupted code
Claus Gittinger <cg@exept.de>
parents: 10462
diff changeset
   943
    "Created: / 07-12-2006 / 17:27:21 / cg"
20935
7803512423cb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 20934
diff changeset
   944
    "Modified: / 08-11-2016 / 22:42:21 / cg"
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   945
! !
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   946
16089
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
   947
!ReadEvalPrintLoop methodsFor:'queries'!
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
   948
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
   949
autoDefineVariables
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
   950
    "when evaluating with --eval, auto define any variables"
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
   951
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
   952
    ^ #workspace
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
   953
! !
04545ee7ab04 class: ReadEvalPrintLoop
Claus Gittinger <cg@exept.de>
parents: 16088
diff changeset
   954
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
!ReadEvalPrintLoop class methodsFor:'documentation'!
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   956
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   957
version
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   958
    ^ '$Header$'
13121
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   959
!
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   960
e0cc829d4b4d added: #correctableError:position:to:from:
Claus Gittinger <cg@exept.de>
parents: 10635
diff changeset
   961
version_CVS
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   962
    ^ '$Header$'
10248
c00913f343f1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
! !
19379
9bbc68ce23a6 #FEATURE
Claus Gittinger <cg@exept.de>
parents: 16565
diff changeset
   964