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