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