BCompiler.st
author Claus Gittinger <cg@exept.de>
Thu, 24 Oct 1996 16:23:58 +0200
changeset 400 e5cfc008be47
parent 383 fc4b30e5e511
child 407 a8c20d561cd6
permissions -rw-r--r--
bytecode changes - some more are now special-send codes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     1
"
4
f6fd83437415 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
     3
	      All Rights Reserved
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
     4
7ad01559b262 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
7ad01559b262 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
7ad01559b262 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7ad01559b262 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7ad01559b262 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
7ad01559b262 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    11
"
7ad01559b262 Initial revision
claus
parents:
diff changeset
    12
7ad01559b262 Initial revision
claus
parents:
diff changeset
    13
Parser subclass:#ByteCodeCompiler
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
    14
	instanceVariableNames:'codeBytes codeIndex litArray stackDelta extra lineno extraLiteral
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
    15
		maxStackDepth relocList'
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
    16
	classVariableNames:'JumpToAbsJump SequenceNumber STCCompilationDefines
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
    17
		STCCompilationIncludes STCCompilationOptions STCCompilation
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
    18
		ShareCode STCKeepCIntermediate STCModulePath'
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
    19
	poolDictionaries:''
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
    20
	category:'System-Compiler'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    21
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    22
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
    23
!ByteCodeCompiler class methodsFor:'documentation'!
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
    24
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    25
copyright
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    26
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    27
 COPYRIGHT (c) 1989 by Claus Gittinger
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    28
	      All Rights Reserved
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    29
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    30
 This software is furnished under a license and may be used
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    31
 only in accordance with the terms of that license and with the
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    33
 be provided or otherwise made available to, or used by, any
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    34
 other person.  No title to or ownership of the software is
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    35
 hereby transferred.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    36
"
135
aa4f7b8f121e uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
    37
!
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    38
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
    39
documentation
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
    40
"
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    41
    This class performs compilation into ByteCodes.
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    42
    First, parsing is done using superclass methods,
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    43
    then the parse-tree is converted into an array of symbolic codes
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    44
    and a relocation table; 
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    45
    these two are finally combined into a byteArray of the codes.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    46
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    47
    (the intermediate step through symbolic codes is for debugging
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    48
     only - it will vanish)
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    49
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    50
    There are many dependencies to the run-time-system (especially the
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    51
    interpreter) in here - be careful when playing around ...
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    52
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    53
    [Instance variables:]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    54
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    55
        codeBytes       <ByteArry>              bytecodes
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    56
        codeIndex       <SmallInteger>          next index to put into code array
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    57
        litArray        <OrderedCollection>     literals
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    58
        stackDelta      <SmallInteger>          return value of byteCodeFor:
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    59
        extra           <Symbol>                return value of byteCodeFor:
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    60
        lineno          <Boolean>               return value of byteCodeFor:
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    61
        extraLiteral    <Symbol>                return value of byteCodeFor:
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    62
        maxStackDepth   <SmallInteger>          stack need of method
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    63
        relocList       <Array>                 used temporary for relocation
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    64
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    65
    [Class variables:]
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    66
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    67
        JumpToAbsJump   <Dictionary>            internal table to map opcodes
211
1fd13827a2fc ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    68
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    69
        SequenceNumber  <Integer>               counting intermediate stc-compiled
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    70
                                                objects (for unique o-file naming)
211
1fd13827a2fc ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    71
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    72
        STCCompilationDefines                   passed to stc as command line arguments
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    73
        STCCompilationIncludes
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    74
        STCCompilationOptions
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    75
                        <String>                
211
1fd13827a2fc ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    76
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    77
        STCCompilation  <Symbol>                #always, #primitiveOnly or #never
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    78
                                                controls when stc compilation is wanted
211
1fd13827a2fc ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    79
259
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    80
        ShareCode       <Boolean>               reuse byteArrays for common (simple) code sequences
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    81
                                                This is normally a 'good' optimization,
a469695d8d19 commentary
Claus Gittinger <cg@exept.de>
parents: 256
diff changeset
    82
                                                expect if you plan to modify the byteCodes.
263
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    83
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    84
    [author:]
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    85
        Claus Gittinger
3b21d0991eff documentation
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
    86
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
    87
"
98
claus
parents: 97
diff changeset
    88
! !
claus
parents: 97
diff changeset
    89
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
    90
!ByteCodeCompiler class methodsFor:'initialization'!
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    91
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    92
initialize
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    93
    ShareCode := true.
295
ec9ca802683e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 292
diff changeset
    94
    STCKeepCIntermediate := false.
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
    95
    STCModulePath := './modules'.
211
1fd13827a2fc ask CCReader about the sourceMode
Claus Gittinger <cg@exept.de>
parents: 209
diff changeset
    96
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
    97
    "Modified: 12.7.1996 / 12:14:53 / cg"
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    98
! !
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
    99
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   100
!ByteCodeCompiler class methodsFor:'compiling methods'!
98
claus
parents: 97
diff changeset
   101
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   102
compile:methodText forClass:classToCompileFor
7ad01559b262 Initial revision
claus
parents:
diff changeset
   103
    "compile a source-string for a method in classToCompileFor"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   104
7ad01559b262 Initial revision
claus
parents:
diff changeset
   105
    ^ self compile:methodText
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   106
	  forClass:classToCompileFor
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   107
	inCategory:'others'
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   108
	 notifying:nil
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   109
	   install:true
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   110
	skipIfSame:false
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   111
	    silent:false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   112
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   113
7ad01559b262 Initial revision
claus
parents:
diff changeset
   114
compile:aString forClass:aClass inCategory:cat
7ad01559b262 Initial revision
claus
parents:
diff changeset
   115
    "compile a source-string for a method in classToCompileFor.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   116
     The method will get cat as category"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   117
7ad01559b262 Initial revision
claus
parents:
diff changeset
   118
    ^ self compile:aString
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   119
	  forClass:aClass
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   120
	inCategory:cat
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   121
	 notifying:nil
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   122
	   install:true
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   123
	skipIfSame:false
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   124
	    silent:false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   125
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   126
84
claus
parents: 78
diff changeset
   127
compile:aString forClass:aClass inCategory:cat notifying:requestor
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   128
    "compile a source-string for a method in classToCompileFor.
84
claus
parents: 78
diff changeset
   129
     errors are forwarded to requestor.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   130
     The method will get cat as category"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   131
7ad01559b262 Initial revision
claus
parents:
diff changeset
   132
    ^ self compile:aString
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   133
	  forClass:aClass
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   134
	inCategory:cat
84
claus
parents: 78
diff changeset
   135
	 notifying:requestor
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   136
	   install:true
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   137
	skipIfSame:false
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   138
	    silent:false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   139
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   140
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   141
compile:aString forClass:aClass inCategory:cat notifying:requestor install:install
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   142
    "compile a source-string for a method in classToCompileFor.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   143
     The install-argument controls if the method is to be installed into the
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   144
     classes method-dictionary, or just to be compiled and a method object to be returned.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   145
     Errors are forwarded to requestor. The method will get cat as category"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   146
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   147
    ^ self compile:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   148
	  forClass:aClass
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   149
	inCategory:cat
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   150
	 notifying:requestor
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   151
	   install:install
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   152
	skipIfSame:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   153
	    silent:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   154
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   155
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   156
compile:aString forClass:aClass inCategory:cat notifying:requestor
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   157
		 install:install skipIfSame:skipIfSame
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   158
    "compile a source-string for a method in classToCompileFor.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   159
     The install-argument controls if the method is to be installed into the
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   160
     classes method-dictionary, or just to be compiled and a method object to be returned.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   161
     Errors are forwarded to requestor. The method will get cat as category.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   162
     If skipIsSame is true, and the source is the same as an existing
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   163
     methods source, this is a noop (for fast fileIn)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   164
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   165
    ^ self compile:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   166
	  forClass:aClass
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   167
	inCategory:cat
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   168
	 notifying:requestor
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   169
	   install:install
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   170
	skipIfSame:skipIfSame
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   171
	    silent:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   172
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   173
84
claus
parents: 78
diff changeset
   174
compile:aString forClass:aClass inCategory:cat notifying:requestor
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   175
		 install:install skipIfSame:skipIfSame silent:silent
230
54e13c76f143 allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
   176
54e13c76f143 allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
   177
    ^ self
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   178
	compile:aString
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   179
	forClass:aClass
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   180
	inCategory:cat
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   181
	notifying:requestor
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   182
	install:install
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   183
	skipIfSame:skipIfSame
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   184
	silent:silent
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   185
	foldConstants:true
230
54e13c76f143 allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
   186
!
54e13c76f143 allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
   187
54e13c76f143 allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
   188
compile:aString forClass:aClass inCategory:cat notifying:requestor
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   189
                 install:install skipIfSame:skipIfSame silent:silent foldConstants:fold
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   190
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   191
    "the basic workhorse method for compiling:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   192
     compile a source-string for a method in classToCompileFor.
84
claus
parents: 78
diff changeset
   193
     errors are forwarded to requestor (report on Transcript and return
claus
parents: 78
diff changeset
   194
     #Error, if requestor is nil).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   195
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   196
     The new method will get cat as category. 
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   197
     If install is true, the method will go into the classes method-table, 
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   198
     otherwise the method is simply returned (for anonymous methods).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   199
     If skipIsSame is true, and the source is the same as an existing
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   200
     methods source, this is a noop (for fast fileIn).
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   201
     The argument, silent controls if errors are to be reported."
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   202
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   203
    |compiler newMethod tree lits symbolicCodeArray oldMethod lazy silencio 
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   204
     sourceFile sourceStream newSource primNr pos sel keptOldCode msg answer|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   205
7ad01559b262 Initial revision
claus
parents:
diff changeset
   206
    aString isNil ifTrue:[^ nil].
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   207
    silencio := silent or:[Smalltalk silentLoading == true].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   208
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   209
    "lazy compilation is EXPERIMENTAL"
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   210
    lazy := (LazyCompilation == true) and:[install].
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   211
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   212
    "create a compiler, let it parse and create the parsetree"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   213
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   214
    compiler := self for:(ReadStream on:aString) in:aClass.
84
claus
parents: 78
diff changeset
   215
    compiler parseForCode.
230
54e13c76f143 allow constant folding to be turned off
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
   216
    fold ifFalse:[compiler foldConstants:nil].
84
claus
parents: 78
diff changeset
   217
    compiler notifying:requestor.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   218
    silent ifTrue:[
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   219
"/        compiler ignoreErrors.
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   220
        compiler ignoreWarnings
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   221
    ].
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   222
"/    compiler nextToken.
350
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   223
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   224
    (compiler parseMethodSpec == #Error) ifTrue:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   225
        compiler parseError:'syntax error in method specification'.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   226
        tree := #Error
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   227
    ] ifFalse:[
350
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   228
        lazy ifTrue:[
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   229
            "/
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   230
            "/ that one method IS required
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   231
            "/
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   232
            (aClass isMeta and:[compiler selector == #version]) ifTrue:[
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   233
                lazy := false
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   234
            ]
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   235
        ].
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   236
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   237
        lazy ifFalse:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   238
            "check if same source"
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   239
            (skipIfSame and:[(sel := compiler selector) notNil]) ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   240
                oldMethod := aClass compiledMethodAt:sel.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   241
                oldMethod notNil ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   242
                    oldMethod source = aString ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   243
                        oldMethod isInvalid ifFalse:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   244
                            silencio ifFalse:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   245
                                Transcript showCR:('    unchanged: ',aClass name,' ',compiler selector)
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   246
                            ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   247
                            "
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   248
                             same. however, category may be different
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   249
                            "
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   250
                            (cat notNil and:[cat ~= oldMethod category]) ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   251
                                oldMethod category:cat.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   252
                                oldMethod changed:#category.    
191
5c285632f2ea slightly faster lazy loading
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   253
    "/                            aClass updateRevisionString.
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   254
                                aClass addChangeRecordForMethodCategory:oldMethod category:cat.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   255
                            ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   256
                            ^ oldMethod
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   257
                        ]
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   258
                    ]
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   259
                ]
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   260
            ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   261
            tree := compiler parseMethodBody.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   262
            compiler tree:tree.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   263
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   264
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   265
7ad01559b262 Initial revision
claus
parents:
diff changeset
   266
    (compiler errorFlag or:[tree == #Error]) ifTrue:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   267
        compiler showErrorMessageForClass:aClass.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   268
        ^ #Error
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   269
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   270
191
5c285632f2ea slightly faster lazy loading
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   271
    sel := compiler selector.
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   272
    "if no error and also no selector ..."
90
claus
parents: 85
diff changeset
   273
     sel isNil ifTrue:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   274
        "... it was just a comment or other empty stuff"
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   275
        ^ nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   276
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   277
191
5c285632f2ea slightly faster lazy loading
Claus Gittinger <cg@exept.de>
parents: 187
diff changeset
   278
    lazy ifFalse:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   279
        "
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   280
         freak-out support ...
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   281
        "
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   282
        (compiler hasNonOptionalPrimitiveCode 
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   283
        or:[(compiler hasPrimitiveCode and:[self canCreateMachineCode])
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   284
        or:[STCCompilation == #always and:[sel  ~~ #doIt]]]) ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   285
            newMethod := compiler 
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   286
                            compileToMachineCode:aString 
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   287
                            forClass:aClass 
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   288
                            inCategory:cat 
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   289
                            notifying:requestor
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   290
                            install:install 
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   291
                            skipIfSame:skipIfSame 
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   292
                            silent:silent.
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   293
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   294
            newMethod == #Error ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   295
                compiler showErrorMessageForClass:aClass.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   296
                ^ #Error
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   297
            ].
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   298
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   299
            (newMethod == #CannotLoad) ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   300
                newMethod := compiler trappingStubMethodFor:aString inCategory:cat.
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   301
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   302
                keptOldCode := false.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   303
                install ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   304
                    "/
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   305
                    "/ be very careful with existing methods
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   306
                    "/ (otherwise, you could easily make your system unusable in systems which cannot load)
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   307
                    "/
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   308
                    sel notNil ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   309
                        oldMethod := aClass compiledMethodAt:sel 
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   310
                    ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   311
                    (oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   312
                        answer := Dialog
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   313
                                     confirm:'installation of binary code is not possible or disabled.
97
claus
parents: 96
diff changeset
   314
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   315
Shall I use the old methods functionality
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   316
or instead create a dummy trap method for it ?
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   317
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   318
Hint:
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   319
  if that method is needed by the system, you better leave the
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   320
  original functionality in the system.
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   321
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   322
Close this warnBox to abort the compilation.
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   323
'
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   324
                                     yesLabel:'trap code'
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   325
                                     noLabel:'keep old'.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   326
                        answer isNil ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   327
                            ^ #Error
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   328
                        ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   329
                        answer == false ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   330
                            newMethod code:(oldMethod code).
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   331
                            keptOldCode := true.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   332
                        ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   333
                    ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   334
                    aClass addSelector:sel withMethod:newMethod
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   335
                ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   336
                Transcript show:'*** '.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   337
                sel notNil ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   338
                    Transcript show:(sel ,' ')
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   339
                ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   340
                keptOldCode ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   341
                    msg := 'not really compiled - method still shows previous behavior'.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   342
                ] ifFalse:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   343
                    msg := 'not compiled to machine code - created a stub instead.'.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   344
                ].
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   345
                Transcript showCR:msg.
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   346
            ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   347
            ^ newMethod
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   348
        ].
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   349
    ].
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   350
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   351
    "
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   352
     EXPERIMENTAL: quick loading
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   353
     only create a lazyMethod, which has no byteCode and will 
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   354
     compile itself when first called.
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   355
    "
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   356
    lazy ifTrue:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   357
        newMethod := LazyMethod new.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   358
        (ClassCategoryReader sourceMode == #sourceReference) ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   359
            sourceFile := ObjectMemory nameForSources.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   360
            sourceFile notNil ifTrue:[    
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   361
                sourceStream := sourceFile asFilename appendingWriteStream.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   362
            ]
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   363
        ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   364
        sourceStream isNil ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   365
            newMethod source:aString.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   366
        ] ifFalse:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   367
            sourceStream setToEnd.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   368
            pos := sourceStream position.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   369
            sourceStream nextChunkPut:aString.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   370
            sourceStream close.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   371
            newMethod sourceFilename:sourceFile position:pos.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   372
        ].
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   373
        newMethod category:cat.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   374
        Project notNil ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   375
            newMethod package:(Project currentPackageName)
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   376
        ].
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   377
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   378
        aClass addSelector:sel withLazyMethod:newMethod.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   379
        ^ newMethod
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   380
    ].
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   381
90
claus
parents: 85
diff changeset
   382
    (primNr := compiler primitiveNumber) isNil ifTrue:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   383
        "
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   384
         produce symbolic code first
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   385
        "
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   386
        symbolicCodeArray := compiler genSymbolicCode.
90
claus
parents: 85
diff changeset
   387
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   388
        (symbolicCodeArray == #Error) ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   389
            Transcript show:'    '.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   390
            sel notNil ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   391
                Transcript show:(sel ,' ')
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   392
            ].
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   393
            Transcript showCR:'translation error'.
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   394
            ^ #Error
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   395
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   396
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   397
        "
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   398
         take this, producing bytecode 
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   399
         (someone willin' to make machine code :-)
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   400
        "
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   401
        ((compiler genByteCodeFrom:symbolicCodeArray) == #Error) ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   402
            Transcript show:'    '.
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   403
             sel notNil ifTrue:[
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   404
                Transcript show:(sel ,' ')
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   405
            ].
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   406
            Transcript showCR:'relocation error - must be simplified'.
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   407
            ^ #Error
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   408
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   409
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   410
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   411
    "
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   412
     finally create the new method-object
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   413
    "
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   414
    newMethod := compiler createMethod.
90
claus
parents: 85
diff changeset
   415
    primNr notNil ifTrue:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   416
        newMethod code:(compiler checkForPrimitiveCode:primNr).
78
e320344c19b7 *** empty log message ***
claus
parents: 76
diff changeset
   417
    ] ifFalse:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   418
        newMethod byteCode:(compiler code).
78
e320344c19b7 *** empty log message ***
claus
parents: 76
diff changeset
   419
    ].
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   420
"/    newMethod numberOfMethodVars:(compiler numberOfMethodVars).
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   421
"/    newMethod numberOfMethodArgs:(compiler numberOfMethodArgs).
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   422
"/    newMethod stackSize:(compiler maxStackDepth).
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   423
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   424
    "
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   425
     if there where any corrections, install the updated source
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   426
    "
90
claus
parents: 85
diff changeset
   427
    (newSource := compiler correctedSource) notNil ifTrue:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   428
        newMethod source:newSource 
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   429
    ] ifFalse:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   430
        newMethod source:aString.
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   431
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   432
    newMethod category:cat.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   433
    Project notNil ifTrue:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   434
        newMethod package:(Project currentPackageName)
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   435
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   436
7ad01559b262 Initial revision
claus
parents:
diff changeset
   437
    install ifTrue:[
256
ae09ebb4aa35 no need to send nextToken when parsing a method
Claus Gittinger <cg@exept.de>
parents: 253
diff changeset
   438
        aClass addSelector:sel withMethod:newMethod
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   439
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   440
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   441
    silencio ifFalse:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
   442
        Transcript showCR:('    compiled: ', aClass name,' ', sel)
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   443
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   444
7ad01559b262 Initial revision
claus
parents:
diff changeset
   445
    ^ newMethod
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   446
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   447
    "Created: 29.10.1995 / 19:59:36 / cg"
292
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
   448
    "Modified: 24.6.1996 / 12:41:13 / stefan"
350
13e1dcaf87eb oops - the classes version method may not be lazy
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   449
    "Modified: 8.10.1996 / 20:03:29 / cg"
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   450
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   451
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   452
compile:methodText forClass:classToCompileFor notifying:requestor
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   453
    "compile a source-string for a method in classToCompileFor.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   454
     Errors are forwarded to requestor."
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   455
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   456
    ^ self compile:methodText
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   457
	  forClass:classToCompileFor
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   458
	inCategory:'others'
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   459
	 notifying:requestor
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   460
	   install:true
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   461
	skipIfSame:false
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   462
	    silent:false
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   463
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   464
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   465
compile:textOrStream in:aClass notifying:requestor ifFail:exceptionBlock
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   466
    "name alias for ST-80 compatibility"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   467
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   468
    |m|
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   469
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   470
    m := self 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   471
	   compile:textOrStream
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   472
	  forClass:aClass 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   473
	inCategory:'others'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   474
	 notifying:requestor 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   475
	   install:true
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   476
	skipIfSame:false
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   477
	    silent:false.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   478
    m == #Error ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   479
	^ exceptionBlock value
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   480
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   481
     ^ m
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   482
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   483
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   484
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   485
!ByteCodeCompiler class methodsFor:'constants'!
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   486
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   487
byteCodeFor:aSymbol
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   488
    "returns the numeric code for some symbolic bytecodes."
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   489
25
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   490
    (aSymbol == #retNil) ifTrue:[^ 1].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   491
    (aSymbol == #retTrue) ifTrue:[^ 2].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   492
    (aSymbol == #retFalse) ifTrue:[^ 3].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   493
    (aSymbol == #ret0) ifTrue:[^ 4].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   494
    (aSymbol == #retTop) ifTrue:[^ 0].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   495
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   496
    (aSymbol == #push0) ifTrue:[^120].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   497
    (aSymbol == #push1) ifTrue:[^121].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   498
    (aSymbol == #push2) ifTrue:[^139].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   499
    (aSymbol == #pushMinus1) ifTrue:[^122].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   500
    (aSymbol == #pushNil) ifTrue:[^ 10].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   501
    (aSymbol == #pushTrue) ifTrue:[^ 11].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   502
    (aSymbol == #pushFalse) ifTrue:[^ 12].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   503
    (aSymbol == #pushSelf) ifTrue:[^ 15].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   504
    self error
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   505
! !
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   506
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   507
!ByteCodeCompiler class methodsFor:'stc compilation defaults'!
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   508
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   509
canCreateMachineCode
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   510
    "return true, if compilation to machine code is supported.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   511
     Currently, all SYSV4 and Linux systems do so;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   512
     REAL/IX, AIX and HPUX do not (due to the need for dynamic loading 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   513
     of object files, which is not supported by those).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   514
     MIPS ULTRIX is almost finished, but not yet released.
124
claus
parents: 120
diff changeset
   515
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   516
     However, if no compiler is around (i.e. the demo distribution),
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   517
     there is no chance ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   518
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   519
    |canDo|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   520
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   521
    ObjectFileLoader isNil ifTrue:[^ false].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   522
    ObjectFileLoader canLoadObjectFiles ifFalse:[^ false].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   523
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   524
    "/ no chance, if no stc is available
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   525
    ^ self incrementalStcPath notNil
124
claus
parents: 120
diff changeset
   526
claus
parents: 120
diff changeset
   527
    "
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   528
     Compiler canCreateMachineCode     
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   529
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   530
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   531
    "Modified: 13.9.1995 / 15:15:11 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   532
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   533
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   534
incrementalStcPath 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   535
    "return the path to the stc command for incremental method compilation, 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   536
     or nil if not found."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   537
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   538
    |f|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   539
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   540
    (f := self stcPathOf:'stc') notNil ifTrue:[^ f].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   541
    ^ self stcPathOf:'demostc'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   542
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   543
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   544
     Compiler incrementalStcPath     
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   545
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   546
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   547
    "Created: 13.9.1995 / 14:36:36 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   548
    "Modified: 13.9.1995 / 15:15:04 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   549
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   550
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   551
stcCompilation
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   552
    "return the flag which controls compilation to machine code.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   553
     If #always, methods are always compiled to machine code (which takes
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   554
     longer, but provides faster code). If #none, methods are never compiled
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   555
     to machine code, instead for non-primitive ones, compilation is to bytecode
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   556
     and for primitive ones, a trapping stub is generated.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   557
     Anything else lets the compiler compile to bytecode,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   558
     except for methods containing primitive code.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   559
     This can be set from your private.rc file or from a workspace
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   560
     for selective compilation to machine code."
124
claus
parents: 120
diff changeset
   561
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   562
    ^ STCCompilation
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   563
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   564
    "
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   565
     Compiler stcCompilation
124
claus
parents: 120
diff changeset
   566
    "
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   567
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   568
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   569
stcCompilation:how
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   570
    "set the flag which controls compilation to machine code.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   571
     If #always, methods are always compiled to machine code (which takes
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   572
     longer, but provides faster code). If #none, methods are never compiled
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   573
     to machine code, instead for non-primitive ones, compilation is to bytecode
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   574
     and for primitive ones, a trapping stub is generated.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   575
     Anything else lets the compiler compile to bytecode,
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   576
     except for methods containing primitive code.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   577
     This can be set from your private.rc file or from a workspace
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   578
     for selective compilation to machine code."
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   579
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   580
    |ret|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   581
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   582
    ret := STCCompilation.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   583
    STCCompilation := how.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   584
    ^ ret
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   585
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   586
    "
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   587
     Compiler stcCompilation:#always
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   588
     Compiler stcCompilation:#never 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   589
     Compiler stcCompilation:#default 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   590
    "
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   591
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   592
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   593
stcCompilationDefines
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   594
    "return the defines used with stc compilation"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   595
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   596
    ^ STCCompilationDefines
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   597
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   598
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   599
stcCompilationDefines:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   600
    "define the flags (for example, additional -D defines)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   601
     to be used when compiling to machine code.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   602
     These are passed to stc. Can be set from your private.rc file."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   603
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   604
    STCCompilationDefines := aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   605
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   606
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   607
     Compiler stcCompilationDefines:'-DVGL -DDEBUG'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   608
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   609
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   610
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   611
stcCompilationIncludes
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   612
    "return the includes used with stc compilation"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   613
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   614
    ^ STCCompilationIncludes
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   615
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   616
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   617
stcCompilationIncludes:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   618
    "define the include directories via additional -I flags.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   619
     These are passed to stc. Can be set in your private.rc file"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   620
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   621
    STCCompilationIncludes := aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   622
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   623
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   624
     Compiler stcCompilationIncludes:'-I/usr/local/include -I../../include'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   625
     Compiler stcCompilationIncludes:(Compiler stcCompilationIncludes , ' -I../../libxt')
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   626
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   627
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   628
124
claus
parents: 120
diff changeset
   629
stcCompilationOptions
claus
parents: 120
diff changeset
   630
    "return the options used with stc compilation"
claus
parents: 120
diff changeset
   631
claus
parents: 120
diff changeset
   632
    ^ STCCompilationOptions
claus
parents: 120
diff changeset
   633
!
claus
parents: 120
diff changeset
   634
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   635
stcCompilationOptions:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   636
    "define the compilation options 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   637
     to be used when compiling to machine code.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   638
     These are passed to stc. Can be set from your private.rc file."
101
claus
parents: 98
diff changeset
   639
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   640
    STCCompilationOptions := aString
101
claus
parents: 98
diff changeset
   641
claus
parents: 98
diff changeset
   642
    "
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   643
     Compiler stcCompilationOptions:'+optinline'
101
claus
parents: 98
diff changeset
   644
    "
claus
parents: 98
diff changeset
   645
!
claus
parents: 98
diff changeset
   646
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   647
stcModulePath
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   648
    "return the path, where temporary modules are created"
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   649
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   650
    ^ STCModulePath
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   651
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   652
    "Created: 12.7.1996 / 12:15:26 / cg"
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   653
!
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   654
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   655
stcModulePath:aPath
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   656
    "set the path to the directory, where temporary modules are created"
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   657
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   658
    STCModulePath := aPath
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   659
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   660
    "Created: 12.7.1996 / 12:15:49 / cg"
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   661
!
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
   662
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   663
stcPath 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   664
    "return the path to the stc command, or nil if not found."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   665
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   666
    ^ self stcPathOf:'stc'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   667
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   668
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   669
     Compiler stcPath     
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   670
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   671
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   672
    "Modified: 13.9.1995 / 14:37:26 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   673
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   674
120
claus
parents: 118
diff changeset
   675
stcPathOf:command 
claus
parents: 118
diff changeset
   676
    "return the path to an stc command, or nil if not found."
101
claus
parents: 98
diff changeset
   677
claus
parents: 98
diff changeset
   678
    |f|
97
claus
parents: 96
diff changeset
   679
120
claus
parents: 118
diff changeset
   680
    ((f := '../../stc' asFilename construct:command)) isExecutable ifTrue:[
101
claus
parents: 98
diff changeset
   681
	^ f pathName
claus
parents: 98
diff changeset
   682
    ].
126
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   683
    ^ OperatingSystem pathOfCommand:command
97
claus
parents: 96
diff changeset
   684
claus
parents: 96
diff changeset
   685
    "
120
claus
parents: 118
diff changeset
   686
     Compiler stcPathOf:'stc'     
claus
parents: 118
diff changeset
   687
    "
claus
parents: 118
diff changeset
   688
claus
parents: 118
diff changeset
   689
    "Created: 13.9.1995 / 14:37:16 / claus"
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   690
! !
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   691
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   692
!ByteCodeCompiler methodsFor:'ST-80 compatibility'!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   693
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   694
compile:textOrStream in:aClass notifying:requestor ifFail:exceptionBlock
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   695
    "name alias for ST-80 compatibility"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   696
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   697
    ^ self class
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   698
		compile:textOrStream
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   699
		in:aClass 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   700
		notifying:requestor 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   701
		ifFail:exceptionBlock
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   702
"/    |m|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   703
"/
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   704
"/    m := self class 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   705
"/                compile:textOrStream 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   706
"/                forClass:aClass 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   707
"/                inCategory:'no category'
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   708
"/                notifying:requestor
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   709
"/                install:true 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   710
"/                skipIfSame:false
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   711
"/                silent:false.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   712
"/    m == #Error ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   713
"/        ^ exceptionBlock value
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   714
"/    ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   715
"/     ^ m
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   716
! !
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   717
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   718
!ByteCodeCompiler methodsFor:'accessing'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   719
7ad01559b262 Initial revision
claus
parents:
diff changeset
   720
code
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
   721
    "return the bytecode array - only valid after code-generation"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   722
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   723
    ^ codeBytes
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   724
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   725
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   726
literalArray
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   727
    "return the literal array - only valid after parsing"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   728
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   729
    ^ litArray
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   730
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   731
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   732
maxStackDepth
7ad01559b262 Initial revision
claus
parents:
diff changeset
   733
    "return the stack-need of the method - only valid after code-generation"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   734
7ad01559b262 Initial revision
claus
parents:
diff changeset
   735
    ^ maxStackDepth
7ad01559b262 Initial revision
claus
parents:
diff changeset
   736
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   737
7ad01559b262 Initial revision
claus
parents:
diff changeset
   738
!ByteCodeCompiler methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   739
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   740
absJumpFromJump:code
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   741
    "given a jump-symbolic code, return corresponding absolute jump"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   742
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   743
    JumpToAbsJump isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   744
	JumpToAbsJump := IdentityDictionary new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   745
	JumpToAbsJump at:#jump put:#jumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   746
	JumpToAbsJump at:#trueJump put:#trueJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   747
	JumpToAbsJump at:#falseJump put:#falseJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   748
	JumpToAbsJump at:#nilJump put:#nilJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   749
	JumpToAbsJump at:#notNilJump put:#notNilJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   750
	JumpToAbsJump at:#eqJump put:#eqJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   751
	JumpToAbsJump at:#notEqJump put:#notEqJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   752
	JumpToAbsJump at:#zeroJump put:#zeroJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   753
	JumpToAbsJump at:#notZeroJump put:#notZeroJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   754
	JumpToAbsJump at:#makeBlock put:#makeBlockabs.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   755
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   756
    ^ JumpToAbsJump at:code
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   757
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   758
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   759
addLiteral:anObject
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   760
    "add a literal to the literalArray - watch for and eliminate
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   761
     duplicates. return the index of the literal in the Array"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   762
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   763
    |index class|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   764
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   765
    litArray isNil ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   766
	litArray := Array with:anObject.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   767
	^ 1
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   768
    ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   769
    index := litArray identityIndexOf:anObject.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   770
    (index == 0) ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   771
	"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   772
	 reuse constants if same value and same class
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   773
	"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   774
	class := anObject class.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   775
	((class == Float) 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   776
	or:[class == Fraction]) ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   777
	    index := litArray indexOf:anObject.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   778
	].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   779
	((index == 0) or:[(litArray at:index) class ~~ class]) ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   780
	    litArray := litArray copyWith:anObject.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   781
	    ^ litArray size
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   782
	].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   783
    ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   784
    ^ index
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   785
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   786
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   787
addReloc:symIndex
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   788
    "remember to relocate offset at symIndex later ..."
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
   789
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   790
    relocList isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   791
	relocList := OrderedCollection new.
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   792
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   793
    relocList add:symIndex
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   794
!
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   795
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   796
appendByte:aByte
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   797
    "append a byte to the code-Array, checking for byte-range (debug-only)"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   798
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   799
    |idx "{Class: SmallInteger }"|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   800
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   801
    idx := codeIndex.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   802
    (aByte between:0 and:255) ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   803
	codeBytes at:idx put:aByte.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   804
	codeIndex := idx + 1
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   805
    ] ifFalse:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   806
	self error:'byte range error'.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   807
	errorFlag := #Error
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   808
    ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   809
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   810
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   811
appendByteCodeFor:codeSymbol
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   812
    "append the byteCode for an instructionSymbol to the code-Array"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   813
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   814
    |idx "{Class: SmallInteger }"|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   815
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   816
    idx := codeIndex.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   817
    codeBytes at:idx put:(self byteCodeFor:codeSymbol).
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   818
    codeIndex := idx + 1
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   819
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   820
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   821
appendEmptyByte
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   822
    "append an empty byte to the code-Array"
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
   823
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   824
    |idx "{Class: SmallInteger }"|
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
   825
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   826
    idx := codeIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   827
    codeBytes at:idx put:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   828
    codeIndex := idx + 1
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   829
!
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   830
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   831
appendEmptyLong
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   832
    "append an empty long (4 bytes) to the code-Array"
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   833
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   834
    |idx "{Class: SmallInteger }"|
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   835
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   836
    idx := codeIndex.
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   837
    codeBytes at:idx put:0.
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   838
    codeBytes at:idx+1 put:0.
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   839
    codeBytes at:idx+2 put:0.
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   840
    codeBytes at:idx+3 put:0.
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   841
    codeIndex := idx + 4
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   842
!
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   843
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   844
appendEmptyShort
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   845
    "append an empty short (2 bytes) to the code-Array"
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   846
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   847
    |idx "{Class: SmallInteger }"|
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   848
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   849
    idx := codeIndex.
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   850
    codeBytes at:idx put:0.
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   851
    codeBytes at:idx+1 put:0.
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   852
    codeIndex := idx + 2
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   853
!
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
   854
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   855
appendSignedByte:aByte
7ad01559b262 Initial revision
claus
parents:
diff changeset
   856
    "append a signedbyte (as in jump-offsets) to the code-Array,
7ad01559b262 Initial revision
claus
parents:
diff changeset
   857
     check range and report an error if invalid"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   858
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   859
    |b   "{Class: SmallInteger }" 
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   860
     idx "{Class: SmallInteger }"|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   861
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   862
    idx := codeIndex.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   863
    b := aByte.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   864
    (b >= 0) ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   865
	(b > 127) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   866
	    self error:'jump-range error'.
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   867
	    errorFlag := #Error
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   868
	].
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   869
	codeBytes at:idx put:b
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   870
    ] ifFalse:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   871
	(b < -128) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   872
	    self error:'jump-range error'.
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   873
	    errorFlag := #Error
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   874
	].
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   875
	b := 256 + b
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   876
    ].
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   877
    codeBytes at:idx put:b.
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   878
    codeIndex := idx + 1
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   879
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   880
46
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   881
appendSignedWord:aWord
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   882
    "append a signed word to the code-Array,
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   883
     check range and report an error if invalid"
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   884
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   885
    |w   "{Class: SmallInteger }"|
46
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   886
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   887
    w := aWord.
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   888
    (w >= 0) ifTrue:[
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   889
	(w > 16r7FFFF) ifTrue:[
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   890
	    self error:'word-range error'.
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   891
	    errorFlag := #Error
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   892
	].
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   893
    ] ifFalse:[
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   894
	(w < 16r-8000) ifTrue:[
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   895
	    self error:'word-range error'.
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   896
	    errorFlag := #Error
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   897
	].
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   898
	w := (16r10000 + w).
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   899
    ].
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   900
    self appendWord:w
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   901
!
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   902
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   903
appendWord:aWord
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   904
    "append an unsigned word (low-high) to the code-Array, 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   905
     checking for word-range (debug-only)"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   906
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   907
    |idx "{Class: SmallInteger }"|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   908
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   909
    idx := codeIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   910
    (aWord between:0 and:16rFFFF) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   911
	codeBytes at:idx put:(aWord bitAnd:16rFF).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   912
	idx := idx + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   913
	codeBytes at:idx put:(aWord bitShift:-8).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   914
	codeIndex := idx + 1
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   915
    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   916
	self error:'word range error'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   917
	errorFlag := #Error
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   918
    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   919
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   920
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   921
byteCodeFor:aSymbol
7ad01559b262 Initial revision
claus
parents:
diff changeset
   922
    "given a symbolic instruction, return the corresponding bytecode.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   923
     as a side-effect, leave number of bytes pushed/popped by this instr.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   924
     in stackDelta, and, if the instruction needs extra arguments, leave
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   925
     this info in extra. Also lineno is set to true, if this code has line
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   926
     information and extraLiteral is set if any hidden send is performed by it."
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   927
7ad01559b262 Initial revision
claus
parents:
diff changeset
   928
    "standard bytecodes"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   929
7ad01559b262 Initial revision
claus
parents:
diff changeset
   930
    (aSymbol == #pushNil) ifTrue:[stackDelta := 1. ^ 10].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   931
    (aSymbol == #pushTrue) ifTrue:[stackDelta := 1. ^ 11].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   932
    (aSymbol == #pushFalse) ifTrue:[stackDelta := 1. ^ 12].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   933
    (aSymbol == #pushLit) ifTrue:[stackDelta := 1. extra := #lit. ^ 14].
105
claus
parents: 104
diff changeset
   934
    (aSymbol == #pushLitS) ifTrue:[stackDelta := 1. extra := #index. ^ 14].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   935
    (aSymbol == #pushSelf) ifTrue:[stackDelta := 1. ^ 15].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   936
    (aSymbol == #pushNum) ifTrue:[stackDelta := 1. extra := #number. ^ 16].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   937
7ad01559b262 Initial revision
claus
parents:
diff changeset
   938
    (aSymbol == #pushMethodArg) ifTrue:[stackDelta := 1. extra := #index. ^ 30].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   939
    (aSymbol == #pushMethodVar) ifTrue:[stackDelta := 1. extra := #index. ^ 31].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   940
    (aSymbol == #pushBlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 32].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   941
    (aSymbol == #pushBlockVar) ifTrue:[stackDelta := 1. extra := #index. ^ 33].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   942
    (aSymbol == #pushInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 34].
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   943
    (aSymbol == #pushOuterBlockArg) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 42].
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   944
    (aSymbol == #pushOuterBlockVar) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 128].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   945
7ad01559b262 Initial revision
claus
parents:
diff changeset
   946
    (aSymbol == #retTop) ifTrue:[stackDelta := -1. ^ 0].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   947
    (aSymbol == #retSelf) ifTrue:[^5].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   948
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   949
    (aSymbol == #==) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 45].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   950
    (aSymbol == #~~) ifTrue:[stackDelta := -1. extraLiteral := aSymbol. ^ 46].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   951
7ad01559b262 Initial revision
claus
parents:
diff changeset
   952
    (aSymbol == #falseJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 50].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   953
    (aSymbol == #trueJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 51].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   954
    (aSymbol == #nilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 52].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   955
    (aSymbol == #notNilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 53].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   956
    (aSymbol == #jump) ifTrue:[extra := #offset. ^ 54].
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   957
    (aSymbol == #makeBlock) ifTrue:[stackDelta := 1. extra := #offsetNvarNarg. ^ 55].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   958
    (aSymbol == #zeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 56].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   959
    (aSymbol == #notZeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 57].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   960
    (aSymbol == #eqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 58].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   961
    (aSymbol == #notEqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 59].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   962
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   963
    (aSymbol == #lineno) ifTrue:[lineno := true. ^ 8].
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   964
    (aSymbol == #lineno16) ifTrue:[lineno := true. ^ 9].
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   965
106
claus
parents: 105
diff changeset
   966
    (aSymbol == #send) ifTrue:[lineno := true. extra := #special. ^ 19].
claus
parents: 105
diff changeset
   967
    (aSymbol == #superSend) ifTrue:[lineno := true. extra := #special. ^ 20].
claus
parents: 105
diff changeset
   968
    (aSymbol == #hereSend) ifTrue:[lineno := true. extra := #special. ^ 20].
117
claus
parents: 111
diff changeset
   969
    (aSymbol == #sendSelf) ifTrue:[lineno := true. extra := #special. ^ 13].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   970
7ad01559b262 Initial revision
claus
parents:
diff changeset
   971
    (aSymbol == #drop) ifTrue:[stackDelta := -1. ^ 18].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   972
    (aSymbol == #dup) ifTrue:[stackDelta := 1. ^ 47].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   973
117
claus
parents: 111
diff changeset
   974
    (aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37].
claus
parents: 111
diff changeset
   975
    (aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38].
claus
parents: 111
diff changeset
   976
    (aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   977
117
claus
parents: 111
diff changeset
   978
    (aSymbol == #pushClassVarS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35].
356
bb3beb18de1f 6empty slots in GLOBL/CLASSVAR bytecodes removed
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   979
    (aSymbol == #pushGlobalS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 36].
117
claus
parents: 111
diff changeset
   980
claus
parents: 111
diff changeset
   981
    (aSymbol == #storeClassVarS) ifTrue:[extra := #speciallitS.stackDelta := -1. ^ 40].
356
bb3beb18de1f 6empty slots in GLOBL/CLASSVAR bytecodes removed
Claus Gittinger <cg@exept.de>
parents: 350
diff changeset
   982
    (aSymbol == #storeGlobalS) ifTrue:[extra := #speciallitS. stackDelta := -1. ^ 41].
247
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
   983
    (aSymbol == #pushSpecialGlobal) ifTrue:[stackDelta := 1. extra := #index. ^ 200].
117
claus
parents: 111
diff changeset
   984
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   985
    (aSymbol == #storeOuterBlockVar) ifTrue:[stackDelta := -1. extra := #indexLevel. ^ 129].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   986
117
claus
parents: 111
diff changeset
   987
    (aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176].
claus
parents: 111
diff changeset
   988
    (aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177].
105
claus
parents: 104
diff changeset
   989
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   990
    "optimized bytecodes"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   991
7ad01559b262 Initial revision
claus
parents:
diff changeset
   992
    (aSymbol == #retNil) ifTrue:[^ 1].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   993
    (aSymbol == #retTrue) ifTrue:[^ 2].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   994
    (aSymbol == #retFalse) ifTrue:[^ 3].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   995
    (aSymbol == #ret0) ifTrue:[^ 4].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   996
    (aSymbol == #retNum) ifTrue:[extra := #number. ^ 127].
25
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   997
    (aSymbol == #homeRetTop) ifTrue:[^ 7].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   998
46
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   999
    (aSymbol == #pushNum16) ifTrue:[stackDelta := 1. extra := #number16. ^ 17].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1000
    (aSymbol == #push0) ifTrue:[stackDelta := 1. ^120].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1001
    (aSymbol == #push1) ifTrue:[stackDelta := 1. ^121].
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
  1002
    (aSymbol == #push2) ifTrue:[stackDelta := 1. ^139].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1003
    (aSymbol == #pushMinus1) ifTrue:[stackDelta := 1. ^122].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1004
106
claus
parents: 105
diff changeset
  1005
    (aSymbol == #send0) ifTrue:[lineno := true. extra := #index. ^21].
claus
parents: 105
diff changeset
  1006
    (aSymbol == #send1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^22].
claus
parents: 105
diff changeset
  1007
    (aSymbol == #send2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^23].
claus
parents: 105
diff changeset
  1008
    (aSymbol == #send3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^24].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1009
106
claus
parents: 105
diff changeset
  1010
    (aSymbol == #sendSelf0) ifTrue:[lineno := true. extra := #index. stackDelta := 1. ^180].
claus
parents: 105
diff changeset
  1011
    (aSymbol == #sendSelf1) ifTrue:[lineno := true. extra := #index. ^181].
claus
parents: 105
diff changeset
  1012
    (aSymbol == #sendSelf2) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^182].
claus
parents: 105
diff changeset
  1013
    (aSymbol == #sendSelf3) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^183].
claus
parents: 105
diff changeset
  1014
    (aSymbol == #sendSelfDrop0) ifTrue:[lineno := true. extra := #index. ^184].
claus
parents: 105
diff changeset
  1015
    (aSymbol == #sendSelfDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^185].
claus
parents: 105
diff changeset
  1016
    (aSymbol == #sendSelfDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^186].
claus
parents: 105
diff changeset
  1017
    (aSymbol == #sendSelfDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^187].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1018
106
claus
parents: 105
diff changeset
  1019
    (aSymbol == #sendDrop) ifTrue:[lineno := true. extra := #special. ^25].
claus
parents: 105
diff changeset
  1020
    (aSymbol == #sendDrop0) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^26].
claus
parents: 105
diff changeset
  1021
    (aSymbol == #sendDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^27].
claus
parents: 105
diff changeset
  1022
    (aSymbol == #sendDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^28].
claus
parents: 105
diff changeset
  1023
    (aSymbol == #sendDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -4. ^29].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1024
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1025
    (aSymbol == #pushMethodVar1) ifTrue:[stackDelta := 1. ^80].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1026
    (aSymbol == #pushMethodVar2) ifTrue:[stackDelta := 1. ^81].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1027
    (aSymbol == #pushMethodVar3) ifTrue:[stackDelta := 1. ^82].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1028
    (aSymbol == #pushMethodVar4) ifTrue:[stackDelta := 1. ^83].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1029
    (aSymbol == #pushMethodVar5) ifTrue:[stackDelta := 1. ^84].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1030
    (aSymbol == #pushMethodVar6) ifTrue:[stackDelta := 1. ^85].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1031
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1032
    (aSymbol == #pushMethodArg1) ifTrue:[stackDelta := 1. ^86].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1033
    (aSymbol == #pushMethodArg2) ifTrue:[stackDelta := 1. ^87].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1034
    (aSymbol == #pushMethodArg3) ifTrue:[stackDelta := 1. ^88].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1035
    (aSymbol == #pushMethodArg4) ifTrue:[stackDelta := 1. ^89].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1036
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1037
    (aSymbol == #pushInstVar1) ifTrue:[stackDelta := 1. ^90].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1038
    (aSymbol == #pushInstVar2) ifTrue:[stackDelta := 1. ^91].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1039
    (aSymbol == #pushInstVar3) ifTrue:[stackDelta := 1. ^92].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1040
    (aSymbol == #pushInstVar4) ifTrue:[stackDelta := 1. ^93].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1041
    (aSymbol == #pushInstVar5) ifTrue:[stackDelta := 1. ^94].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1042
    (aSymbol == #pushInstVar6) ifTrue:[stackDelta := 1. ^95].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1043
    (aSymbol == #pushInstVar7) ifTrue:[stackDelta := 1. ^96].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1044
    (aSymbol == #pushInstVar8) ifTrue:[stackDelta := 1. ^97].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1045
    (aSymbol == #pushInstVar9) ifTrue:[stackDelta := 1. ^98].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1046
    (aSymbol == #pushInstVar10) ifTrue:[stackDelta := 1. ^99].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1047
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1048
    (aSymbol == #storeMethodVar1) ifTrue:[stackDelta := -1. ^100].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1049
    (aSymbol == #storeMethodVar2) ifTrue:[stackDelta := -1. ^101].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1050
    (aSymbol == #storeMethodVar3) ifTrue:[stackDelta := -1. ^102].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1051
    (aSymbol == #storeMethodVar4) ifTrue:[stackDelta := -1. ^103].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1052
    (aSymbol == #storeMethodVar5) ifTrue:[stackDelta := -1. ^104].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1053
    (aSymbol == #storeMethodVar6) ifTrue:[stackDelta := -1. ^105].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1054
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1055
    (aSymbol == #storeInstVar1) ifTrue:[stackDelta := -1. ^110].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1056
    (aSymbol == #storeInstVar2) ifTrue:[stackDelta := -1. ^111].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1057
    (aSymbol == #storeInstVar3) ifTrue:[stackDelta := -1. ^112].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1058
    (aSymbol == #storeInstVar4) ifTrue:[stackDelta := -1. ^113].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1059
    (aSymbol == #storeInstVar5) ifTrue:[stackDelta := -1. ^114].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1060
    (aSymbol == #storeInstVar6) ifTrue:[stackDelta := -1. ^115].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1061
    (aSymbol == #storeInstVar7) ifTrue:[stackDelta := -1. ^116].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1062
    (aSymbol == #storeInstVar8) ifTrue:[stackDelta := -1. ^117].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1063
    (aSymbol == #storeInstVar9) ifTrue:[stackDelta := -1. ^118].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1064
    (aSymbol == #storeInstVar10) ifTrue:[stackDelta := -1. ^119].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1065
103
claus
parents: 102
diff changeset
  1066
    (aSymbol == #pushLit1) ifTrue:[stackDelta := 1. ^ 222].
claus
parents: 102
diff changeset
  1067
    (aSymbol == #pushLit2) ifTrue:[stackDelta := 1. ^ 223].
claus
parents: 102
diff changeset
  1068
    (aSymbol == #pushLit3) ifTrue:[stackDelta := 1. ^ 224].
claus
parents: 102
diff changeset
  1069
    (aSymbol == #pushLit4) ifTrue:[stackDelta := 1. ^ 225].
claus
parents: 102
diff changeset
  1070
    (aSymbol == #pushLit5) ifTrue:[stackDelta := 1. ^ 226].
claus
parents: 102
diff changeset
  1071
    (aSymbol == #pushLit6) ifTrue:[stackDelta := 1. ^ 227].
claus
parents: 102
diff changeset
  1072
    (aSymbol == #pushLit7) ifTrue:[stackDelta := 1. ^ 228].
claus
parents: 102
diff changeset
  1073
    (aSymbol == #pushLit8) ifTrue:[stackDelta := 1. ^ 229].
claus
parents: 102
diff changeset
  1074
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1075
    (aSymbol == #retMethodVar1) ifTrue:[^160].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1076
    (aSymbol == #retMethodVar2) ifTrue:[^161].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1077
    (aSymbol == #retMethodVar3) ifTrue:[^162].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1078
    (aSymbol == #retMethodVar4) ifTrue:[^163].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1079
    (aSymbol == #retMethodVar5) ifTrue:[^164].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1080
    (aSymbol == #retMethodVar6) ifTrue:[^165].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1081
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1082
    (aSymbol == #retInstVar1) ifTrue:[^166].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1083
    (aSymbol == #retInstVar2) ifTrue:[^167].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1084
    (aSymbol == #retInstVar3) ifTrue:[^168].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1085
    (aSymbol == #retInstVar4) ifTrue:[^169].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1086
    (aSymbol == #retInstVar5) ifTrue:[^170].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1087
    (aSymbol == #retInstVar6) ifTrue:[^171].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1088
    (aSymbol == #retInstVar7) ifTrue:[^172].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1089
    (aSymbol == #retInstVar8) ifTrue:[^173].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1090
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1091
    (aSymbol == #retMethodArg1) ifTrue:[^174].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1092
    (aSymbol == #retMethodArg2) ifTrue:[^175].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1093
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1094
    (aSymbol == #pushBlockArg1) ifTrue:[stackDelta := 1. ^140].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1095
    (aSymbol == #pushBlockArg2) ifTrue:[stackDelta := 1. ^141].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1096
    (aSymbol == #pushBlockArg3) ifTrue:[stackDelta := 1. ^142].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1097
    (aSymbol == #pushBlockArg4) ifTrue:[stackDelta := 1. ^143].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1098
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1099
    (aSymbol == #pushOuter1BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 43].
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1100
    (aSymbol == #pushOuter2BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 44].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1101
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1102
    (aSymbol == #=) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^130].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1103
    (aSymbol == #+) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^131].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1104
    (aSymbol == #~=) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^132].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1105
    (aSymbol == #-) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^133].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1106
    (aSymbol == #*) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^230].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1107
    (aSymbol == #class) ifTrue:[extraLiteral := aSymbol. ^134].
400
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1108
"/    (aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. ^106].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1109
"/    (aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. ^107].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1110
"/    (aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. ^108].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1111
"/    (aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. ^109].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1112
"/    (aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. ^154].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1113
"/    (aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. ^155].
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1114
    (aSymbol == #at:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^135].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1115
    (aSymbol == #at:put:)ifTrue:[lineno := true. stackDelta := -2. extraLiteral := aSymbol. ^136].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1116
    (aSymbol == #bitAnd:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^137].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1117
    (aSymbol == #bitOr:) ifTrue:[lineno := true. stackDelta := -1. extraLiteral := aSymbol. ^138].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1118
    (aSymbol == #plus1) ifTrue:[lineno := true. extraLiteral := #+. ^123].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1119
    (aSymbol == #minus1) ifTrue:[lineno := true. extraLiteral := #-. ^124].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1120
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1121
    (aSymbol == #incMethodVar) ifTrue:[lineno := true. extraLiteral := #+. extra := #index. ^125].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1122
    (aSymbol == #decMethodVar) ifTrue:[lineno := true. extraLiteral := #-. extra := #index. ^126].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1123
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1124
    (aSymbol == #eq0) ifTrue:[extraLiteral := #==. ^48].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1125
    (aSymbol == #ne0) ifTrue:[extraLiteral := #~~. ^49].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1126
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1127
    (aSymbol == #>) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 145].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1128
    (aSymbol == #>=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 146].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1129
    (aSymbol == #<) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 147].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1130
    (aSymbol == #<=) ifTrue:[lineno := true. extraLiteral := aSymbol. stackDelta := -1. ^ 148].
400
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1131
"/    (aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 149].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1132
"/    (aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 150].
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1133
    (aSymbol == #value) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 151].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1134
    (aSymbol == #value:) ifTrue:[lineno := true. extraLiteral := aSymbol.  stackDelta := -1. ^ 152].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1135
    (aSymbol == #value:value:) ifTrue:[lineno := true. extraLiteral := aSymbol.  stackDelta := -2. ^ 178].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1136
    (aSymbol == #size) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 153].
400
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1137
"/    (aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 158].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1138
"/    (aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 159].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1139
    (aSymbol == #mk0Block) ifTrue:[^ 156].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1140
    (aSymbol == #mkNilBlock) ifTrue:[^ 157].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1141
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1142
    (aSymbol == #gt0) ifTrue:[lineno := true. extraLiteral := #>. ^ 212].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1143
    (aSymbol == #pushgt0) ifTrue:[lineno := true. stackDelta := 1. extraLiteral := #>. ^ 208].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1144
    (aSymbol == #basicNew) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 211].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1145
    (aSymbol == #new) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 213].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1146
    (aSymbol == #basicNew:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 214].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1147
    (aSymbol == #new:) ifTrue:[lineno := true. extraLiteral := aSymbol. ^ 215].
103
claus
parents: 102
diff changeset
  1148
217
eba0ee7232aa new opcodes
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
  1149
    (aSymbol == #pushBlockVar1) ifTrue:[stackDelta := 1. ^ 232].
eba0ee7232aa new opcodes
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
  1150
    (aSymbol == #pushBlockVar2) ifTrue:[stackDelta := 1. ^ 233].
eba0ee7232aa new opcodes
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
  1151
    (aSymbol == #pushBlockVar3) ifTrue:[stackDelta := 1. ^ 234].
eba0ee7232aa new opcodes
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
  1152
    (aSymbol == #storeBlockVar1) ifTrue:[stackDelta := -1. ^ 235].
eba0ee7232aa new opcodes
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
  1153
    (aSymbol == #storeBlockVar2) ifTrue:[stackDelta := -1. ^ 236].
eba0ee7232aa new opcodes
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
  1154
    (aSymbol == #storeBlockVar3) ifTrue:[stackDelta := -1. ^ 237].
eba0ee7232aa new opcodes
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
  1155
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1156
    (aSymbol == #falseJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 190].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1157
    (aSymbol == #trueJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 191].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1158
    (aSymbol == #nilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 192].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1159
    (aSymbol == #notNilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 193].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1160
    (aSymbol == #jumpabs) ifTrue:[extra := #absoffset. ^ 194].
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1161
    (aSymbol == #makeBlockabs) ifTrue:[stackDelta := 1. extra := #absoffsetNvarNarg. ^ 195].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1162
    (aSymbol == #zeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 196].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1163
    (aSymbol == #notZeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 197].
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1164
    (aSymbol == #eqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 198].
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1165
    (aSymbol == #notEqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 199].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1166
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1167
    (aSymbol == #pushThisContext) ifTrue:[stackDelta := 1. ^ 144].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1168
76
55d64cb1ffea *** empty log message ***
claus
parents: 54
diff changeset
  1169
    (aSymbol == #isNil) ifTrue:[^ 188].
55d64cb1ffea *** empty log message ***
claus
parents: 54
diff changeset
  1170
    (aSymbol == #notNil) ifTrue:[^ 189].
55d64cb1ffea *** empty log message ***
claus
parents: 54
diff changeset
  1171
    (aSymbol == #not) ifTrue:[lineno := true. ^ 179].
110
claus
parents: 109
diff changeset
  1172
    (aSymbol == #&) ifTrue:[lineno := true. ^ 216].
claus
parents: 109
diff changeset
  1173
    (aSymbol == #|) ifTrue:[lineno := true. ^ 217].
76
55d64cb1ffea *** empty log message ***
claus
parents: 54
diff changeset
  1174
117
claus
parents: 111
diff changeset
  1175
    (aSymbol == #pushClassVarL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
claus
parents: 111
diff changeset
  1176
    (aSymbol == #pushGlobalL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
claus
parents: 111
diff changeset
  1177
    (aSymbol == #storeClassVarL) ifTrue:[extra := #speciallitL.stackDelta := -1. ^ 219].
claus
parents: 111
diff changeset
  1178
    (aSymbol == #storeGlobalL) ifTrue:[extra := #speciallitL. stackDelta := -1. ^ 219].
claus
parents: 111
diff changeset
  1179
    (aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201].
claus
parents: 111
diff changeset
  1180
claus
parents: 111
diff changeset
  1181
    (aSymbol == #sendL) ifTrue:[lineno := true. extra := #specialL. ^ 205].
claus
parents: 111
diff changeset
  1182
    (aSymbol == #sendSelfL) ifTrue:[lineno := true. extra := #specialL. ^ 207].
claus
parents: 111
diff changeset
  1183
    (aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #specialL. ^ 204].
claus
parents: 111
diff changeset
  1184
    (aSymbol == #superSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
claus
parents: 111
diff changeset
  1185
    (aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
106
claus
parents: 105
diff changeset
  1186
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1187
    (aSymbol == #top) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1188
    (aSymbol == #bottom) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1189
    (aSymbol == #left) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1190
    (aSymbol == #right) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1191
400
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1192
    (aSymbol == #x) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1193
    (aSymbol == #y) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1194
    (aSymbol == #width) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1195
    (aSymbol == #height) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1196
    (aSymbol == #origin) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1197
    (aSymbol == #extent) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1198
    (aSymbol == #next) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1199
    (aSymbol == #peek) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1200
    (aSymbol == #asInteger) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1201
    (aSymbol == #rounded) ifTrue:[lineno := true. extraLiteral := aSymbol. extra := #specialSend. ^ 231].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1202
217
eba0ee7232aa new opcodes
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
  1203
    (aSymbol == #blockRef) ifTrue:[stackDelta := 0. ^ 238].
eba0ee7232aa new opcodes
Claus Gittinger <cg@exept.de>
parents: 215
diff changeset
  1204
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1205
    self error:'invalid code symbol'.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1206
    errorFlag := #Error
117
claus
parents: 111
diff changeset
  1207
claus
parents: 111
diff changeset
  1208
    "Modified: 3.9.1995 / 12:58:47 / claus"
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
  1209
    "Modified: 21.10.1996 / 11:16:10 / cg"
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1210
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1211
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1212
checkForCommonCode:symbolicCodeArray
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1213
    "hook to return the code for common code sequences.
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1214
     This reduces the in-memory number of byteArrays somewhat.
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1215
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1216
     Not yet fully implemented - just an idea ... theres certainly more to do here
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1217
     (does it make sense to scan all methods, collect code in a set and unify things
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1218
      automatically in the background - or upon request ?)"
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1219
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1220
    |sz insn1|
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1221
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1222
    (sz := symbolicCodeArray size) == 2 ifTrue:[
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1223
	"/
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1224
	"/ a very common sequence: return the first literal
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1225
	"/
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1226
	(insn1 := symbolicCodeArray at:1) == #pushLit1 ifTrue:[
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1227
	    (symbolicCodeArray at:2) == #retTop ifTrue:[
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1228
		^ #[222 0]
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1229
	    ]
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1230
	]
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1231
    ].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1232
    sz == 1 ifTrue:[
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1233
	"/
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1234
	"/ another common sequence: return the receiver
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1235
	"/
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1236
	(insn1 := symbolicCodeArray at:1) == #retSelf ifTrue:[
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1237
	    ^ #[5]
212
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1238
	].
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1239
	insn1 == #retTrue ifTrue:[
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1240
	    ^ #[2]
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1241
	].
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1242
	insn1 == #retFalse ifTrue:[
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1243
	    ^ #[3]
ff39051e219f more constant folding options
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
  1244
	].
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1245
    ].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1246
    ^ nil
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1247
!
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1248
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1249
checkForPrimitiveCode:nr
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1250
    "return the code for an ST-80 primitive method.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1251
     Since many primitives available on ST-80 should also be available
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1252
     somewhere in ST/X, this may work for many primitive numbers.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1253
     However, more information is needed and more things to be added below.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1254
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1255
     This was added to allow emulation of (some) ST-80
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1256
     primitives (to fileIn RemoteInvocation & Monitor41 packages)"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1257
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1258
    |cls sel|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1259
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1260
    (nr == 75)  ifTrue:[ cls := Object. sel := #identityHash ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1261
    (nr == 110) ifTrue:[ cls := Object. sel := #==           ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1262
    (nr == 111) ifTrue:[ cls := Object. sel := #class        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1263
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1264
     should add more here, to be able to fileIn ST-80 methods
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1265
     containing primitive calls (who gives me the numbers ... ?)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1266
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1267
    cls notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1268
	^ (cls compiledMethodAt:sel) code
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1269
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1270
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1271
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1272
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1273
createMethod
292
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  1274
    |newMethod i|
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1275
292
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  1276
    newMethod := Method new:(litArray size).
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  1277
    litArray notNil ifTrue:[
383
fc4b30e5e511 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
  1278
        "/ fixup CheapBlocks method-field in literal array,
fc4b30e5e511 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
  1279
        litArray do:[:aLiteral |
fc4b30e5e511 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
  1280
            (aLiteral isMemberOf:CheapBlock) ifTrue:[
fc4b30e5e511 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
  1281
                aLiteral setMethod:newMethod.
fc4b30e5e511 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
  1282
            ]
fc4b30e5e511 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
  1283
        ].
292
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  1284
        newMethod literals:litArray
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1285
    ].
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1286
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1287
    newMethod numberOfMethodVars:(self numberOfMethodVars).
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1288
    newMethod numberOfMethodArgs:(self numberOfMethodArgs).
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1289
    newMethod stackSize:(self maxStackDepth).
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1290
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1291
    primitiveResource notNil ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1292
        newMethod setResourceFlag
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1293
    ].
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1294
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1295
    ^ newMethod
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1296
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1297
    "Created: 18.5.1996 / 16:33:17 / cg"
292
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  1298
    "Modified: 24.6.1996 / 12:32:50 / stefan"
383
fc4b30e5e511 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 372
diff changeset
  1299
    "Modified: 21.10.1996 / 13:58:41 / cg"
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1300
!
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1301
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1302
genByteCodeFrom:symbolicCodeArray
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1303
    "convert symbolicCode into bytecodes"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1304
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1305
    |symIndex    "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1306
     codeSize    "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1307
     symCodeSize "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1308
     index addr
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1309
     codeSymbol nargs needRetry
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1310
     stackDepth relocInfo level nvars round t|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1311
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1312
    symbolicCodeArray isNil ifTrue:[^ self].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1313
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1314
    round := 0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1315
    needRetry := true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1316
    symCodeSize := symbolicCodeArray size.
192
5f5ecdcffc67 share common byteCodes - just an idea and more is needed for most compact code
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
  1317
    ShareCode ifTrue:[
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1318
        codeBytes := self checkForCommonCode:symbolicCodeArray.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1319
        codeBytes notNil ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1320
            ^ self
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1321
        ].
192
5f5ecdcffc67 share common byteCodes - just an idea and more is needed for most compact code
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
  1322
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1323
    codeSize := symCodeSize.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1324
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1325
    [needRetry] whileTrue:[
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1326
        stackDepth := 0.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1327
        maxStackDepth := 0.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1328
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1329
        codeBytes := ByteArray uninitializedNew:codeSize.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1330
        relocInfo := Array basicNew:(codeSize + 1).
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1331
        symIndex := 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1332
        codeIndex := 1.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1333
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1334
        needRetry := false.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1335
        round := round + 1.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1336
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1337
        [symIndex <= symCodeSize] whileTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1338
            relocInfo at:symIndex put:codeIndex.
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1339
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1340
            codeSymbol := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1341
            symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1342
            stackDelta := 0.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1343
            extra := extraLiteral := nil.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1344
            lineno := false.
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1345
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1346
            self appendByteCodeFor:codeSymbol.
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1347
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1348
            extraLiteral notNil ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1349
                self addLiteral:extraLiteral
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1350
            ].
246
abf09d4821fe new code for faster global pushes
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
  1351
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1352
            lineno ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1353
                self appendByte:((symbolicCodeArray at:symIndex) min:255).
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
  1354
                symIndex := symIndex + 1.
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
  1355
                codeSymbol == #lineno16 ifTrue:[
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
  1356
                    self appendByte:((symbolicCodeArray at:symIndex) min:255).
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
  1357
                    symIndex := symIndex + 1
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
  1358
                ]
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1359
            ].
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1360
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1361
            extra notNil ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1362
                (extra == #number) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1363
                    index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1364
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1365
                    self appendSignedByte:index
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1366
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1367
                ] ifFalse:[ (extra == #number16) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1368
                    index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1369
                    symIndex := symIndex + 2.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1370
                    self appendSignedWord:index
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1371
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1372
                ] ifFalse:[ (extra == #unsigned16) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1373
                    index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1374
                    symIndex := symIndex + 2.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1375
                    self appendWord:index
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1376
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1377
                ] ifFalse:[ (extra == #index) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1378
                    index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1379
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1380
                    self appendByte:index
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1381
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1382
                ] ifFalse:[ (extra == #lit) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1383
                    index := self addLiteral:(symbolicCodeArray at:symIndex).
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1384
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1385
                    self appendByte:index
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1386
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1387
                ] ifFalse:[ (extra == #speciallit) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1388
                    index := self addLiteral:(symbolicCodeArray at:symIndex).
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1389
                    index > 255 ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1390
                        self parseError:'too many globals (' , 
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1391
                                        (symbolicCodeArray at:symIndex) ,
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1392
                                        ' index=' , index printString ,
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1393
                                        ') in method - please simplify'.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1394
                        ^ #Error
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1395
                    ].
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1396
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1397
                    self appendByte:index.
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1398
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1399
                ] ifFalse:[ (extra == #speciallitS) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1400
                    index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1401
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1402
                    self appendByte:index.
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1403
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1404
                ] ifFalse:[ (extra == #speciallitL) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1405
                    index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1406
                    symIndex := symIndex + 2.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1407
                    self appendWord:index.
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1408
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1409
                ] ifFalse:[ (extra == #offset) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1410
                    relocInfo at:symIndex put:codeIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1411
                    self addReloc:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1412
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1413
                    self appendByte:0
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1414
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1415
                ] ifFalse:[ (extra == #indexLevel) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1416
                    index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1417
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1418
                    self appendByte:index.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1419
                    level := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1420
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1421
                    self appendByte:level
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1422
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1423
                ] ifFalse:[ (extra == #offsetNvarNarg) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1424
                    relocInfo at:symIndex put:codeIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1425
                    self addReloc:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1426
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1427
                    self appendEmptyByte.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1428
                    nvars := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1429
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1430
                    self appendByte:nvars.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1431
                    level := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1432
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1433
                    self appendByte:level
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1434
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1435
                ] ifFalse:[ (extra == #absoffset) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1436
                    relocInfo at:symIndex put:codeIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1437
                    self addReloc:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1438
                    addr := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1439
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1440
                    self appendByte:(addr bitAnd:16rFF).
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1441
                    self appendByte:((addr bitShift:-8) bitAnd:16rFF).
199
1b3b350a3f59 moved bytecode query methods into compiler;
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
  1442
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1443
                ] ifFalse:[ (extra == #absoffsetNvarNarg) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1444
                    relocInfo at:symIndex put:codeIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1445
                    self addReloc:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1446
                    addr := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1447
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1448
                    self appendByte:(addr bitAnd:16rFF).
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1449
                    self appendByte:((addr bitShift:-8) bitAnd:16rFF).
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1450
                    nvars := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1451
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1452
                    self appendByte:nvars.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1453
                    level := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1454
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1455
                    self appendByte:level
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1456
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1457
                ] ifFalse:[ (extra == #special) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1458
                    ((codeSymbol == #send) 
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1459
                     or:[codeSymbol == #sendSelf
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1460
                     or:[codeSymbol == #superSend
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1461
                     or:[codeSymbol == #hereSend]]]) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1462
                        index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1463
                        symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1464
                        nargs := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1465
                        symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1466
                        self appendByte:nargs.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1467
                        self appendByte:index.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1468
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1469
                        (codeSymbol == #superSend
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1470
                        or:[codeSymbol == #hereSend]) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1471
                            index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1472
                            symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1473
                            self appendByte:index
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1474
                        ].
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1475
                        stackDelta := nargs negated.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1476
                        codeSymbol == #sendSelf ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1477
                            stackDelta := stackDelta + 1
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1478
                        ]
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1479
                    ] ifFalse:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1480
                        (codeSymbol == #sendDrop) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1481
                            index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1482
                            symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1483
                            nargs := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1484
                            symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1485
                            self appendByte:nargs.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1486
                            self appendByte:index.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1487
                            stackDelta := (nargs + 1) negated
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1488
                        ]
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1489
                    ]
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1490
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1491
                ] ifFalse:[ (extra == #specialL) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1492
                    ((codeSymbol == #sendL) 
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1493
                     or:[codeSymbol == #sendSelfL
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1494
                     or:[codeSymbol == #superSendL
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1495
                     or:[codeSymbol == #hereSendL]]]) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1496
                        index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1497
                        symIndex := symIndex + 2.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1498
                        nargs := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1499
                        symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1500
                        self appendByte:nargs.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1501
                        self appendWord:index.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1502
                        (codeSymbol == #superSendL
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1503
                        or:[codeSymbol == #hereSendL]) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1504
                            index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1505
                            symIndex := symIndex + 2.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1506
                            self appendWord:index.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1507
                        ].
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1508
                        stackDelta := nargs negated.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1509
                        codeSymbol == #sendSelfL ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1510
                            stackDelta := stackDelta + 1
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1511
                        ]
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1512
                    ]
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1513
                ] ifFalse:[ (extra == #specialSend) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1514
                    index := symbolicCodeArray at:symIndex.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1515
                    symIndex := symIndex + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1516
                    self appendByte:index.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1517
                ]]]]]]]]]]]]]]]]
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1518
            ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1519
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1520
            stackDepth := stackDepth + stackDelta.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1521
            (stackDepth > maxStackDepth) ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1522
                maxStackDepth := stackDepth
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1523
            ]
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1524
        ].
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1525
        relocInfo at:symIndex put:codeIndex.
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1526
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1527
        needRetry ifFalse:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1528
            "
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1529
             now relocate - returns true if ok, false if we have to do it again
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1530
             (when short jumps have been changed to long jumps)
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1531
            "
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1532
            relocList notNil ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1533
                needRetry := (self relocateWith:symbolicCodeArray relocInfo:relocInfo) not.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1534
                "
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1535
                 if returned with false, a relative jump was made into
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1536
                 an absolute jump - need to start over with one more byte space
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1537
                "
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1538
                needRetry ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1539
                    relocList := nil.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1540
                    codeSize := codeSize + 1.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1541
                ]
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1542
            ]
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1543
        ] ifTrue:[
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1544
            'compiling again ...' infoPrintCR.
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  1545
        ]
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1546
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1547
    "code printNL."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1548
    ^ errorFlag
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1549
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1550
    "Modified: 3.9.1995 / 12:59:43 / claus"
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
  1551
    "Modified: 21.10.1996 / 11:17:33 / cg"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1552
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1553
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1554
genSymbolicCode
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1555
    "traverse the parse-tree producing symbolicCode - return the codeArray"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1556
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1557
    |codeStream code thisStatement lastStatement|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1558
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1559
    litArray := nil.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1560
    codeStream := WriteStream on:(OrderedCollection new:100).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1561
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1562
    thisStatement := tree.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1563
    [thisStatement notNil] whileTrue:[
328
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1564
        lastStatement := thisStatement.
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1565
        thisStatement codeForSideEffectOn:codeStream inBlock:nil for:self.
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1566
        thisStatement := thisStatement nextStatement
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1567
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1568
    (lastStatement isNil or:[lastStatement isReturnNode not])
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1569
    ifTrue:[
328
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1570
        "not a return - add retSelf"
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1571
        "
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1572
         if the last statement was a send for side-effect,
330
9b9a1ff67ba3 Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents: 328
diff changeset
  1573
         replace the previous drop by a retSelf.
9b9a1ff67ba3 Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents: 328
diff changeset
  1574
         In this case we have to keep an extra retSelf bacause
9b9a1ff67ba3 Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents: 328
diff changeset
  1575
         it could be a jump target.
328
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1576
        "
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1577
        (lastStatement notNil 
330
9b9a1ff67ba3 Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents: 328
diff changeset
  1578
         and:[(code := codeStream contents) notNil
9b9a1ff67ba3 Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents: 328
diff changeset
  1579
         and:[code size > 0
9b9a1ff67ba3 Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents: 328
diff changeset
  1580
         and:[code last == #drop]]]) ifTrue:[
9b9a1ff67ba3 Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents: 328
diff changeset
  1581
            codeStream backStep.
9b9a1ff67ba3 Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents: 328
diff changeset
  1582
            codeStream nextPut:#retSelf
328
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1583
        ]. 
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1584
        codeStream nextPut:#retSelf
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1585
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1586
    ^ codeStream contents
328
c63c54ff95d3 Optimize double #retSelf.
Stefan Vogel <sv@exept.de>
parents: 325
diff changeset
  1587
330
9b9a1ff67ba3 Bad change in previous version. Need extra bytecode as jump target.
Stefan Vogel <sv@exept.de>
parents: 328
diff changeset
  1588
    "Modified: 15.8.1996 / 17:35:02 / stefan"
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1589
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1590
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1591
hasLineNumber:sel
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1592
    "return true, if special send code needs lineNr"
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1593
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1594
    (sel == #==) ifTrue:[^ false].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1595
    (sel == #~~) ifTrue:[^ false].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1596
    (sel == #class) ifTrue:[^ false].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1597
    (sel == #isNil) ifTrue:[^ false].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1598
    (sel == #notNil) ifTrue:[^ false].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1599
    ^ true
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1600
!
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1601
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1602
isBuiltIn1ArgSelector:sel forReceiver:receiver
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1603
    "return true, if selector sel is built-in.
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1604
     (i.e. there is a single bytecode for it)"
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1605
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1606
    (sel == #at:) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1607
    (sel == #value:) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1608
    (sel == #bitAnd:) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1609
    (sel == #bitOr:) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1610
    (sel == #new:) ifTrue:[^ true].
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1611
    (sel == #basicNew:) ifTrue:[
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1612
        "/ this one is critical - some redefine it
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1613
        receiver isGlobal ifTrue:[
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1614
            (#('String' 'ByteArray' 'Array'
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1615
              'Point' 'Rectangle' 'Object')
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1616
            includes:receiver name) ifTrue:[^ true].
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1617
        ].
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1618
    ].
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1619
    ^ false
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1620
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1621
    "Created: 17.4.1996 / 22:33:13 / cg"
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1622
    "Modified: 17.4.1996 / 22:38:08 / cg"
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1623
!
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1624
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1625
isBuiltIn2ArgSelector:sel forReceiver:receiver
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1626
    "return true, if selector sel is built-in.
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1627
     (i.e. there is a single bytecode for it)"
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1628
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1629
    (sel == #at:put:) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1630
    ^ false
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1631
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1632
    "Created: 17.4.1996 / 22:33:16 / cg"
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1633
!
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1634
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1635
isBuiltInBinarySelector:sel forReceiver:receiver
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1636
    sel == #== ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1637
    sel == #~~ ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1638
    sel == #= ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1639
    sel == #~= ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1640
    sel == #+ ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1641
    sel == #- ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1642
    sel == #< ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1643
    sel == #<= ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1644
    sel == #> ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1645
    sel == #>= ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1646
    sel == #* ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1647
    sel == #& ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1648
    sel == #| ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1649
    ^ false
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1650
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1651
    "Created: 17.4.1996 / 22:34:27 / cg"
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1652
!
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1653
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1654
isBuiltInUnarySelector:sel forReceiver:receiver
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1655
    "return true, if unary selector sel is built-in. 
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1656
     (i.e. there is a single bytecode for it)"
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1657
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1658
    (sel == #value) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1659
    (sel == #class) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1660
    (sel == #size) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1661
    (sel == #isNil) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1662
    (sel == #notNil) ifTrue:[^ true].
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1663
    (sel == #not) ifTrue:[^ true].
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1664
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1665
    (sel == #new) ifTrue:[^ true].
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1666
    (sel == #basicNew) ifTrue:[
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1667
        "/ this one is critical - some redefine it
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1668
        receiver isGlobal ifTrue:[
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1669
            (#('String' 'ByteArray' 'Array'
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1670
              'Point' 'Rectangle' 'Object')
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1671
            includes:receiver name) ifTrue:[^ true].
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1672
        ].
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1673
    ].
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1674
    ^ false
253
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1675
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1676
    "Created: 17.4.1996 / 22:32:16 / cg"
759ba0ddb672 oops - must check for receiver when attempting built-in basicNew
Claus Gittinger <cg@exept.de>
parents: 247
diff changeset
  1677
    "Modified: 17.4.1996 / 22:38:14 / cg"
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1678
!
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1679
247
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1680
isSpecialGlobalSymbol:nm
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1681
    "return true, if unary selector sel is a special selector"
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1682
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1683
    ^ #(Array String FloatArray DoubleArray
325
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1684
        Point Symbol Smalltalk Processor
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1685
        SmallInteger Character Float 
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1686
        Process 
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1687
        Set IdentitySet Dictionary IdentityDictionary 
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1688
        Sempahore 
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1689
        OrderedCollection 
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1690
       ) includesIdentical:nm
247
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1691
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1692
    "Created: 13.4.1996 / 20:15:35 / cg"
325
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1693
    "Modified: 5.8.1996 / 16:56:58 / cg"
247
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1694
!
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1695
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1696
isSpecialSendSelector:sel
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1697
    "return true, if unary selector sel is a special selector"
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1698
400
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1699
    ^ (self specialSendCodeFor:sel) notNil
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1700
!
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1701
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1702
moveGlobalsToFront
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1703
    "move all global-literals to the front of the literal array.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1704
     This may be the last chance to compile the method, since
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1705
     for globals, the maximum literal index is 255 - while for normal
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1706
     literals its a stress-less 65535"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1707
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1708
    litArray isNil ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1709
	^ self error:'oops compiler botch'.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1710
    ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1711
    litArray sort:[:a :b |   "a < b -> #(a b)"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1712
		   (a isMemberOf:Symbol) ifFalse:[false]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1713
		   ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1714
		      (b isMemberOf:Symbol) ifFalse:[true]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1715
		      ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1716
			(a at:1) isUppercase ifFalse:[false]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1717
			ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1718
			  (b at:1) isUppercase ifFalse:[true]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1719
			  ifTrue:[a < b].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1720
			]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1721
		      ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1722
		    ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1723
		   ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1724
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1725
"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1726
    #(#A #c #B #D #E #a #b #F)
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1727
     sort:[:a :b |  
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1728
		   (a isMemberOf:Symbol) ifFalse:[false]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1729
		   ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1730
		      (b isMemberOf:Symbol) ifFalse:[true]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1731
		      ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1732
			(a at:1) isUppercase ifFalse:[false]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1733
			ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1734
			  (b at:1) isUppercase ifFalse:[true]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1735
			  ifTrue:[(a < b)].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1736
			]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1737
		      ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1738
		    ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1739
		   ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1740
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1741
"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1742
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1743
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1744
relocateWith:symbolicCodeArray relocInfo:relocInfo
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1745
    "helper for genByteCodeFrom - relocate code using relocInfo.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1746
     if relocation fails badly (due to long relative jumps) patch
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1747
     symbolicCode to use absolute jumps instead and return false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1748
     (genByteCodeFrom will then try again). Otherwise return true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1749
     Also, on the fly, jumps to jumps and jumps to return are handled."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1750
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1751
    |delta       "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1752
     codePos     "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1753
     opCodePos   "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1754
     codeOffset  "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1755
     symOffset 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1756
     opcode      "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1757
     dstOpcode jumpTarget
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1758
     jumpCode deleteSet|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1759
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1760
    deleteSet := OrderedCollection new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1761
    relocList do:[:sIndex |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1762
	"have to relocate symCode at sIndex ..." 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1763
	symOffset := symbolicCodeArray at:sIndex.   "the target in the symbolic code"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1764
	codePos := relocInfo at:sIndex.             "position of the offet in byte code"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1765
	codeOffset := relocInfo at:symOffset.       "position of the target in byte code"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1766
	delta := codeOffset - codePos - 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1767
	opCodePos := codePos - 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1768
	opcode := codeBytes at:opCodePos.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1769
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1770
	(opcode between:190 and:199) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1771
	    "an absolute jump/makeBlock"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1772
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1773
	    codeBytes at:codePos put:(codeOffset bitAnd:16rFF).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1774
	    codeBytes at:(codePos + 1) put:(codeOffset bitShift:-8)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1775
	] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1776
	    "get jump-code from long and vlong codes"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1777
	    (opcode between:50 and:59) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1778
		(opcode between:60 and:69) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1779
		    opcode := opcode - 10
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1780
		] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1781
		    (opcode between:70 and:79) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1782
			opcode := opcode - 20
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1783
		    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1784
			self error:'invalid code to relocate'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1785
		    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1786
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1787
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1788
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1789
	    "optimize jump to return and jump to jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1790
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1791
	    (opcode == 54) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1792
		"a jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1793
		dstOpcode := symbolicCodeArray at:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1794
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1795
		(#(retSelf retTop retNil retTrue retFalse ret0 "blockRetTop") includes:dstOpcode) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1796
		    "a jump to a return - put in the return instead jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1797
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1798
		    symbolicCodeArray at:(sIndex - 1) put:dstOpcode.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1799
		    symbolicCodeArray at:sIndex put:dstOpcode.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1800
		    codeBytes at:opCodePos put:(self byteCodeFor:dstOpcode).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1801
		    delta := 0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1802
		    deleteSet add:sIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1803
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1804
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1805
'jump to return at: ' print. (sIndex - 1) printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1806
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1807
		] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1808
		    (dstOpcode == #jump) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1809
			"jump to jump to be done soon"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1810
			jumpTarget := symbolicCodeArray at:(symOffset + 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1811
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1812
'jump to jump at: ' print. (sIndex - 1) print.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1813
'  newTarget:' print. jumpTarget printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1814
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1815
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1816
			symbolicCodeArray at:sIndex put:jumpTarget.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1817
			symOffset := jumpTarget.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1818
			codeOffset := relocInfo at:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1819
			delta := codeOffset - codePos - 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1820
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1821
			"continue with new delta"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1822
		    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1823
		]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1824
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1825
	    (#(50 51 52 53 56 57 58 59) includes:opcode) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1826
		"a conditional jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1827
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1828
		dstOpcode := symbolicCodeArray at:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1829
		(dstOpcode == #jump) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1830
		    "conditional jump to unconditional jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1831
		    jumpTarget := symbolicCodeArray at:(symOffset + 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1832
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1833
'cond jump to jump at: ' print. (sIndex - 1) print.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1834
'  newTarget:' print. jumpTarget printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1835
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1836
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1837
		    symbolicCodeArray at:sIndex put:jumpTarget.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1838
		    symOffset := jumpTarget.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1839
		    codeOffset := relocInfo at:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1840
		    delta := codeOffset - codePos - 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1841
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1842
		    "continue with new delta"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1843
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1844
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1845
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1846
	    (delta >= 0) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1847
		(delta > 127) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1848
		    (opcode between:50 and:59) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1849
			self error:'invalid code to relocate'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1850
		    ] ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1851
			(delta > 255) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1852
			    "change jmp into vljmp ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1853
			    codeBytes at:opCodePos put:(opcode + 20).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1854
			    delta := delta - 256 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1855
			] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1856
			    "change jmp into ljmp ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1857
			    codeBytes at:opCodePos put:(opcode + 10).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1858
			    delta := delta - 128
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1859
			].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1860
			(delta > 127) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1861
			    "change symbolic into a jump absolute and fail"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1862
			    jumpCode := symbolicCodeArray at:(sIndex - 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1863
			    symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1864
			    symbolicCodeArray at:sIndex put:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1865
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1866
'change short into abs jump' printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1867
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1868
			    deleteSet do:[:d | relocList remove:d].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1869
			    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1870
			]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1871
		    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1872
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1873
		codeBytes at:codePos put:delta
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1874
	    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1875
		(delta < -128) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1876
		    (opcode between:50 and:59) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1877
			self error:'invalid code to relocate'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1878
		    ] ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1879
			(delta < -256) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1880
			    "change jmp into vljmp ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1881
			    codeBytes at:opCodePos put:(opcode + 20).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1882
			    delta := delta + 256
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1883
			] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1884
			    "change jmp into ljmp ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1885
			    codeBytes at:opCodePos put:(opcode + 10).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1886
			    delta := delta + 128
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1887
			].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1888
			(delta < -128) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1889
			    "change symbolic into a jump absolute and fail"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1890
			    jumpCode := symbolicCodeArray at:(sIndex - 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1891
			    symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1892
			    symbolicCodeArray at:sIndex put:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1893
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1894
'change short into abs jump' printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1895
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1896
			    deleteSet do:[:d | relocList remove:d].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1897
			    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1898
			]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1899
		    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1900
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1901
		codeBytes at:codePos put:(256 + delta)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1902
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1903
	]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1904
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1905
    (errorFlag == #Error) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1906
	self error:'relocation range error'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1907
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1908
    ^ true
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1909
!
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1910
247
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1911
specialGlobalCodeFor:aSymbol
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1912
    aSymbol == #Array ifTrue:[^ 0].
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1913
    aSymbol == #String ifTrue:[^ 1].
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1914
    aSymbol == #FloatArray ifTrue:[^ 2].
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1915
    aSymbol == #DoubleArray ifTrue:[^ 3].
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1916
    aSymbol == #Point ifTrue:[^ 4].
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1917
    aSymbol == #Symbol ifTrue:[^ 5].
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1918
    aSymbol == #Smalltalk ifTrue:[^ 6].
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1919
    aSymbol == #Processor ifTrue:[^ 7].
325
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1920
    aSymbol == #SmallInteger ifTrue:[^ 8].
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1921
    aSymbol == #Character ifTrue:[^ 9].
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1922
    aSymbol == #Float ifTrue:[^ 10].
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1923
    aSymbol == #Process ifTrue:[^ 11].
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1924
    aSymbol == #Set ifTrue:[^ 12].
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1925
    aSymbol == #IdentitySet ifTrue:[^ 13].
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1926
    aSymbol == #Dictionary ifTrue:[^ 14].
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1927
    aSymbol == #IdentityDictionary ifTrue:[^ 15].
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1928
    aSymbol == #Sempahore ifTrue:[^ 16].
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1929
    aSymbol == #OrderedCollection ifTrue:[^ 17].
247
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1930
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1931
    self error:'invalid special global symbol'.
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1932
    errorFlag := #Error
325
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1933
c94aaca6f94c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  1934
    "Modified: 5.8.1996 / 16:51:45 / cg"
247
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1935
!
fbb6e3b5764c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 246
diff changeset
  1936
400
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1937
specialSendCodeFor:sel
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1938
    sel == #top    ifTrue:[^ 0].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1939
    sel == #bottom ifTrue:[^ 1].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1940
    sel == #left   ifTrue:[^ 2].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1941
    sel == #right  ifTrue:[^ 3].
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  1942
400
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1943
    sel == #x      ifTrue:[^ 4].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1944
    sel == #y      ifTrue:[^ 5].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1945
    sel == #width  ifTrue:[^ 6].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1946
    sel == #height ifTrue:[^ 7].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1947
    sel == #origin ifTrue:[^ 8].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1948
    sel == #extent ifTrue:[^ 9].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1949
    sel == #asInteger ifTrue:[^ 10].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1950
    sel == #rounded   ifTrue:[^ 11].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1951
    sel == #next   ifTrue:[^ 12].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1952
    sel == #peek   ifTrue:[^ 13].
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1953
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  1954
    ^ nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1955
! !
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1956
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1957
!ByteCodeCompiler methodsFor:'machine code generation'!
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1958
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1959
compileToMachineCode:aString forClass:aClass inCategory:cat 
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1960
                             notifying:requestor install:install skipIfSame:skipIfSame silent:silent
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1961
    "this is called to compile primitive code.
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1962
     This is EXPERIMENTAL and going to be changed to raise an error,
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1963
     an redefined in subclasses which can do it (either by direct compilation, or by calling
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1964
     the external stc do do it.
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1965
     For a description of the arguments, see compile:forClass....."
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1966
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  1967
    |stFileName stream handle address flags command oFileName 
120
claus
parents: 118
diff changeset
  1968
     initName newMethod ok status className sep class stcPath 
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1969
     errorStream errorMessages eMsg m supers mP moduleFileName|
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1970
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1971
    (mP := STCModulePath asFilename) exists ifFalse:[
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1972
       mP makeDirectory
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1973
    ].
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1974
    (mP isDirectory 
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1975
    and:[mP isReadable
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1976
    and:[mP isWritable]]) ifFalse:[
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1977
        self parseError:('no access to tempDir: ' , mP pathName) position:1.
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1978
        ^ #CannotLoad
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1979
    ].
96
claus
parents: 95
diff changeset
  1980
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1981
    ObjectFileLoader isNil ifTrue:[^ #CannotLoad].
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1982
    STCCompilation == #never ifTrue:[^ #CannotLoad].
120
claus
parents: 118
diff changeset
  1983
    (stcPath := self class incrementalStcPath) isNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1984
        self parseError:'no stc compiler available - cannot create machine code' position:1.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1985
        ^ #CannotLoad
120
claus
parents: 118
diff changeset
  1986
    ].
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1987
298
118648c3b590 include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  1988
    "/ generate a unique name, consisting of my processID and a sequence number
118648c3b590 include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  1989
    "/ the processId is added to allow filein of modules from different
118648c3b590 include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  1990
    "/ lifes
118648c3b590 include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  1991
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1992
    SequenceNumber isNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  1993
        SequenceNumber := 0.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1994
    ].
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1995
    SequenceNumber := SequenceNumber + 1.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1996
298
118648c3b590 include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  1997
    initName := 'm_' , OperatingSystem getProcessId printString, '_' , SequenceNumber printString.
118648c3b590 include the processID in the dynamic modules name;
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  1998
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  1999
    stFileName := './' , initName , '.st'. 
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2000
    stream := stFileName asFilename writeStream.
187
8aa7dd9bb1e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 182
diff changeset
  2001
    stream isNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2002
        self parseError:'cannot create temporary sourcefile for compilation'.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2003
        ^ #CannotLoad
187
8aa7dd9bb1e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 182
diff changeset
  2004
    ].
97
claus
parents: 96
diff changeset
  2005
    sep := stream class chunkSeparator.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2006
101
claus
parents: 98
diff changeset
  2007
    class := aClass.
claus
parents: 98
diff changeset
  2008
    class isMeta ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2009
        class := aClass soleInstance
101
claus
parents: 98
diff changeset
  2010
    ].
235
8dde5344f785 oops - did not incrementally compile class-methods (shame on me)
Claus Gittinger <cg@exept.de>
parents: 230
diff changeset
  2011
    supers := class allSuperclasses.
214
683adf870f54 oops - couldn't compile for Object (no superclass)
Claus Gittinger <cg@exept.de>
parents: 212
diff changeset
  2012
    supers notNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2013
        supers reverseDo:[:cls|
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2014
            cls ~~ Object ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2015
                cls isLoaded ifFalse:[
357
4c0f6e13867c remove temp-st file in case of trouble
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  2016
                    stream close.
4c0f6e13867c remove temp-st file in case of trouble
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  2017
                    OperatingSystem removeFile:stFileName.
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2018
                    ^ #CannotLoad
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2019
                ].
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2020
                cls fileOutDefinitionOn:stream.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2021
                stream nextPut:sep; cr.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2022
            ]
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2023
        ]
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2024
    ].
101
claus
parents: 98
diff changeset
  2025
    class fileOutDefinitionOn:stream.
96
claus
parents: 95
diff changeset
  2026
    stream nextPut:sep; cr.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2027
101
claus
parents: 98
diff changeset
  2028
    class fileOutPrimitiveDefinitionsOn:stream.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2029
96
claus
parents: 95
diff changeset
  2030
    stream nextPut:sep.
235
8dde5344f785 oops - did not incrementally compile class-methods (shame on me)
Claus Gittinger <cg@exept.de>
parents: 230
diff changeset
  2031
    className := class name.
96
claus
parents: 95
diff changeset
  2032
235
8dde5344f785 oops - did not incrementally compile class-methods (shame on me)
Claus Gittinger <cg@exept.de>
parents: 230
diff changeset
  2033
    stream nextPutAll:className.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2034
    aClass isMeta ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2035
        stream nextPutAll:' class'.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2036
    ].
96
claus
parents: 95
diff changeset
  2037
    stream nextPutAll:' methodsFor:'''; nextPutAll:cat; nextPutAll:''''.
296
999d5fdf0bde oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2038
    stream nextPut:sep; cr.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2039
296
999d5fdf0bde oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2040
    stream nextPutAll:'"{ Line: 0 }"'; cr; 
999d5fdf0bde oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2041
           nextChunkPut:aString;
999d5fdf0bde oops - must write source as chunk (for exclas)
Claus Gittinger <cg@exept.de>
parents: 295
diff changeset
  2042
           space; nextPut:sep.
96
claus
parents: 95
diff changeset
  2043
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2044
    stream close.
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2045
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2046
    "
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2047
     call stc to compile it
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2048
    "
94
claus
parents: 90
diff changeset
  2049
    oFileName := './' , initName , '.o'. 
claus
parents: 90
diff changeset
  2050
    oFileName asFilename delete.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2051
150
7aae365b392a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
  2052
    flags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName .
124
claus
parents: 120
diff changeset
  2053
    STCCompilationDefines notNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2054
        flags := STCCompilationDefines , ' ' , flags
124
claus
parents: 120
diff changeset
  2055
    ].
claus
parents: 120
diff changeset
  2056
    STCCompilationIncludes notNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2057
        flags := STCCompilationIncludes , ' ' , flags
124
claus
parents: 120
diff changeset
  2058
    ].
claus
parents: 120
diff changeset
  2059
    STCCompilationOptions notNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2060
        flags := STCCompilationOptions , ' ' , flags
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2061
    ].
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2062
101
claus
parents: 98
diff changeset
  2063
    command := stcPath , ' ' , flags , ' -c ' , stFileName.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2064
"/    command printNL.
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2065
215
d104a3e755a7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2066
    self activityNotification:'compiling'.
357
4c0f6e13867c remove temp-st file in case of trouble
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  2067
    ok := OperatingSystem 
4c0f6e13867c remove temp-st file in case of trouble
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  2068
                executeCommand:command 
4c0f6e13867c remove temp-st file in case of trouble
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  2069
                onError:[:stat| 
4c0f6e13867c remove temp-st file in case of trouble
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  2070
                            status := stat.
4c0f6e13867c remove temp-st file in case of trouble
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  2071
                            false
4c0f6e13867c remove temp-st file in case of trouble
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  2072
                        ].
101
claus
parents: 98
diff changeset
  2073
120
claus
parents: 118
diff changeset
  2074
    "for debugging - leave c intermediate"
claus
parents: 118
diff changeset
  2075
    STCKeepCIntermediate == true ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2076
        command := stcPath , ' ' , flags , ' -C ' , stFileName.
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2077
        'executing: ' infoPrint. command infoPrintCR.
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2078
        OperatingSystem executeCommand:command
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2079
    ].
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2080
94
claus
parents: 90
diff changeset
  2081
    oFileName asFilename exists ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2082
        ok ifFalse:[
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2083
            'oops - system says it failed - but o-file is there ...' infoPrintCR.
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2084
            ok := true
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2085
        ]
94
claus
parents: 90
diff changeset
  2086
    ] ifFalse:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2087
        ok := false
94
claus
parents: 90
diff changeset
  2088
    ].
claus
parents: 90
diff changeset
  2089
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2090
    ok ifFalse:[
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2091
        (status notNil and:[status couldNotExecute]) ifTrue:[
287
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2092
            eMsg := 'oops, no STC - cannot create machine code'
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2093
        ] ifFalse:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2094
            errorStream := 'errorOutput' asFilename readStream.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2095
            errorStream notNil ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2096
                errorMessages := errorStream contents.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2097
                errorMessages notNil ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2098
                    errorMessages := errorMessages asStringCollection.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2099
                    errorMessages size > 20 ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2100
                        errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped'
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2101
                    ].
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  2102
"/                    errorMessages := errorMessages collect:[:line |
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  2103
"/                        (line startsWith:(stFileName , ':')) ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  2104
"/                            'Line: ' , (line copyFrom:(stFileName size + 2))
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  2105
"/                        ] ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  2106
"/                            line
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  2107
"/                        ]
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  2108
"/                      ].
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2109
                    errorMessages := errorMessages asString
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2110
                ].
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2111
            ].
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2112
            errorMessages isNil ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2113
                errorMessages := ''
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2114
            ].
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2115
            eMsg := ('STC / CC error during compilation:\\',errorMessages) withCRs.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2116
        ].
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2117
        'errorOutput' asFilename remove.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2118
        self parseError:eMsg position:1.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2119
        OperatingSystem removeFile:stFileName.
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2120
        OperatingSystem removeFile:oFileName.
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2121
        OperatingSystem removeFile:'errorOutput'.
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2122
        ^ #Error
120
claus
parents: 118
diff changeset
  2123
    ].
claus
parents: 118
diff changeset
  2124
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2125
    OperatingSystem removeFile:'errorOutput'.
297
7affb1798230 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
  2126
120
claus
parents: 118
diff changeset
  2127
    (ObjectFileLoader notNil 
claus
parents: 118
diff changeset
  2128
    and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2129
        self parseError:'no dynamic load configured - cannot load machine code' position:1.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2130
        OperatingSystem removeFile:stFileName.
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2131
        OperatingSystem removeFile:oFileName.
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2132
        ^ #CannotLoad
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2133
    ].
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2134
215
d104a3e755a7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2135
    "
d104a3e755a7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2136
     if required, make a shared or otherwise loadable object file for it
d104a3e755a7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2137
    "
d104a3e755a7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2138
    self activityNotification:'linking'.
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2139
    oFileName := ObjectFileLoader createLoadableObjectFor:initName.
323
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2140
    oFileName isNil ifTrue:[
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2141
        "/ something went wrong
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2142
        OperatingSystem removeFile:stFileName.
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2143
        self parseError:(ObjectFileLoader lastError) position:1.
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2144
        ^ #CannotLoad
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2145
    ].
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2146
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2147
    oFileName asFilename exists ifFalse:[
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2148
        OperatingSystem removeFile:stFileName.
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2149
        OperatingSystem removeFile:oFileName.
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2150
        self parseError:'link failed - cannot create machine code' position:1.
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2151
        ^ #CannotLoad
0d6e05191a9b check if createLoadableObject really did it
Claus Gittinger <cg@exept.de>
parents: 301
diff changeset
  2152
    ].
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2153
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2154
    "
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2155
     move it into the modules directory
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2156
    "
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2157
    moduleFileName := STCModulePath , '/' , initName , '.' , (oFileName asFilename suffix).
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2158
    oFileName asFilename moveTo:moduleFileName.
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2159
    oFileName := moduleFileName.
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2160
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2161
    "
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2162
     load the objectfile
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2163
    "
215
d104a3e755a7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2164
    self activityNotification:'loading'.
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2165
    handle := ObjectFileLoader loadDynamicObject:moduleFileName.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2166
    handle isNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2167
        OperatingSystem removeFile:stFileName.
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2168
        OperatingSystem removeFile:moduleFileName.
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2169
        self parseError:'dynamic load failed - cannot create machine code' position:1.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2170
        ^ #CannotLoad
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2171
    ].
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2172
"/    ('handle is ' , handle printString) infoPrintCR.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2173
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2174
    address := ObjectFileLoader getFunction:'__' , initName , '_Init' from:handle.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2175
    address isNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2176
        address := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2177
        address isNil ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2178
            (ObjectFileLoader getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2179
                ObjectFileLoader listUndefinedSymbolsIn:handle.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2180
                eMsg := 'undefined symbols in primitive code'.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2181
            ] ifFalse:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2182
                eMsg := initName , '_Init() lookup failed'
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2183
            ].
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
  2184
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2185
            ObjectFileLoader unloadDynamicObject:handle.
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
  2186
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2187
            OperatingSystem removeFile:stFileName.
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2188
            OperatingSystem removeFile:moduleFileName.
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2189
            self parseError:(eMsg , ' - cannot create machine code') position:1.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2190
            ^ #CannotLoad
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2191
        ]
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2192
    ].
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2193
280
eff98fcf188f printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
  2194
"/    ('init at ' , address printString) infoPrintCR.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2195
156
2bf6dc265509 method loading
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
  2196
    m := ObjectFileLoader 
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2197
        callInitFunctionAt:address 
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2198
        specialInit:true
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2199
        forceOld:true 
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2200
        interruptable:false
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2201
        argument:2
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2202
        identifyAs:handle
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2203
        returnsObject:true.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2204
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2205
    "
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2206
     did it work ?
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2207
    "
96
claus
parents: 95
diff changeset
  2208
    newMethod := aClass compiledMethodAt:selector.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2209
    newMethod notNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2210
        m ~~ newMethod ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2211
            'BCOMPILER: oops - loaded method installed itself elsewhere' errorPrintNL.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2212
        ].
156
2bf6dc265509 method loading
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
  2213
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2214
        newMethod source:aString.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2215
        Project notNil ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2216
            newMethod package:(Project currentPackageName)
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2217
        ].
160
5e01f0113d6e dont forget package-info in compiled methods
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
  2218
162
2349ee7039ce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
  2219
"/        aClass updateRevisionString.
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2220
        aClass addChangeRecordForMethod:newMethod.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2221
        (silent or:[Smalltalk silentLoading == true]) ifFalse:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2222
            Transcript showCR:('    compiled: ', className,' ',selector,' - machine code')
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2223
        ].
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2224
        ObjectMemory flushCaches.
120
claus
parents: 118
diff changeset
  2225
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2226
        OperatingSystem removeFile:stFileName.
120
claus
parents: 118
diff changeset
  2227
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2228
        handle method:newMethod.
120
claus
parents: 118
diff changeset
  2229
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2230
        "/ check for obsolete loaded objects and unload them
120
claus
parents: 118
diff changeset
  2231
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2232
        ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle |
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2233
            anotherHandle isMethodHandle ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2234
                anotherHandle method isNil ifTrue:[
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2235
                    ObjectFileLoader unloadObjectFile:anotherHandle pathName.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2236
                    OperatingSystem removeFile:anotherHandle pathName.
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2237
                ]
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2238
            ]
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2239
        ].
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2240
        ^ newMethod.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2241
    ].
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2242
120
claus
parents: 118
diff changeset
  2243
    OperatingSystem removeFile:stFileName.
301
5c0add6f00e2 create temporary method object files in an extra directory;
Claus Gittinger <cg@exept.de>
parents: 298
diff changeset
  2244
    OperatingSystem removeFile:moduleFileName.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  2245
    self parseError:'dynamic load failed' position:1.
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  2246
    ^ #CannotLoad
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2247
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2248
    "
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2249
     |m|
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2250
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2251
     Object subclass:#Test
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2252
            instanceVariableNames:''
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2253
            classVariableNames:''
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2254
            poolDictionaries:''
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2255
            category:'tests'.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2256
     m := ByteCodeCompiler
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2257
            compile:'foo ^ ''hello'''
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2258
            forClass:Test
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2259
            inCategory:'tests'
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2260
            notifying:nil
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2261
            install:false
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2262
            skipIfSame:false.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2263
     m inspect
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2264
    "
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2265
    "
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2266
     |m|
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2267
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2268
     Object subclass:#Test
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2269
            instanceVariableNames:''
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2270
            classVariableNames:''
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2271
            poolDictionaries:''
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2272
            category:'tests'.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2273
     m := ByteCodeCompiler
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2274
            compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}'
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2275
            forClass:Test
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2276
            inCategory:'tests'
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2277
            notifying:nil
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2278
            install:false
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2279
            skipIfSame:false
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2280
            silent:false.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2281
     m inspect
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2282
    "
120
claus
parents: 118
diff changeset
  2283
claus
parents: 118
diff changeset
  2284
    "Modified: 14.9.1995 / 22:33:04 / claus"
287
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2285
    "Modified: 28.12.1995 / 15:52:48 / stefan"
357
4c0f6e13867c remove temp-st file in case of trouble
Claus Gittinger <cg@exept.de>
parents: 356
diff changeset
  2286
    "Modified: 12.10.1996 / 19:06:11 / cg"
97
claus
parents: 96
diff changeset
  2287
!
claus
parents: 96
diff changeset
  2288
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2289
createLoadableObjectFor:baseFileName
287
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2290
    |osType oFileName soFileName|
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2291
287
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2292
    osType := OperatingSystem getOSType.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2293
    osType = 'irix' ifTrue:[
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2294
        "
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2295
         link it to a shared object
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2296
        "
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2297
        oFileName := './' , baseFileName , '.o'.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2298
        soFileName := './' , baseFileName , '.so'. 
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2299
        OperatingSystem removeFile:soFileName.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2300
        OperatingSystem executeCommand:'ld -shared -all -o ' , soFileName , ' ' , oFileName.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2301
        OperatingSystem removeFile:oFileName.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2302
        ^ soFileName. 
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2303
    ].
287
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2304
    osType = 'sys5_4' ifTrue:[
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2305
        "
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2306
         link it to a shared object
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2307
        "
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2308
        oFileName := './' , baseFileName , '.o'.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2309
        soFileName := './' , baseFileName , '.so'. 
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2310
        OperatingSystem removeFile:soFileName.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2311
        OperatingSystem executeCommand:'ld -G -o ' , soFileName , ' ' , oFileName.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2312
        OperatingSystem removeFile:oFileName.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2313
        ^ soFileName. 
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2314
    ].
287
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2315
    osType = 'linux' ifTrue:[
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2316
        "
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2317
         link it to a shared object
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2318
        "
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2319
        oFileName := './' , baseFileName , '.o'.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2320
        soFileName := './' , baseFileName , '.so'. 
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2321
        OperatingSystem removeFile:soFileName.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2322
        OperatingSystem executeCommand:'ld -shared -o ' , soFileName , ' ' , oFileName.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2323
        OperatingSystem removeFile:oFileName.
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2324
        ^ soFileName. 
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2325
    ].
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2326
    ^ oFileName
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2327
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2328
    "Created: 3.1.1996 / 16:04:45 / cg"
287
dc42dd240e5c Use OperatingSystem executeCommand:onError.
Stefan Vogel <sv@exept.de>
parents: 280
diff changeset
  2329
    "Modified: 14.6.1996 / 11:16:46 / stefan"
182
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2330
!
b8316f207380 added query for fileFormat; moved link-code from BCompiler to ObjFLoader
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
  2331
97
claus
parents: 96
diff changeset
  2332
trappingStubMethodFor:aString inCategory:cat
claus
parents: 96
diff changeset
  2333
    "return a stub method which traps and reports an error whenever
claus
parents: 96
diff changeset
  2334
     called."
claus
parents: 96
diff changeset
  2335
292
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  2336
    |newMethod|
97
claus
parents: 96
diff changeset
  2337
292
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  2338
    newMethod := Method new:(litArray size).
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  2339
    litArray notNil ifTrue:[
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  2340
        newMethod literals:litArray
97
claus
parents: 96
diff changeset
  2341
    ].
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2342
124
claus
parents: 120
diff changeset
  2343
    newMethod makeUncompiled.
97
claus
parents: 96
diff changeset
  2344
    newMethod numberOfMethodVars:(self numberOfMethodVars).
claus
parents: 96
diff changeset
  2345
    newMethod numberOfMethodArgs:(self numberOfMethodArgs).
claus
parents: 96
diff changeset
  2346
    newMethod source:aString.
claus
parents: 96
diff changeset
  2347
    newMethod category:cat.
claus
parents: 96
diff changeset
  2348
    Project notNil ifTrue:[
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2349
        newMethod package:(Project currentPackageName)
97
claus
parents: 96
diff changeset
  2350
    ].
claus
parents: 96
diff changeset
  2351
    ^ newMethod
277
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2352
0b599e23a936 set resourceFlag if method has a <resource> definition (prepare for fast search)
Claus Gittinger <cg@exept.de>
parents: 263
diff changeset
  2353
    "Modified: 18.5.1996 / 16:39:12 / cg"
292
163651658aee Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents: 287
diff changeset
  2354
    "Modified: 24.6.1996 / 12:28:24 / stefan"
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  2355
! !
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  2356
372
98da4d230a8d prepare support for 16-bit lineNumbers
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
  2357
!ByteCodeCompiler class methodsFor:'documentation'!
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  2358
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  2359
version
400
e5cfc008be47 bytecode changes - some more are now special-send codes
Claus Gittinger <cg@exept.de>
parents: 383
diff changeset
  2360
    ^ '$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.96 1996-10-24 14:23:36 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  2361
! !
209
b858b6a6880f compare categoryStrings equal before writing a change record
Claus Gittinger <cg@exept.de>
parents: 199
diff changeset
  2362
ByteCodeCompiler initialize!