BCompiler.st
author Claus Gittinger <cg@exept.de>
Wed, 13 Dec 1995 20:45:43 +0100
changeset 172 85ad12831217
parent 162 2349ee7039ce
child 174 3be731572be7
permissions -rw-r--r--
give user a chance to choose between trapCode and original code if compilation to binary is not possible
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
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
    14
	instanceVariableNames:'codeBytes codeIndex litArray stackDelta extra lineno
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
    15
		maxStackDepth relocList'
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
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
    18
		KeepSource STCKeepCIntermediate'
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
    19
	poolDictionaries:''
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
    20
	category:'System-Compiler'
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    21
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    22
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
    23
!ByteCodeCompiler class methodsFor:'documentation'!
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
    24
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    25
copyright
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    26
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    27
 COPYRIGHT (c) 1989 by Claus Gittinger
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    28
	      All Rights Reserved
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    29
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    30
 This software is furnished under a license and may be used
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    31
 only in accordance with the terms of that license and with the
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    33
 be provided or otherwise made available to, or used by, any
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    34
 other person.  No title to or ownership of the software is
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    35
 hereby transferred.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
    36
"
135
aa4f7b8f121e uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 128
diff changeset
    37
!
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
    38
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
    39
documentation
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
    40
"
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    41
    This class performs compilation into ByteCodes.
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    42
    First, parsing is done using superclass methods,
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    43
    then the parse-tree is converted into an array of symbolic codes
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    44
    and a relocation table; 
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    45
    these two are finally combined into a byteArray of the codes.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    46
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    47
    (the intermediate step through symbolic codes is for debugging
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    48
     only - it will vanish)
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    49
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    50
    There are many dependencies to the run-time-system (especially the
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    51
    interpreter) in here - be careful when playing around ...
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    52
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    53
    Instance variables:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    54
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
    55
	codeBytes       <ByteArry>              bytecodes
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    56
	codeIndex       <SmallInteger>          next index to put into code array
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    57
	litArray        <OrderedCollection>     literals
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    58
	stackDelta      <SmallInteger>          return value of byteCodeFor:
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    59
	extra           <Symbol>                return value of byteCodeFor:
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    60
	lineno          <Boolean>               return value of byteCodeFor:
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    61
	maxStackDepth   <SmallInteger>          stack need of method
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    62
	relocList       <Array>                 used temporary for relocation
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    63
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    64
    Class variables:
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
    65
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    66
	JumpToAbsJump   <Dictionary>            internal table to map opcodes
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
    67
"
98
claus
parents: 97
diff changeset
    68
! !
claus
parents: 97
diff changeset
    69
claus
parents: 97
diff changeset
    70
!ByteCodeCompiler class methodsFor:'compiling methods'!
claus
parents: 97
diff changeset
    71
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    72
compile:methodText forClass:classToCompileFor
7ad01559b262 Initial revision
claus
parents:
diff changeset
    73
    "compile a source-string for a method in classToCompileFor"
7ad01559b262 Initial revision
claus
parents:
diff changeset
    74
7ad01559b262 Initial revision
claus
parents:
diff changeset
    75
    ^ self compile:methodText
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    76
	  forClass:classToCompileFor
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    77
	inCategory:'others'
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    78
	 notifying:nil
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    79
	   install:true
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    80
	skipIfSame:false
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    81
	    silent:false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    82
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    83
7ad01559b262 Initial revision
claus
parents:
diff changeset
    84
compile:aString forClass:aClass inCategory:cat
7ad01559b262 Initial revision
claus
parents:
diff changeset
    85
    "compile a source-string for a method in classToCompileFor.
7ad01559b262 Initial revision
claus
parents:
diff changeset
    86
     The method will get cat as category"
7ad01559b262 Initial revision
claus
parents:
diff changeset
    87
7ad01559b262 Initial revision
claus
parents:
diff changeset
    88
    ^ self compile:aString
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    89
	  forClass:aClass
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    90
	inCategory:cat
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    91
	 notifying:nil
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    92
	   install:true
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    93
	skipIfSame:false
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
    94
	    silent:false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    95
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
    96
84
claus
parents: 78
diff changeset
    97
compile:aString forClass:aClass inCategory:cat notifying:requestor
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
    98
    "compile a source-string for a method in classToCompileFor.
84
claus
parents: 78
diff changeset
    99
     errors are forwarded to requestor.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   100
     The method will get cat as category"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   101
7ad01559b262 Initial revision
claus
parents:
diff changeset
   102
    ^ self compile:aString
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   103
	  forClass:aClass
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   104
	inCategory:cat
84
claus
parents: 78
diff changeset
   105
	 notifying:requestor
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   106
	   install:true
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   107
	skipIfSame:false
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   108
	    silent:false
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   109
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   110
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   111
compile:aString forClass:aClass inCategory:cat notifying:requestor install:install
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   112
    "compile a source-string for a method in classToCompileFor.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   113
     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
   114
     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
   115
     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
   116
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   117
    ^ self compile:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   118
	  forClass:aClass
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   119
	inCategory:cat
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   120
	 notifying:requestor
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   121
	   install:install
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   122
	skipIfSame:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   123
	    silent:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   124
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   125
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   126
compile:aString forClass:aClass inCategory:cat notifying:requestor
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   127
		 install:install skipIfSame:skipIfSame
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   128
    "compile a source-string for a method in classToCompileFor.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   129
     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
   130
     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
   131
     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
   132
     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
   133
     methods source, this is a noop (for fast fileIn)."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   134
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   135
    ^ self compile:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   136
	  forClass:aClass
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   137
	inCategory:cat
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   138
	 notifying:requestor
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   139
	   install:install
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   140
	skipIfSame:skipIfSame
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   141
	    silent:false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   142
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   143
84
claus
parents: 78
diff changeset
   144
compile:aString forClass:aClass inCategory:cat notifying:requestor
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
   145
                 install:install skipIfSame:skipIfSame silent:silent
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   146
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   147
    "the basic workhorse method for compiling:
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   148
     compile a source-string for a method in classToCompileFor.
84
claus
parents: 78
diff changeset
   149
     errors are forwarded to requestor (report on Transcript and return
claus
parents: 78
diff changeset
   150
     #Error, if requestor is nil).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   151
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   152
     The new method will get cat as category. 
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   153
     If install is true, the method will go into the classes method-table, 
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   154
     otherwise the method is simply returned (for anonymous methods).
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   155
     If skipIsSame is true, and the source is the same as an existing
20
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   156
     methods source, this is a noop (for fast fileIn).
f8dd8ba75205 *** empty log message ***
claus
parents: 19
diff changeset
   157
     The argument, silent controls if errors are to be reported."
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   158
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   159
    |compiler newMethod tree lits symbolicCodeArray oldMethod lazy silencio 
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   160
     sourceFile sourceStream newSource primNr pos sel keptOldCode msg answer|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   161
7ad01559b262 Initial revision
claus
parents:
diff changeset
   162
    aString isNil ifTrue:[^ nil].
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   163
    silencio := silent or:[Smalltalk silentLoading == true].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   164
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   165
    "lazy compilation is EXPERIMENTAL"
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   166
    lazy := (LazyCompilation == true) and:[install].
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   167
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   168
    "create a compiler, let it parse and create the parsetree"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   169
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   170
    compiler := self for:(ReadStream on:aString) in:aClass.
84
claus
parents: 78
diff changeset
   171
    compiler parseForCode.
claus
parents: 78
diff changeset
   172
    compiler notifying:requestor.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   173
    silent ifTrue:[
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   174
"/        compiler ignoreErrors.
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
   175
        compiler ignoreWarnings
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   176
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   177
    compiler nextToken.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   178
    (compiler parseMethodSpec == #Error) ifTrue:[
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
   179
        compiler parseError:'syntax error in method specification'.
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
   180
        tree := #Error
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   181
    ] ifFalse:[
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
   182
        "check if same source"
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
   183
        (skipIfSame and:[(sel := compiler selector) notNil]) ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   184
            oldMethod := aClass compiledMethodAt:sel.
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
   185
            oldMethod notNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   186
                oldMethod source = aString ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   187
                    oldMethod isInvalid ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   188
                        silencio ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   189
                            Transcript showCr:('    unchanged: ',aClass name,' ',compiler selector)
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
   190
                        ].
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
   191
                        "
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
   192
                         same. however, category may be different
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
   193
                        "
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
   194
                        (cat notNil and:[cat ~~ oldMethod category]) ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   195
                            oldMethod category:cat.
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
   196
                            oldMethod changed:#category.    
162
2349ee7039ce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   197
"/                            aClass updateRevisionString.
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
   198
                            aClass addChangeRecordForMethodCategory:oldMethod category:cat.
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
   199
                        ].
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
   200
                        ^ oldMethod
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
   201
                    ]
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
   202
                ]
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
   203
            ]
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   204
        ].
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
   205
        lazy ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   206
            tree := compiler parseMethodBody.
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
   207
            compiler tree:tree.
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
   208
        ]
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   209
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   210
90
claus
parents: 85
diff changeset
   211
    sel := compiler selector.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   212
    (compiler errorFlag or:[tree == #Error]) ifTrue:[
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
   213
        compiler showErrorMessageForClass:aClass.
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
   214
        ^ #Error
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   215
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   216
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   217
    "if no error and also no selector ..."
90
claus
parents: 85
diff changeset
   218
     sel isNil ifTrue:[
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
   219
        "... it was just a comment or other empty stuff"
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
   220
        ^ nil
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   221
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   222
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   223
    "
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   224
     freak-out support ...
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   225
    "
126
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   226
    (compiler hasNonOptionalPrimitiveCode 
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   227
    or:[(compiler hasPrimitiveCode and:[self canCreateMachineCode])
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   228
    or:[STCCompilation == #always and:[sel  ~~ #doIt]]]) ifTrue:[
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
   229
        newMethod := compiler 
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
   230
                        compileToMachineCode:aString 
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
   231
                        forClass:aClass 
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
   232
                        inCategory:cat 
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
   233
                        notifying:requestor
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
   234
                        install:install 
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
   235
                        skipIfSame:skipIfSame 
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
   236
                        silent:silent.
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
   237
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
   238
        newMethod == #Error ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   239
            compiler showErrorMessageForClass:aClass.
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
   240
            ^ #Error
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
   241
        ].
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
   242
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
   243
        (newMethod == #CannotLoad) ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   244
            newMethod := compiler trappingStubMethodFor:aString inCategory:cat.
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
   245
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
   246
            keptOldCode := false.
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
   247
            install ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   248
                "/
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
   249
                "/ be very careful with existing methods
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
   250
                "/ (otherwise, you could easily make your system unusable in systems which cannot load)
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
   251
                "/
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
   252
                sel notNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   253
                    oldMethod := aClass compiledMethodAt:sel 
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
   254
                ].
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
   255
                (oldMethod notNil and:[oldMethod code ~= newMethod code]) ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   256
                    answer := Dialog
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
   257
                                 confirm:'installation of binary code is not possible or disabled.
97
claus
parents: 96
diff changeset
   258
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
   259
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
   260
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
   261
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
   262
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
   263
  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
   264
  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
   265
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
   266
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
   267
'
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
   268
                                 yesLabel:'trap code'
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
   269
                                 noLabel:'keep old'.
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
   270
                    answer isNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   271
                        ^ #Error
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
   272
                    ].
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
   273
                    answer == false ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   274
                        newMethod code:(oldMethod code).
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
   275
                        keptOldCode := true.
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
   276
                    ].
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
   277
                ].
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
   278
                aClass addSelector:sel withMethod:newMethod
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
   279
            ].
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
   280
            Transcript show:'*** '.
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
   281
            sel notNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   282
                Transcript show:(sel ,' ')
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
   283
            ].
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
   284
            keptOldCode ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   285
                msg := 'not really compiled - method still shows previous behavior'.
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
   286
            ] ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   287
                msg := 'not compiled to machine code - created a stub instead.'.
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
   288
            ].
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
   289
            Transcript showCr:msg.
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
   290
        ].
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
   291
        ^ newMethod
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   292
    ].
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   293
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   294
    "
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   295
     EXPERIMENTAL: quick loading
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   296
     only create a lazyMethod, which has no byteCode and will 
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   297
     compile itself when first called.
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   298
    "
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   299
    lazy ifTrue:[
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
   300
        newMethod := LazyMethod new.
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   301
        KeepSource == false ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   302
            sourceFile := ObjectMemory nameForSources.
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
   303
            sourceStream := sourceFile asFilename appendingWriteStream.
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
   304
        ].
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
   305
        sourceStream isNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   306
            newMethod source:aString.
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
   307
        ] ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   308
            sourceStream setToEnd.
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
   309
            pos := sourceStream position.
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
   310
            sourceStream nextChunkPut:aString.
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
   311
            sourceStream close.
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
   312
            newMethod sourceFilename:sourceFile position:pos.
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
   313
        ].
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
   314
        newMethod category:cat.
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   315
        Project notNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   316
            newMethod package:(Project currentPackageName)
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   317
        ].
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   318
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
   319
        aClass addSelector:sel withLazyMethod:newMethod.
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   320
        ^ newMethod
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   321
    ].
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   322
90
claus
parents: 85
diff changeset
   323
    (primNr := compiler primitiveNumber) isNil ifTrue:[
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
   324
        "
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
   325
         produce symbolic code first
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
   326
        "
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
   327
        symbolicCodeArray := compiler genSymbolicCode.
90
claus
parents: 85
diff changeset
   328
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
   329
        (symbolicCodeArray == #Error) ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   330
            Transcript show:'    '.
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
            sel notNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   332
                Transcript show:(sel ,' ')
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
            Transcript showCr:'translation error'.
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
            ^ #Error
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
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   337
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
   338
        "
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
         take this, producing bytecode 
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
   340
         (someone willin' to make machine code :-)
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
   341
        "
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
   342
        ((compiler genByteCodeFrom:symbolicCodeArray) == #Error) ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   343
            Transcript show:'    '.
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
   344
             sel notNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
   345
                Transcript show:(sel ,' ')
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
   346
            ].
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
   347
            Transcript showCr:'relocation error - must be simplified'.
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
   348
            ^ #Error
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
   349
        ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   350
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   351
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   352
    "
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   353
     finally create the new method-object
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   354
    "
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   355
    newMethod := Method new.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   356
    lits := compiler literalArray.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   357
    lits notNil ifTrue:[
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
   358
        "literals MUST be an array - not just any Collection"
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
   359
        lits := Array withAll:lits.
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
   360
        newMethod literals:lits
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   361
    ].
90
claus
parents: 85
diff changeset
   362
    primNr notNil ifTrue:[
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
   363
        newMethod code:(compiler checkForPrimitiveCode:primNr).
78
e320344c19b7 *** empty log message ***
claus
parents: 76
diff changeset
   364
    ] ifFalse:[
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
   365
        newMethod byteCode:(compiler code).
78
e320344c19b7 *** empty log message ***
claus
parents: 76
diff changeset
   366
    ].
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   367
    newMethod numberOfMethodVars:(compiler numberOfMethodVars).
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   368
    newMethod numberOfMethodArgs:(compiler numberOfMethodArgs).
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   369
    newMethod stackSize:(compiler maxStackDepth).
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   370
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   371
    "
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   372
     if there where any corrections, install the updated source
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   373
    "
90
claus
parents: 85
diff changeset
   374
    (newSource := compiler correctedSource) notNil ifTrue:[
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
   375
        newMethod source:newSource 
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   376
    ] ifFalse:[
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
   377
        newMethod source:aString.
19
84a1ddf215a5 *** empty log message ***
claus
parents: 15
diff changeset
   378
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   379
    newMethod category:cat.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   380
    Project notNil ifTrue:[
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
   381
        newMethod package:(Project currentPackageName)
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   382
    ].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   383
7ad01559b262 Initial revision
claus
parents:
diff changeset
   384
    install ifTrue:[
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
   385
        aClass addSelector:sel withMethod:newMethod
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   386
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   387
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   388
    silencio ifFalse:[
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
   389
        Transcript showCr:('    compiled: ', aClass name,' ', sel)
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   390
    ].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   391
7ad01559b262 Initial revision
claus
parents:
diff changeset
   392
    ^ newMethod
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   393
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   394
    "Created: 29.10.1995 / 19:59:36 / cg"
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
   395
    "Modified: 13.12.1995 / 20:42:56 / cg"
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   396
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   397
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   398
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
   399
    "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
   400
     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
   401
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   402
    ^ self compile:methodText
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   403
	  forClass:classToCompileFor
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   404
	inCategory:'others'
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   405
	 notifying:requestor
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   406
	   install:true
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   407
	skipIfSame:false
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   408
	    silent:false
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   409
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   410
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   411
compile:textOrStream in:aClass notifying:requestor ifFail:exceptionBlock
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   412
    "name alias for ST-80 compatibility"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   413
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   414
    |m|
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   415
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   416
    m := self 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   417
	   compile:textOrStream
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   418
	  forClass:aClass 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   419
	inCategory:'others'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   420
	 notifying:requestor 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   421
	   install:true
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   422
	skipIfSame:false
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   423
	    silent:false.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   424
    m == #Error ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   425
	^ exceptionBlock value
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   426
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   427
     ^ m
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   428
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   429
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   430
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   431
!ByteCodeCompiler class methodsFor:'constants'!
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   432
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   433
byteCodeFor:aSymbol
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   434
    "only some exported codes handled here (for BlockNode)"
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   435
25
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   436
    (aSymbol == #retNil) ifTrue:[^ 1].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   437
    (aSymbol == #retTrue) ifTrue:[^ 2].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   438
    (aSymbol == #retFalse) ifTrue:[^ 3].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   439
    (aSymbol == #ret0) ifTrue:[^ 4].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   440
    (aSymbol == #retTop) ifTrue:[^ 0].
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   441
15
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   442
    (aSymbol == #push0) ifTrue:[^120].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   443
    (aSymbol == #push1) ifTrue:[^121].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   444
    (aSymbol == #push2) ifTrue:[^139].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   445
    (aSymbol == #pushMinus1) ifTrue:[^122].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   446
    (aSymbol == #pushNil) ifTrue:[^ 10].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   447
    (aSymbol == #pushTrue) ifTrue:[^ 11].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   448
    (aSymbol == #pushFalse) ifTrue:[^ 12].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   449
    (aSymbol == #pushSelf) ifTrue:[^ 15].
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   450
    self error
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   451
! !
992c3d87edbf *** empty log message ***
claus
parents: 13
diff changeset
   452
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   453
!ByteCodeCompiler class methodsFor:'stc compilation defaults'!
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   454
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   455
canCreateMachineCode
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   456
    "return true, if compilation to machine code is supported.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   457
     Currently, all SYSV4 and Linux systems do so;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   458
     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
   459
     of object files, which is not supported by those).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   460
     MIPS ULTRIX is almost finished, but not yet released.
124
claus
parents: 120
diff changeset
   461
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   462
     However, if no compiler is around (i.e. the demo distribution),
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   463
     there is no chance ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   464
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   465
    |canDo|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   466
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   467
    ObjectFileLoader isNil ifTrue:[^ false].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   468
    ObjectFileLoader canLoadObjectFiles ifFalse:[^ false].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   469
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   470
    "/ no chance, if no stc is available
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   471
    ^ self incrementalStcPath notNil
124
claus
parents: 120
diff changeset
   472
claus
parents: 120
diff changeset
   473
    "
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   474
     Compiler canCreateMachineCode     
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   475
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   476
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   477
    "Modified: 13.9.1995 / 15:15:11 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   478
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   479
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   480
incrementalStcPath 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   481
    "return the path to the stc command for incremental method compilation, 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   482
     or nil if not found."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   483
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   484
    |f|
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
    (f := self stcPathOf:'stc') notNil ifTrue:[^ f].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   487
    ^ self stcPathOf:'demostc'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   488
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   489
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   490
     Compiler incrementalStcPath     
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   491
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   492
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   493
    "Created: 13.9.1995 / 14:36:36 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   494
    "Modified: 13.9.1995 / 15:15:04 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   495
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   496
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   497
keepSource:aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   498
    "if true, the source of a method is kept as a string in memory;
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   499
     if false, the source is appended to the sources-file (st.src) and
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   500
     only a reference to its fileposition is kept in memory - thus saving
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   501
     space. You have to care for the source-file to not become corrupted
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   502
     in this case; therefore, the default is to keep it as strings for now."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   503
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   504
    KeepSource := aBoolean
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   505
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   506
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   507
     Compiler keepSource:true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   508
     Compiler keepSource:false.
124
claus
parents: 120
diff changeset
   509
    "
claus
parents: 120
diff changeset
   510
!
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   511
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   512
stcCompilation
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   513
    "return the flag which controls compilation to machine code.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   514
     If #always, methods are always compiled to machine code (which takes
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   515
     longer, but provides faster code). If #none, methods are never compiled
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   516
     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
   517
     and for primitive ones, a trapping stub is generated.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   518
     Anything else lets the compiler compile to bytecode,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   519
     except for methods containing primitive code.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   520
     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
   521
     for selective compilation to machine code."
124
claus
parents: 120
diff changeset
   522
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   523
    ^ STCCompilation
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   524
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   525
    "
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   526
     Compiler stcCompilation
124
claus
parents: 120
diff changeset
   527
    "
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   528
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   529
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   530
stcCompilation:how
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   531
    "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
   532
     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
   533
     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
   534
     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
   535
     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
   536
     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
   537
     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
   538
     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
   539
     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
   540
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   541
    |ret|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   542
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   543
    ret := STCCompilation.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   544
    STCCompilation := how.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   545
    ^ ret
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   546
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   547
    "
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   548
     Compiler stcCompilation:#always
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   549
     Compiler stcCompilation:#never 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   550
     Compiler stcCompilation:#default 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   551
    "
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   552
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   553
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   554
stcCompilationDefines
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   555
    "return the defines used with stc compilation"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   556
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   557
    ^ STCCompilationDefines
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   558
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   559
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   560
stcCompilationDefines:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   561
    "define the flags (for example, additional -D defines)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   562
     to be used when compiling to machine code.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   563
     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
   564
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   565
    STCCompilationDefines := aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   566
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   567
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   568
     Compiler stcCompilationDefines:'-DVGL -DDEBUG'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   569
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   570
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   571
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   572
stcCompilationIncludes
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   573
    "return the includes used with stc compilation"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   574
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   575
    ^ STCCompilationIncludes
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   576
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   577
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   578
stcCompilationIncludes:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   579
    "define the include directories via additional -I flags.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   580
     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
   581
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   582
    STCCompilationIncludes := aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   583
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   584
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   585
     Compiler stcCompilationIncludes:'-I/usr/local/include -I../../include'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   586
     Compiler stcCompilationIncludes:(Compiler stcCompilationIncludes , ' -I../../libxt')
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   587
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   588
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   589
124
claus
parents: 120
diff changeset
   590
stcCompilationOptions
claus
parents: 120
diff changeset
   591
    "return the options used with stc compilation"
claus
parents: 120
diff changeset
   592
claus
parents: 120
diff changeset
   593
    ^ STCCompilationOptions
claus
parents: 120
diff changeset
   594
!
claus
parents: 120
diff changeset
   595
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   596
stcCompilationOptions:aString
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   597
    "define the compilation options 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   598
     to be used when compiling to machine code.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   599
     These are passed to stc. Can be set from your private.rc file."
101
claus
parents: 98
diff changeset
   600
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   601
    STCCompilationOptions := aString
101
claus
parents: 98
diff changeset
   602
claus
parents: 98
diff changeset
   603
    "
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   604
     Compiler stcCompilationOptions:'+optinline'
101
claus
parents: 98
diff changeset
   605
    "
claus
parents: 98
diff changeset
   606
!
claus
parents: 98
diff changeset
   607
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   608
stcPath 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   609
    "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
   610
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   611
    ^ self stcPathOf:'stc'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   612
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   613
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   614
     Compiler stcPath     
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   615
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   616
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   617
    "Modified: 13.9.1995 / 14:37:26 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   618
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   619
120
claus
parents: 118
diff changeset
   620
stcPathOf:command 
claus
parents: 118
diff changeset
   621
    "return the path to an stc command, or nil if not found."
101
claus
parents: 98
diff changeset
   622
claus
parents: 98
diff changeset
   623
    |f|
97
claus
parents: 96
diff changeset
   624
120
claus
parents: 118
diff changeset
   625
    ((f := '../../stc' asFilename construct:command)) isExecutable ifTrue:[
101
claus
parents: 98
diff changeset
   626
	^ f pathName
claus
parents: 98
diff changeset
   627
    ].
126
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   628
    ^ OperatingSystem pathOfCommand:command
97
claus
parents: 96
diff changeset
   629
claus
parents: 96
diff changeset
   630
    "
120
claus
parents: 118
diff changeset
   631
     Compiler stcPathOf:'stc'     
claus
parents: 118
diff changeset
   632
    "
claus
parents: 118
diff changeset
   633
claus
parents: 118
diff changeset
   634
    "Created: 13.9.1995 / 14:37:16 / claus"
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   635
! !
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   636
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   637
!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
   638
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   639
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
   640
    "name alias for ST-80 compatibility"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   641
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   642
    ^ self class
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   643
		compile:textOrStream
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   644
		in:aClass 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   645
		notifying:requestor 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   646
		ifFail:exceptionBlock
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   647
"/    |m|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   648
"/
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   649
"/    m := self class 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   650
"/                compile:textOrStream 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   651
"/                forClass:aClass 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   652
"/                inCategory:'no category'
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   653
"/                notifying:requestor
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   654
"/                install:true 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   655
"/                skipIfSame:false
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   656
"/                silent:false.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   657
"/    m == #Error ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   658
"/        ^ exceptionBlock value
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
"/     ^ m
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   661
! !
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   662
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   663
!ByteCodeCompiler methodsFor:'accessing'!
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   664
7ad01559b262 Initial revision
claus
parents:
diff changeset
   665
code
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
   666
    "return the bytecode array - only valid after code-generation"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   667
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   668
    ^ codeBytes
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   669
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   670
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   671
literalArray
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   672
    "return the literal array - only valid after parsing"
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
    ^ litArray
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
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   677
maxStackDepth
7ad01559b262 Initial revision
claus
parents:
diff changeset
   678
    "return the stack-need of the method - only valid after code-generation"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   679
7ad01559b262 Initial revision
claus
parents:
diff changeset
   680
    ^ maxStackDepth
7ad01559b262 Initial revision
claus
parents:
diff changeset
   681
! !
7ad01559b262 Initial revision
claus
parents:
diff changeset
   682
7ad01559b262 Initial revision
claus
parents:
diff changeset
   683
!ByteCodeCompiler methodsFor:'code generation'!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   684
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   685
absJumpFromJump:code
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   686
    "given a jump-symbolic code, return corresponding absolute jump"
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   687
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   688
    JumpToAbsJump isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   689
	JumpToAbsJump := IdentityDictionary new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   690
	JumpToAbsJump at:#jump put:#jumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   691
	JumpToAbsJump at:#trueJump put:#trueJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   692
	JumpToAbsJump at:#falseJump put:#falseJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   693
	JumpToAbsJump at:#nilJump put:#nilJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   694
	JumpToAbsJump at:#notNilJump put:#notNilJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   695
	JumpToAbsJump at:#eqJump put:#eqJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   696
	JumpToAbsJump at:#notEqJump put:#notEqJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   697
	JumpToAbsJump at:#zeroJump put:#zeroJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   698
	JumpToAbsJump at:#notZeroJump put:#notZeroJumpabs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   699
	JumpToAbsJump at:#makeBlock put:#makeBlockabs.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   700
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   701
    ^ JumpToAbsJump at:code
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   702
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   703
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   704
addLiteral:anObject
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   705
    "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
   706
     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
   707
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   708
    |index class|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   709
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   710
    litArray isNil ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   711
	litArray := Array with:anObject.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   712
	^ 1
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   713
    ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   714
    index := litArray identityIndexOf:anObject.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   715
    (index == 0) ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   716
	"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   717
	 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
   718
	"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   719
	class := anObject class.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   720
	((class == Float) 
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   721
	or:[class == Fraction]) ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   722
	    index := litArray indexOf:anObject.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   723
	].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   724
	((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
   725
	    litArray := litArray copyWith:anObject.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   726
	    ^ litArray size
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   727
	].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   728
    ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   729
    ^ index
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   730
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   731
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   732
addReloc:symIndex
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   733
    "remember to relocate offset at symIndex later ..."
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
   734
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   735
    relocList isNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   736
	relocList := OrderedCollection new.
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   737
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   738
    relocList add:symIndex
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   739
!
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   740
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   741
appendByte:aByte
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   742
    "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
   743
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   744
    |idx "{Class: SmallInteger }"|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   745
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   746
    idx := codeIndex.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   747
    (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
   748
	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
   749
	codeIndex := idx + 1
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   750
    ] ifFalse:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   751
	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
   752
	errorFlag := #Error
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   753
    ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   754
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   755
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   756
appendByteCodeFor:codeSymbol
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   757
    "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
   758
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   759
    |idx "{Class: SmallInteger }"|
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   760
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   761
    idx := codeIndex.
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   762
    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
   763
    codeIndex := idx + 1
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   764
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   765
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   766
appendEmptyByte
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   767
    "append an empty byte to the code-Array"
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
   768
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   769
    |idx "{Class: SmallInteger }"|
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
   770
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   771
    idx := codeIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   772
    codeBytes at:idx put:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   773
    codeIndex := idx + 1
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   774
!
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   775
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   776
appendSignedByte:aByte
7ad01559b262 Initial revision
claus
parents:
diff changeset
   777
    "append a signedbyte (as in jump-offsets) to the code-Array,
7ad01559b262 Initial revision
claus
parents:
diff changeset
   778
     check range and report an error if invalid"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   779
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   780
    |b   "{Class: SmallInteger }" 
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   781
     idx "{Class: SmallInteger }"|
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   782
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   783
    idx := codeIndex.
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   784
    b := aByte.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   785
    (b >= 0) ifTrue:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   786
	(b > 127) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   787
	    self error:'jump-range error'.
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   788
	    errorFlag := #Error
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   789
	].
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   790
	codeBytes at:idx put:b
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   791
    ] ifFalse:[
45
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   792
	(b < -128) ifTrue:[
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   793
	    self error:'jump-range error'.
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   794
	    errorFlag := #Error
e8331ba8ad5d *** empty log message ***
claus
parents: 39
diff changeset
   795
	].
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   796
	b := 256 + b
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   797
    ].
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   798
    codeBytes at:idx put:b.
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   799
    codeIndex := idx + 1
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   800
!
7ad01559b262 Initial revision
claus
parents:
diff changeset
   801
46
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   802
appendSignedWord:aWord
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   803
    "append a signed word to the code-Array,
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   804
     check range and report an error if invalid"
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   805
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
   806
    |w   "{Class: SmallInteger }"|
46
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   807
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   808
    w := aWord.
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   809
    (w >= 0) ifTrue:[
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   810
	(w > 16r7FFFF) ifTrue:[
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   811
	    self error:'word-range error'.
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   812
	    errorFlag := #Error
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   813
	].
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   814
    ] ifFalse:[
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   815
	(w < 16r-8000) ifTrue:[
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   816
	    self error:'word-range error'.
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   817
	    errorFlag := #Error
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   818
	].
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   819
	w := (16r10000 + w).
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   820
    ].
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   821
    self appendWord:w
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   822
!
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   823
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   824
appendWord:aWord
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   825
    "append an unsigned word (low-high) to the code-Array, 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   826
     checking for word-range (debug-only)"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   827
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   828
    |idx "{Class: SmallInteger }"|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   829
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   830
    idx := codeIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   831
    (aWord between:0 and:16rFFFF) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   832
	codeBytes at:idx put:(aWord bitAnd:16rFF).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   833
	idx := idx + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   834
	codeBytes at:idx put:(aWord bitShift:-8).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   835
	codeIndex := idx + 1
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   836
    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   837
	self error:'word range error'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   838
	errorFlag := #Error
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   839
    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   840
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
   841
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   842
byteCodeFor:aSymbol
7ad01559b262 Initial revision
claus
parents:
diff changeset
   843
    "given a symbolic instruction, return the corresponding bytecode.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   844
     as a side-effect, leave number of bytes pushed/popped by this instr.
7ad01559b262 Initial revision
claus
parents:
diff changeset
   845
     in stackDelta, and, if the instruction needs extra arguments, leave
7ad01559b262 Initial revision
claus
parents:
diff changeset
   846
     this info in extra"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   847
7ad01559b262 Initial revision
claus
parents:
diff changeset
   848
    "standard bytecodes"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   849
7ad01559b262 Initial revision
claus
parents:
diff changeset
   850
    (aSymbol == #pushNil) ifTrue:[stackDelta := 1. ^ 10].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   851
    (aSymbol == #pushTrue) ifTrue:[stackDelta := 1. ^ 11].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   852
    (aSymbol == #pushFalse) ifTrue:[stackDelta := 1. ^ 12].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   853
    (aSymbol == #pushLit) ifTrue:[stackDelta := 1. extra := #lit. ^ 14].
105
claus
parents: 104
diff changeset
   854
    (aSymbol == #pushLitS) ifTrue:[stackDelta := 1. extra := #index. ^ 14].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   855
    (aSymbol == #pushSelf) ifTrue:[stackDelta := 1. ^ 15].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   856
    (aSymbol == #pushNum) ifTrue:[stackDelta := 1. extra := #number. ^ 16].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   857
7ad01559b262 Initial revision
claus
parents:
diff changeset
   858
    (aSymbol == #pushMethodArg) ifTrue:[stackDelta := 1. extra := #index. ^ 30].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   859
    (aSymbol == #pushMethodVar) ifTrue:[stackDelta := 1. extra := #index. ^ 31].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   860
    (aSymbol == #pushBlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 32].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   861
    (aSymbol == #pushBlockVar) ifTrue:[stackDelta := 1. extra := #index. ^ 33].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   862
    (aSymbol == #pushInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 34].
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   863
    (aSymbol == #pushOuterBlockArg) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 42].
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   864
    (aSymbol == #pushOuterBlockVar) ifTrue:[stackDelta := 1. extra := #indexLevel. ^ 128].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   865
7ad01559b262 Initial revision
claus
parents:
diff changeset
   866
    (aSymbol == #retTop) ifTrue:[stackDelta := -1. ^ 0].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   867
    (aSymbol == #retSelf) ifTrue:[^5].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   868
7ad01559b262 Initial revision
claus
parents:
diff changeset
   869
    (aSymbol == #==) ifTrue:[stackDelta := -1. self addLiteral:aSymbol. ^ 45].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   870
    (aSymbol == #~~) ifTrue:[stackDelta := -1. self addLiteral:aSymbol. ^ 46].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   871
7ad01559b262 Initial revision
claus
parents:
diff changeset
   872
    (aSymbol == #falseJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 50].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   873
    (aSymbol == #trueJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 51].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   874
    (aSymbol == #nilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 52].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   875
    (aSymbol == #notNilJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 53].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   876
    (aSymbol == #jump) ifTrue:[extra := #offset. ^ 54].
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   877
    (aSymbol == #makeBlock) ifTrue:[stackDelta := 1. extra := #offsetNvarNarg. ^ 55].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   878
    (aSymbol == #zeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 56].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   879
    (aSymbol == #notZeroJump) ifTrue:[stackDelta := -1. extra := #offset. ^ 57].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   880
    (aSymbol == #eqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 58].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   881
    (aSymbol == #notEqJump) ifTrue:[stackDelta := -2. extra := #offset. ^ 59].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   882
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   883
    (aSymbol == #lineno) ifTrue:[lineno := true. ^ 8].
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
   884
106
claus
parents: 105
diff changeset
   885
    (aSymbol == #send) ifTrue:[lineno := true. extra := #special. ^ 19].
claus
parents: 105
diff changeset
   886
    (aSymbol == #superSend) ifTrue:[lineno := true. extra := #special. ^ 20].
claus
parents: 105
diff changeset
   887
    (aSymbol == #hereSend) ifTrue:[lineno := true. extra := #special. ^ 20].
117
claus
parents: 111
diff changeset
   888
    (aSymbol == #sendSelf) ifTrue:[lineno := true. extra := #special. ^ 13].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   889
7ad01559b262 Initial revision
claus
parents:
diff changeset
   890
    (aSymbol == #drop) ifTrue:[stackDelta := -1. ^ 18].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   891
    (aSymbol == #dup) ifTrue:[stackDelta := 1. ^ 47].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   892
117
claus
parents: 111
diff changeset
   893
    (aSymbol == #storeMethodVar) ifTrue:[extra := #index. stackDelta := -1. ^ 37].
claus
parents: 111
diff changeset
   894
    (aSymbol == #storeBlockVar) ifTrue:[extra := #index. stackDelta := -1. ^ 38].
claus
parents: 111
diff changeset
   895
    (aSymbol == #storeInstVar) ifTrue:[extra := #index. stackDelta := -1. ^ 39].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   896
117
claus
parents: 111
diff changeset
   897
    (aSymbol == #pushClassVarS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35].
claus
parents: 111
diff changeset
   898
    (aSymbol == #pushGlobalS) ifTrue:[stackDelta := 1. extra := #speciallitS. ^ 35].
claus
parents: 111
diff changeset
   899
claus
parents: 111
diff changeset
   900
    (aSymbol == #storeClassVarS) ifTrue:[extra := #speciallitS.stackDelta := -1. ^ 40].
claus
parents: 111
diff changeset
   901
    (aSymbol == #storeGlobalS) ifTrue:[extra := #speciallitS. stackDelta := -1. ^ 40].
claus
parents: 111
diff changeset
   902
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
   903
    (aSymbol == #storeOuterBlockVar) ifTrue:[stackDelta := -1. extra := #indexLevel. ^ 129].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   904
117
claus
parents: 111
diff changeset
   905
    (aSymbol == #pushClassInstVar) ifTrue:[stackDelta := 1. extra := #index. ^ 176].
claus
parents: 111
diff changeset
   906
    (aSymbol == #storeClassInstVar) ifTrue:[extra := #index.stackDelta := -1. ^ 177].
105
claus
parents: 104
diff changeset
   907
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   908
    "optimized bytecodes"
7ad01559b262 Initial revision
claus
parents:
diff changeset
   909
7ad01559b262 Initial revision
claus
parents:
diff changeset
   910
    (aSymbol == #retNil) ifTrue:[^ 1].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   911
    (aSymbol == #retTrue) ifTrue:[^ 2].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   912
    (aSymbol == #retFalse) ifTrue:[^ 3].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   913
    (aSymbol == #ret0) ifTrue:[^ 4].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   914
    (aSymbol == #retNum) ifTrue:[extra := #number. ^ 127].
25
865d6cfaf90d changed bytecodes
claus
parents: 20
diff changeset
   915
    (aSymbol == #homeRetTop) ifTrue:[^ 7].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   916
46
a8c1e932ed6a 16bit literal offsets
claus
parents: 45
diff changeset
   917
    (aSymbol == #pushNum16) ifTrue:[stackDelta := 1. extra := #number16. ^ 17].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   918
    (aSymbol == #push0) ifTrue:[stackDelta := 1. ^120].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   919
    (aSymbol == #push1) ifTrue:[stackDelta := 1. ^121].
3
b63b8a6b71fb *** empty log message ***
claus
parents: 1
diff changeset
   920
    (aSymbol == #push2) ifTrue:[stackDelta := 1. ^139].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   921
    (aSymbol == #pushMinus1) ifTrue:[stackDelta := 1. ^122].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   922
106
claus
parents: 105
diff changeset
   923
    (aSymbol == #send0) ifTrue:[lineno := true. extra := #index. ^21].
claus
parents: 105
diff changeset
   924
    (aSymbol == #send1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^22].
claus
parents: 105
diff changeset
   925
    (aSymbol == #send2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^23].
claus
parents: 105
diff changeset
   926
    (aSymbol == #send3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^24].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   927
106
claus
parents: 105
diff changeset
   928
    (aSymbol == #sendSelf0) ifTrue:[lineno := true. extra := #index. stackDelta := 1. ^180].
claus
parents: 105
diff changeset
   929
    (aSymbol == #sendSelf1) ifTrue:[lineno := true. extra := #index. ^181].
claus
parents: 105
diff changeset
   930
    (aSymbol == #sendSelf2) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^182].
claus
parents: 105
diff changeset
   931
    (aSymbol == #sendSelf3) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^183].
claus
parents: 105
diff changeset
   932
    (aSymbol == #sendSelfDrop0) ifTrue:[lineno := true. extra := #index. ^184].
claus
parents: 105
diff changeset
   933
    (aSymbol == #sendSelfDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^185].
claus
parents: 105
diff changeset
   934
    (aSymbol == #sendSelfDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^186].
claus
parents: 105
diff changeset
   935
    (aSymbol == #sendSelfDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^187].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   936
106
claus
parents: 105
diff changeset
   937
    (aSymbol == #sendDrop) ifTrue:[lineno := true. extra := #special. ^25].
claus
parents: 105
diff changeset
   938
    (aSymbol == #sendDrop0) ifTrue:[lineno := true. extra := #index. stackDelta := -1. ^26].
claus
parents: 105
diff changeset
   939
    (aSymbol == #sendDrop1) ifTrue:[lineno := true. extra := #index. stackDelta := -2. ^27].
claus
parents: 105
diff changeset
   940
    (aSymbol == #sendDrop2) ifTrue:[lineno := true. extra := #index. stackDelta := -3. ^28].
claus
parents: 105
diff changeset
   941
    (aSymbol == #sendDrop3) ifTrue:[lineno := true. extra := #index. stackDelta := -4. ^29].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   942
7ad01559b262 Initial revision
claus
parents:
diff changeset
   943
    (aSymbol == #pushMethodVar1) ifTrue:[stackDelta := 1. ^80].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   944
    (aSymbol == #pushMethodVar2) ifTrue:[stackDelta := 1. ^81].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   945
    (aSymbol == #pushMethodVar3) ifTrue:[stackDelta := 1. ^82].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   946
    (aSymbol == #pushMethodVar4) ifTrue:[stackDelta := 1. ^83].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   947
    (aSymbol == #pushMethodVar5) ifTrue:[stackDelta := 1. ^84].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   948
    (aSymbol == #pushMethodVar6) ifTrue:[stackDelta := 1. ^85].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   949
7ad01559b262 Initial revision
claus
parents:
diff changeset
   950
    (aSymbol == #pushMethodArg1) ifTrue:[stackDelta := 1. ^86].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   951
    (aSymbol == #pushMethodArg2) ifTrue:[stackDelta := 1. ^87].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   952
    (aSymbol == #pushMethodArg3) ifTrue:[stackDelta := 1. ^88].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   953
    (aSymbol == #pushMethodArg4) ifTrue:[stackDelta := 1. ^89].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   954
7ad01559b262 Initial revision
claus
parents:
diff changeset
   955
    (aSymbol == #pushInstVar1) ifTrue:[stackDelta := 1. ^90].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   956
    (aSymbol == #pushInstVar2) ifTrue:[stackDelta := 1. ^91].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   957
    (aSymbol == #pushInstVar3) ifTrue:[stackDelta := 1. ^92].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   958
    (aSymbol == #pushInstVar4) ifTrue:[stackDelta := 1. ^93].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   959
    (aSymbol == #pushInstVar5) ifTrue:[stackDelta := 1. ^94].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   960
    (aSymbol == #pushInstVar6) ifTrue:[stackDelta := 1. ^95].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   961
    (aSymbol == #pushInstVar7) ifTrue:[stackDelta := 1. ^96].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   962
    (aSymbol == #pushInstVar8) ifTrue:[stackDelta := 1. ^97].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   963
    (aSymbol == #pushInstVar9) ifTrue:[stackDelta := 1. ^98].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   964
    (aSymbol == #pushInstVar10) ifTrue:[stackDelta := 1. ^99].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   965
7ad01559b262 Initial revision
claus
parents:
diff changeset
   966
    (aSymbol == #storeMethodVar1) ifTrue:[stackDelta := -1. ^100].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   967
    (aSymbol == #storeMethodVar2) ifTrue:[stackDelta := -1. ^101].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   968
    (aSymbol == #storeMethodVar3) ifTrue:[stackDelta := -1. ^102].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   969
    (aSymbol == #storeMethodVar4) ifTrue:[stackDelta := -1. ^103].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   970
    (aSymbol == #storeMethodVar5) ifTrue:[stackDelta := -1. ^104].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   971
    (aSymbol == #storeMethodVar6) ifTrue:[stackDelta := -1. ^105].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   972
7ad01559b262 Initial revision
claus
parents:
diff changeset
   973
    (aSymbol == #storeInstVar1) ifTrue:[stackDelta := -1. ^110].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   974
    (aSymbol == #storeInstVar2) ifTrue:[stackDelta := -1. ^111].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   975
    (aSymbol == #storeInstVar3) ifTrue:[stackDelta := -1. ^112].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   976
    (aSymbol == #storeInstVar4) ifTrue:[stackDelta := -1. ^113].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   977
    (aSymbol == #storeInstVar5) ifTrue:[stackDelta := -1. ^114].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   978
    (aSymbol == #storeInstVar6) ifTrue:[stackDelta := -1. ^115].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   979
    (aSymbol == #storeInstVar7) ifTrue:[stackDelta := -1. ^116].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   980
    (aSymbol == #storeInstVar8) ifTrue:[stackDelta := -1. ^117].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   981
    (aSymbol == #storeInstVar9) ifTrue:[stackDelta := -1. ^118].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   982
    (aSymbol == #storeInstVar10) ifTrue:[stackDelta := -1. ^119].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   983
103
claus
parents: 102
diff changeset
   984
    (aSymbol == #pushLit1) ifTrue:[stackDelta := 1. ^ 222].
claus
parents: 102
diff changeset
   985
    (aSymbol == #pushLit2) ifTrue:[stackDelta := 1. ^ 223].
claus
parents: 102
diff changeset
   986
    (aSymbol == #pushLit3) ifTrue:[stackDelta := 1. ^ 224].
claus
parents: 102
diff changeset
   987
    (aSymbol == #pushLit4) ifTrue:[stackDelta := 1. ^ 225].
claus
parents: 102
diff changeset
   988
    (aSymbol == #pushLit5) ifTrue:[stackDelta := 1. ^ 226].
claus
parents: 102
diff changeset
   989
    (aSymbol == #pushLit6) ifTrue:[stackDelta := 1. ^ 227].
claus
parents: 102
diff changeset
   990
    (aSymbol == #pushLit7) ifTrue:[stackDelta := 1. ^ 228].
claus
parents: 102
diff changeset
   991
    (aSymbol == #pushLit8) ifTrue:[stackDelta := 1. ^ 229].
claus
parents: 102
diff changeset
   992
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
   993
    (aSymbol == #retMethodVar1) ifTrue:[^160].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   994
    (aSymbol == #retMethodVar2) ifTrue:[^161].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   995
    (aSymbol == #retMethodVar3) ifTrue:[^162].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   996
    (aSymbol == #retMethodVar4) ifTrue:[^163].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   997
    (aSymbol == #retMethodVar5) ifTrue:[^164].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   998
    (aSymbol == #retMethodVar6) ifTrue:[^165].
7ad01559b262 Initial revision
claus
parents:
diff changeset
   999
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1000
    (aSymbol == #retInstVar1) ifTrue:[^166].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1001
    (aSymbol == #retInstVar2) ifTrue:[^167].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1002
    (aSymbol == #retInstVar3) ifTrue:[^168].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1003
    (aSymbol == #retInstVar4) ifTrue:[^169].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1004
    (aSymbol == #retInstVar5) ifTrue:[^170].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1005
    (aSymbol == #retInstVar6) ifTrue:[^171].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1006
    (aSymbol == #retInstVar7) ifTrue:[^172].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1007
    (aSymbol == #retInstVar8) ifTrue:[^173].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1008
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1009
    (aSymbol == #retMethodArg1) ifTrue:[^174].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1010
    (aSymbol == #retMethodArg2) ifTrue:[^175].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1011
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1012
    (aSymbol == #pushBlockArg1) ifTrue:[stackDelta := 1. ^140].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1013
    (aSymbol == #pushBlockArg2) ifTrue:[stackDelta := 1. ^141].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1014
    (aSymbol == #pushBlockArg3) ifTrue:[stackDelta := 1. ^142].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1015
    (aSymbol == #pushBlockArg4) ifTrue:[stackDelta := 1. ^143].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1016
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1017
    (aSymbol == #pushOuter1BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 43].
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1018
    (aSymbol == #pushOuter2BlockArg) ifTrue:[stackDelta := 1. extra := #index. ^ 44].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1019
5
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1020
    (aSymbol == #=) ifTrue:[lineno := true. stackDelta := -1. self addLiteral:aSymbol. ^130].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1021
    (aSymbol == #+) ifTrue:[lineno := true. stackDelta := -1. self addLiteral:aSymbol. ^131].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1022
    (aSymbol == #~=) ifTrue:[lineno := true. stackDelta := -1. self addLiteral:aSymbol. ^132].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1023
    (aSymbol == #-) ifTrue:[lineno := true. stackDelta := -1. self addLiteral:aSymbol. ^133].
108
claus
parents: 106
diff changeset
  1024
    (aSymbol == #*) ifTrue:[lineno := true. stackDelta := -1. self addLiteral:aSymbol. ^230].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1025
    (aSymbol == #class) ifTrue:[self addLiteral:aSymbol. ^134].
5
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1026
    (aSymbol == #x) ifTrue:[lineno := true. self addLiteral:aSymbol. ^106].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1027
    (aSymbol == #y) ifTrue:[lineno := true. self addLiteral:aSymbol. ^107].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1028
    (aSymbol == #width) ifTrue:[lineno := true. self addLiteral:aSymbol. ^108].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1029
    (aSymbol == #height) ifTrue:[lineno := true. self addLiteral:aSymbol. ^109].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1030
    (aSymbol == #origin) ifTrue:[lineno := true. self addLiteral:aSymbol. ^154].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1031
    (aSymbol == #extent) ifTrue:[lineno := true. self addLiteral:aSymbol. ^155].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1032
    (aSymbol == #at:) ifTrue:[lineno := true. stackDelta := -1. self addLiteral:aSymbol. ^135].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1033
    (aSymbol == #at:put:)ifTrue:[lineno := true. stackDelta := -2. self addLiteral:aSymbol. ^136].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1034
    (aSymbol == #bitAnd:) ifTrue:[lineno := true. stackDelta := -1. self addLiteral:aSymbol. ^137].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1035
    (aSymbol == #bitOr:) ifTrue:[lineno := true. stackDelta := -1. self addLiteral:aSymbol. ^138].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1036
    (aSymbol == #plus1) ifTrue:[lineno := true. self addLiteral:#+. ^123].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1037
    (aSymbol == #minus1) ifTrue:[lineno := true. self addLiteral:#-. ^124].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1038
5
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1039
    (aSymbol == #incMethodVar) ifTrue:[lineno := true. self addLiteral:#+. extra := #index. ^125].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1040
    (aSymbol == #decMethodVar) ifTrue:[lineno := true. self addLiteral:#-. extra := #index. ^126].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1041
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1042
    (aSymbol == #eq0) ifTrue:[self addLiteral:#==. ^48].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1043
    (aSymbol == #ne0) ifTrue:[self addLiteral:#~~. ^49].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1044
5
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1045
    (aSymbol == #>) ifTrue:[lineno := true. self addLiteral:aSymbol. stackDelta := -1. ^ 145].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1046
    (aSymbol == #>=) ifTrue:[lineno := true. self addLiteral:aSymbol. stackDelta := -1. ^ 146].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1047
    (aSymbol == #<) ifTrue:[lineno := true. self addLiteral:aSymbol. stackDelta := -1. ^ 147].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1048
    (aSymbol == #<=) ifTrue:[lineno := true. self addLiteral:aSymbol. stackDelta := -1. ^ 148].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1049
    (aSymbol == #next) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 149].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1050
    (aSymbol == #peek) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 150].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1051
    (aSymbol == #value) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 151].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1052
    (aSymbol == #value:) ifTrue:[lineno := true. self addLiteral:aSymbol.  stackDelta := -1. ^ 152].
6
0cd4e7480440 *** empty log message ***
claus
parents: 5
diff changeset
  1053
    (aSymbol == #value:value:) ifTrue:[lineno := true. self addLiteral:aSymbol.  stackDelta := -2. ^ 178].
5
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1054
    (aSymbol == #size) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 153].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1055
    (aSymbol == #asInteger) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 158].
020d67cc590e *** empty log message ***
claus
parents: 4
diff changeset
  1056
    (aSymbol == #rounded) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 159].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1057
    (aSymbol == #mk0Block) ifTrue:[^ 156].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1058
    (aSymbol == #mkNilBlock) ifTrue:[^ 157].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1059
103
claus
parents: 102
diff changeset
  1060
    (aSymbol == #gt0) ifTrue:[lineno := true. self addLiteral:#>. ^ 212].
117
claus
parents: 111
diff changeset
  1061
    (aSymbol == #pushgt0) ifTrue:[lineno := true. stackDelta := 1. self addLiteral:#>. ^ 208].
106
claus
parents: 105
diff changeset
  1062
    (aSymbol == #basicNew) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 211].
claus
parents: 105
diff changeset
  1063
    (aSymbol == #new) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 213].
111
claus
parents: 110
diff changeset
  1064
    (aSymbol == #basicNew:) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 214].
claus
parents: 110
diff changeset
  1065
    (aSymbol == #new:) ifTrue:[lineno := true. self addLiteral:aSymbol. ^ 215].
103
claus
parents: 102
diff changeset
  1066
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1067
    (aSymbol == #falseJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 190].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1068
    (aSymbol == #trueJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 191].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1069
    (aSymbol == #nilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 192].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1070
    (aSymbol == #notNilJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 193].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1071
    (aSymbol == #jumpabs) ifTrue:[extra := #absoffset. ^ 194].
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1072
    (aSymbol == #makeBlockabs) ifTrue:[stackDelta := 1. extra := #absoffsetNvarNarg. ^ 195].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1073
    (aSymbol == #zeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 196].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1074
    (aSymbol == #notZeroJumpabs) ifTrue:[stackDelta := -1. extra := #absoffset. ^ 197].
1
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1075
    (aSymbol == #eqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 198].
77da9f5728e5 *** empty log message ***
claus
parents: 0
diff changeset
  1076
    (aSymbol == #notEqJumpabs) ifTrue:[stackDelta := -2. extra := #absoffset. ^ 199].
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1077
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1078
    (aSymbol == #pushThisContext) ifTrue:[stackDelta := 1. ^ 144].
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1079
76
55d64cb1ffea *** empty log message ***
claus
parents: 54
diff changeset
  1080
    (aSymbol == #isNil) ifTrue:[^ 188].
55d64cb1ffea *** empty log message ***
claus
parents: 54
diff changeset
  1081
    (aSymbol == #notNil) ifTrue:[^ 189].
55d64cb1ffea *** empty log message ***
claus
parents: 54
diff changeset
  1082
    (aSymbol == #not) ifTrue:[lineno := true. ^ 179].
110
claus
parents: 109
diff changeset
  1083
    (aSymbol == #&) ifTrue:[lineno := true. ^ 216].
claus
parents: 109
diff changeset
  1084
    (aSymbol == #|) ifTrue:[lineno := true. ^ 217].
76
55d64cb1ffea *** empty log message ***
claus
parents: 54
diff changeset
  1085
117
claus
parents: 111
diff changeset
  1086
    (aSymbol == #pushClassVarL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
claus
parents: 111
diff changeset
  1087
    (aSymbol == #pushGlobalL) ifTrue:[stackDelta := 1. extra := #speciallitL. ^ 218].
claus
parents: 111
diff changeset
  1088
    (aSymbol == #storeClassVarL) ifTrue:[extra := #speciallitL.stackDelta := -1. ^ 219].
claus
parents: 111
diff changeset
  1089
    (aSymbol == #storeGlobalL) ifTrue:[extra := #speciallitL. stackDelta := -1. ^ 219].
claus
parents: 111
diff changeset
  1090
    (aSymbol == #pushLitL) ifTrue:[stackDelta := 1. extra := #unsigned16. ^ 201].
claus
parents: 111
diff changeset
  1091
claus
parents: 111
diff changeset
  1092
    (aSymbol == #sendL) ifTrue:[lineno := true. extra := #specialL. ^ 205].
claus
parents: 111
diff changeset
  1093
    (aSymbol == #sendSelfL) ifTrue:[lineno := true. extra := #specialL. ^ 207].
claus
parents: 111
diff changeset
  1094
    (aSymbol == #sendDropL) ifTrue:[lineno := true. extra := #specialL. ^ 204].
claus
parents: 111
diff changeset
  1095
    (aSymbol == #superSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
claus
parents: 111
diff changeset
  1096
    (aSymbol == #hereSendL) ifTrue:[lineno := true. extra := #specialL. ^ 206].
106
claus
parents: 105
diff changeset
  1097
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1098
    self error:'invalid code symbol'.
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1099
    errorFlag := #Error
117
claus
parents: 111
diff changeset
  1100
claus
parents: 111
diff changeset
  1101
    "Modified: 3.9.1995 / 12:58:47 / claus"
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1102
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1103
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1104
checkForPrimitiveCode:nr
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1105
    "return the code for an ST-80 primitive method.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1106
     Since many primitives available on ST-80 should also be available
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1107
     somewhere in ST/X, this may work for many primitive numbers.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1108
     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
  1109
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1110
     This was added to allow emulation of (some) ST-80
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1111
     primitives (to fileIn RemoteInvocation & Monitor41 packages)"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1112
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1113
    |cls sel|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1114
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1115
    (nr == 75)  ifTrue:[ cls := Object. sel := #identityHash ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1116
    (nr == 110) ifTrue:[ cls := Object. sel := #==           ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1117
    (nr == 111) ifTrue:[ cls := Object. sel := #class        ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1118
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1119
     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
  1120
     containing primitive calls (who gives me the numbers ... ?)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1121
    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1122
    cls notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1123
	^ (cls compiledMethodAt:sel) code
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1124
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1125
    ^ nil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1126
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1127
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1128
genByteCodeFrom:symbolicCodeArray
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1129
    "convert symbolicCode into bytecodes"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1130
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1131
    |symIndex    "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1132
     codeSize    "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1133
     symCodeSize "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1134
     index addr
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1135
     codeSymbol nargs needRetry
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1136
     stackDepth relocInfo level nvars round t|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1137
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1138
    symbolicCodeArray isNil ifTrue:[^ self].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1139
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1140
    round := 0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1141
    needRetry := true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1142
    symCodeSize := symbolicCodeArray size.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1143
    codeSize := symCodeSize.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1144
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1145
    [needRetry] whileTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1146
	stackDepth := 0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1147
	maxStackDepth := 0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1148
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1149
	codeBytes := ByteArray uninitializedNew:codeSize.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1150
	relocInfo := Array basicNew:(codeSize + 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1151
	symIndex := 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1152
	codeIndex := 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1153
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1154
	needRetry := false.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1155
	round := round + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1156
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1157
	[symIndex <= symCodeSize] whileTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1158
	    relocInfo at:symIndex put:codeIndex.
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1159
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1160
	    codeSymbol := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1161
	    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1162
	    stackDelta := 0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1163
	    extra := nil.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1164
	    lineno := false.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1165
	    self appendByteCodeFor:codeSymbol.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1166
	    lineno ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1167
		self appendByte:((symbolicCodeArray at:symIndex) min:255).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1168
		symIndex := symIndex + 1
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1169
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1170
	    extra notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1171
		(extra == #number) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1172
		    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1173
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1174
		    self appendSignedByte:index
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1175
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1176
		(extra == #number16) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1177
		    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1178
		    symIndex := symIndex + 2.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1179
		    self appendSignedWord:index
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1180
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1181
		(extra == #unsigned16) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1182
		    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1183
		    symIndex := symIndex + 2.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1184
		    self appendWord:index
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1185
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1186
		(extra == #index) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1187
		    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1188
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1189
		    self appendByte:index
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1190
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1191
		(extra == #lit) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1192
		    index := self addLiteral:(symbolicCodeArray at:symIndex).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1193
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1194
		    self appendByte:index
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1195
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1196
		(extra == #speciallit) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1197
		    index := self addLiteral:(symbolicCodeArray at:symIndex).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1198
		    index > 255 ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1199
			self parseError:'too many globals (' , 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1200
					(symbolicCodeArray at:symIndex) ,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1201
					' index=' , index printString ,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1202
					') in method - please simplify'.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1203
			^ #Error
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1204
		    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1205
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1206
		    self appendByte:index.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1207
		    self appendByte:0.  "space for inline-generation"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1208
		    self appendByte:0.  "space for inline-address"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1209
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1210
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1211
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1212
		    symIndex := symIndex + 5
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1213
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1214
		(extra == #speciallitS) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1215
		    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1216
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1217
		    self appendByte:index.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1218
		    self appendByte:0.  "space for inline-generation"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1219
		    self appendByte:0.  "space for inline-address"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1220
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1221
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1222
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1223
		    symIndex := symIndex + 5
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1224
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1225
		(extra == #speciallitL) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1226
		    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1227
		    symIndex := symIndex + 2.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1228
		    self appendWord:index.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1229
		    self appendByte:0.  "space for inline-generation"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1230
		    self appendByte:0.  "space for inline-address"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1231
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1232
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1233
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1234
		    symIndex := symIndex + 5
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1235
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1236
		(extra == #offset) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1237
		    relocInfo at:symIndex put:codeIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1238
		    self addReloc:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1239
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1240
		    self appendByte:0
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1241
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1242
		(extra == #indexLevel) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1243
		    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1244
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1245
		    self appendByte:index.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1246
		    level := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1247
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1248
		    self appendByte:level
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1249
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1250
		(extra == #offsetNvarNarg) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1251
		    relocInfo at:symIndex put:codeIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1252
		    self addReloc:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1253
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1254
		    self appendByte:0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1255
		    nvars := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1256
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1257
		    self appendByte:nvars.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1258
		    level := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1259
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1260
		    self appendByte:level
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1261
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1262
		(extra == #absoffset) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1263
		    relocInfo at:symIndex put:codeIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1264
		    self addReloc:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1265
		    addr := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1266
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1267
		    self appendByte:(addr bitAnd:16rFF).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1268
		    self appendByte:((addr bitShift:-8) bitAnd:16rFF).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1269
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1270
		(extra == #absoffsetNvarNarg) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1271
		    relocInfo at:symIndex put:codeIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1272
		    self addReloc:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1273
		    addr := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1274
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1275
		    self appendByte:(addr bitAnd:16rFF).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1276
		    self appendByte:((addr bitShift:-8) bitAnd:16rFF).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1277
		    nvars := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1278
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1279
		    self appendByte:nvars.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1280
		    level := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1281
		    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1282
		    self appendByte:level
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1283
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1284
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1285
		extra == #special ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1286
		    ((codeSymbol == #send) 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1287
		     or:[codeSymbol == #sendSelf
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1288
		     or:[codeSymbol == #superSend
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1289
		     or:[codeSymbol == #hereSend]]]) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1290
			index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1291
			symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1292
			nargs := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1293
			symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1294
			self appendByte:nargs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1295
			self appendByte:index.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1296
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1297
			(codeSymbol == #superSend
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1298
			or:[codeSymbol == #hereSend]) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1299
			    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1300
			    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1301
			    self appendByte:index
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1302
			].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1303
			stackDelta := nargs negated.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1304
			codeSymbol == #sendSelf ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1305
			    stackDelta := stackDelta + 1
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1306
			]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1307
		    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1308
			(codeSymbol == #sendDrop) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1309
			    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1310
			    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1311
			    nargs := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1312
			    symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1313
			    self appendByte:nargs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1314
			    self appendByte:index.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1315
			    stackDelta := (nargs + 1) negated
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1316
			]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1317
		    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1318
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1319
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1320
		extra == #specialL ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1321
		    ((codeSymbol == #sendL) 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1322
		     or:[codeSymbol == #sendSelfL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1323
		     or:[codeSymbol == #superSendL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1324
		     or:[codeSymbol == #hereSendL]]]) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1325
			index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1326
			symIndex := symIndex + 2.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1327
			nargs := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1328
			symIndex := symIndex + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1329
			self appendByte:nargs.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1330
			self appendWord:index.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1331
			(codeSymbol == #superSendL
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1332
			or:[codeSymbol == #hereSendL]) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1333
			    index := symbolicCodeArray at:symIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1334
			    symIndex := symIndex + 2.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1335
			    self appendWord:index.
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
			stackDelta := nargs negated.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1338
			codeSymbol == #sendSelfL ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1339
			    stackDelta := stackDelta + 1
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1340
			]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1341
		    ]
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
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1344
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1345
	    stackDepth := stackDepth + stackDelta.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1346
	    (stackDepth > maxStackDepth) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1347
		maxStackDepth := stackDepth
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1348
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1349
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1350
	relocInfo at:symIndex put:codeIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1351
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1352
	needRetry ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1353
	    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1354
	     now relocate - returns true if ok, false if we have to do it again
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1355
	     (when short jumps have been changed to long jumps)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1356
	    "
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1357
	    relocList notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1358
		needRetry := (self relocateWith:symbolicCodeArray relocInfo:relocInfo) not.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1359
		"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1360
		 if returned with false, a relative jump was made into
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1361
		 an absolute jump - need to start over with one more byte space
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1362
		"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1363
		needRetry ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1364
		    relocList := nil.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1365
		    codeSize := codeSize + 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1366
		]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1367
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1368
	] ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1369
	    'compiling again ...' infoPrintNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1370
	]
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1371
    ].
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1372
    "code printNL."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1373
    ^ errorFlag
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1374
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1375
    "Modified: 3.9.1995 / 12:59:43 / claus"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1376
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1377
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1378
genSymbolicCode
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1379
    "traverse the parse-tree producing symbolicCode - return the codeArray"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1380
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1381
    |codeStream code thisStatement lastStatement|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1382
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1383
    litArray := nil.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1384
    codeStream := WriteStream on:(OrderedCollection new:100).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1385
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1386
    thisStatement := tree.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1387
    [thisStatement notNil] whileTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1388
	lastStatement := thisStatement.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1389
	thisStatement codeForSideEffectOn:codeStream inBlock:nil for:self.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1390
	thisStatement := thisStatement nextStatement
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1391
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1392
    (lastStatement isNil or:[lastStatement isReturnNode not])
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1393
    ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1394
	"not a return - add retSelf"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1395
	"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1396
	 if the last statement was a send for side-effect,
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1397
	 replace the previous drop by a retSelf
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1398
	"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1399
	lastStatement notNil ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1400
	    ((code := codeStream contents) notNil
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1401
	    and:[code size > 0
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1402
	    and:[code last == #drop]]) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1403
		codeStream position:(codeStream position - 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1404
		codeStream nextPut:#retSelf
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1405
	    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1406
	].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1407
	codeStream nextPut:#retSelf
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1408
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1409
    ^ codeStream contents
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1410
!
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1411
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1412
moveGlobalsToFront
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1413
    "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
  1414
     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
  1415
     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
  1416
     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
  1417
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1418
    litArray isNil ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1419
	^ 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
  1420
    ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1421
    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
  1422
		   (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
  1423
		   ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1424
		      (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
  1425
		      ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1426
			(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
  1427
			ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1428
			  (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
  1429
			  ifTrue:[a < b].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1430
			]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1431
		      ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1432
		    ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1433
		   ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1434
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1435
"
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1436
    #(#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
  1437
     sort:[:a :b |  
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1438
		   (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
  1439
		   ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1440
		      (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
  1441
		      ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1442
			(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
  1443
			ifTrue:[
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1444
			  (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
  1445
			  ifTrue:[(a < b)].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1446
			]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1447
		      ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1448
		    ]
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1449
		   ].
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1450
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1451
"
141
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1452
!
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1453
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1454
relocateWith:symbolicCodeArray relocInfo:relocInfo
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1455
    "helper for genByteCodeFrom - relocate code using relocInfo.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1456
     if relocation fails badly (due to long relative jumps) patch
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1457
     symbolicCode to use absolute jumps instead and return false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1458
     (genByteCodeFrom will then try again). Otherwise return true.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1459
     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
  1460
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1461
    |delta       "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1462
     codePos     "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1463
     opCodePos   "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1464
     codeOffset  "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1465
     symOffset 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1466
     opcode      "{Class: SmallInteger }"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1467
     dstOpcode jumpTarget
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1468
     jumpCode deleteSet|
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1469
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1470
    deleteSet := OrderedCollection new.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1471
    relocList do:[:sIndex |
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1472
	"have to relocate symCode at sIndex ..." 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1473
	symOffset := symbolicCodeArray at:sIndex.   "the target in the symbolic code"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1474
	codePos := relocInfo at:sIndex.             "position of the offet in byte code"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1475
	codeOffset := relocInfo at:symOffset.       "position of the target in byte code"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1476
	delta := codeOffset - codePos - 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1477
	opCodePos := codePos - 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1478
	opcode := codeBytes at:opCodePos.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1479
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1480
	(opcode between:190 and:199) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1481
	    "an absolute jump/makeBlock"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1482
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1483
	    codeBytes at:codePos put:(codeOffset bitAnd:16rFF).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1484
	    codeBytes at:(codePos + 1) put:(codeOffset bitShift:-8)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1485
	] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1486
	    "get jump-code from long and vlong codes"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1487
	    (opcode between:50 and:59) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1488
		(opcode between:60 and:69) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1489
		    opcode := opcode - 10
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1490
		] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1491
		    (opcode between:70 and:79) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1492
			opcode := opcode - 20
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1493
		    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1494
			self error:'invalid code to relocate'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1495
		    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1496
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1497
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1498
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1499
	    "optimize jump to return and jump to jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1500
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1501
	    (opcode == 54) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1502
		"a jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1503
		dstOpcode := symbolicCodeArray at:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1504
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1505
		(#(retSelf retTop retNil retTrue retFalse ret0 "blockRetTop") includes:dstOpcode) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1506
		    "a jump to a return - put in the return instead jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1507
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1508
		    symbolicCodeArray at:(sIndex - 1) put:dstOpcode.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1509
		    symbolicCodeArray at:sIndex put:dstOpcode.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1510
		    codeBytes at:opCodePos put:(self byteCodeFor:dstOpcode).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1511
		    delta := 0.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1512
		    deleteSet add:sIndex.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1513
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1514
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1515
'jump to return at: ' print. (sIndex - 1) printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1516
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1517
		] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1518
		    (dstOpcode == #jump) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1519
			"jump to jump to be done soon"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1520
			jumpTarget := symbolicCodeArray at:(symOffset + 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1521
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1522
'jump to jump at: ' print. (sIndex - 1) print.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1523
'  newTarget:' print. jumpTarget printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1524
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1525
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1526
			symbolicCodeArray at:sIndex put:jumpTarget.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1527
			symOffset := jumpTarget.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1528
			codeOffset := relocInfo at:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1529
			delta := codeOffset - codePos - 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1530
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1531
			"continue with new delta"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1532
		    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1533
		]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1534
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1535
	    (#(50 51 52 53 56 57 58 59) includes:opcode) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1536
		"a conditional jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1537
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1538
		dstOpcode := symbolicCodeArray at:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1539
		(dstOpcode == #jump) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1540
		    "conditional jump to unconditional jump"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1541
		    jumpTarget := symbolicCodeArray at:(symOffset + 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1542
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1543
'cond jump to jump at: ' print. (sIndex - 1) print.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1544
'  newTarget:' print. jumpTarget printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1545
" 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1546
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1547
		    symbolicCodeArray at:sIndex put:jumpTarget.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1548
		    symOffset := jumpTarget.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1549
		    codeOffset := relocInfo at:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1550
		    delta := codeOffset - codePos - 1.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1551
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1552
		    "continue with new delta"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1553
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1554
	    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1555
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1556
	    (delta >= 0) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1557
		(delta > 127) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1558
		    (opcode between:50 and:59) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1559
			self error:'invalid code to relocate'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1560
		    ] ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1561
			(delta > 255) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1562
			    "change jmp into vljmp ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1563
			    codeBytes at:opCodePos put:(opcode + 20).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1564
			    delta := delta - 256 
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1565
			] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1566
			    "change jmp into ljmp ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1567
			    codeBytes at:opCodePos put:(opcode + 10).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1568
			    delta := delta - 128
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1569
			].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1570
			(delta > 127) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1571
			    "change symbolic into a jump absolute and fail"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1572
			    jumpCode := symbolicCodeArray at:(sIndex - 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1573
			    symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1574
			    symbolicCodeArray at:sIndex put:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1575
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1576
'change short into abs jump' printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1577
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1578
			    deleteSet do:[:d | relocList remove:d].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1579
			    ^ false
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
		    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1582
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1583
		codeBytes at:codePos put:delta
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1584
	    ] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1585
		(delta < -128) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1586
		    (opcode between:50 and:59) ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1587
			self error:'invalid code to relocate'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1588
		    ] ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1589
			(delta < -256) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1590
			    "change jmp into vljmp ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1591
			    codeBytes at:opCodePos put:(opcode + 20).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1592
			    delta := delta + 256
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1593
			] ifFalse:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1594
			    "change jmp into ljmp ..."
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1595
			    codeBytes at:opCodePos put:(opcode + 10).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1596
			    delta := delta + 128
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1597
			].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1598
			(delta < -128) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1599
			    "change symbolic into a jump absolute and fail"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1600
			    jumpCode := symbolicCodeArray at:(sIndex - 1).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1601
			    symbolicCodeArray at:(sIndex - 1) put:(self absJumpFromJump:jumpCode).
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1602
			    symbolicCodeArray at:sIndex put:symOffset.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1603
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1604
'change short into abs jump' printNL.
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1605
"
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1606
			    deleteSet do:[:d | relocList remove:d].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1607
			    ^ false
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1608
			]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1609
		    ]
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1610
		].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1611
		codeBytes at:codePos put:(256 + delta)
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1612
	    ]
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
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1615
    (errorFlag == #Error) ifTrue:[
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1616
	self error:'relocation range error'
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1617
    ].
d378d997aab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 137
diff changeset
  1618
    ^ true
0
7ad01559b262 Initial revision
claus
parents:
diff changeset
  1619
! !
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1620
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1621
!ByteCodeCompiler methodsFor:'machine code generation'!
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1622
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1623
compileToMachineCode:aString forClass:aClass inCategory:cat 
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1624
                             notifying:requestor install:install skipIfSame:skipIfSame silent:silent
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1625
    "this is called to compile primitive code.
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1626
     This is EXPERIMENTAL and going to be changed to raise an error,
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1627
     an redefined in subclasses which can do it (either by direct compilation, or by calling
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1628
     the external stc do do it.
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1629
     For a description of the arguments, see compile:forClass....."
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1630
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1631
    |stFileName stream handle address flags command oFileName soFileName 
120
claus
parents: 118
diff changeset
  1632
     initName newMethod ok status className sep class stcPath 
156
2bf6dc265509 method loading
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
  1633
     errorStream errorMessages eMsg m|
96
claus
parents: 95
diff changeset
  1634
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
  1635
    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
  1636
    STCCompilation == #never ifTrue:[^ #CannotLoad].
120
claus
parents: 118
diff changeset
  1637
    (stcPath := self class incrementalStcPath) isNil ifTrue:[
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
  1638
        self parseError:'no stc compiler available - cannot create machine code' position:1.
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
  1639
        ^ #CannotLoad
120
claus
parents: 118
diff changeset
  1640
    ].
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1641
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1642
    SequenceNumber isNil ifTrue:[
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
  1643
        SequenceNumber := 0.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1644
    ].
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1645
    SequenceNumber := SequenceNumber + 1.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1646
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1647
    initName := 'ttt' , SequenceNumber printString.
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1648
    stFileName := initName , '.st'. 
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1649
    stream := stFileName asFilename writeStream.
97
claus
parents: 96
diff changeset
  1650
    sep := stream class chunkSeparator.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1651
101
claus
parents: 98
diff changeset
  1652
    class := aClass.
claus
parents: 98
diff changeset
  1653
    class isMeta ifTrue:[
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
  1654
        class := aClass soleInstance
101
claus
parents: 98
diff changeset
  1655
    ].
claus
parents: 98
diff changeset
  1656
    class allSuperclasses reverseDo:[:cls|
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
  1657
        cls ~~ Object ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1658
            cls isLoaded ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1659
                ^ #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
  1660
            ].
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
  1661
            cls fileOutDefinitionOn:stream.
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
  1662
            stream nextPut:sep; cr.
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
  1663
        ]
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1664
    ].
101
claus
parents: 98
diff changeset
  1665
    class fileOutDefinitionOn:stream.
96
claus
parents: 95
diff changeset
  1666
    stream nextPut:sep; cr.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1667
101
claus
parents: 98
diff changeset
  1668
    class fileOutPrimitiveDefinitionsOn:stream.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1669
96
claus
parents: 95
diff changeset
  1670
    stream nextPut:sep.
claus
parents: 95
diff changeset
  1671
    className := aClass name.
claus
parents: 95
diff changeset
  1672
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1673
    aClass isMeta ifTrue:[
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
  1674
        stream nextPutAll:(className copyTo:(className size - 5)); nextPutAll:' class'.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1675
    ] ifFalse:[
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
  1676
        stream nextPutAll:className.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1677
    ].
96
claus
parents: 95
diff changeset
  1678
    stream nextPutAll:' methodsFor:'''; nextPutAll:cat; nextPutAll:''''.
claus
parents: 95
diff changeset
  1679
    stream nextPut:sep.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1680
    stream cr.
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1681
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
  1682
    stream nextPutAll:'"{ Line: 0 }"'; cr; nextPutAll:aString.
96
claus
parents: 95
diff changeset
  1683
    stream nextPut:sep; space; nextPut:sep.
claus
parents: 95
diff changeset
  1684
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1685
    stream close.
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1686
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1687
    "
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1688
     call stc to compile it
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1689
    "
94
claus
parents: 90
diff changeset
  1690
    oFileName := './' , initName , '.o'. 
claus
parents: 90
diff changeset
  1691
    oFileName asFilename delete.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1692
150
7aae365b392a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 148
diff changeset
  1693
    flags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName .
124
claus
parents: 120
diff changeset
  1694
    STCCompilationDefines notNil ifTrue:[
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
  1695
        flags := STCCompilationDefines , ' ' , flags
124
claus
parents: 120
diff changeset
  1696
    ].
claus
parents: 120
diff changeset
  1697
    STCCompilationIncludes notNil ifTrue:[
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
  1698
        flags := STCCompilationIncludes , ' ' , flags
124
claus
parents: 120
diff changeset
  1699
    ].
claus
parents: 120
diff changeset
  1700
    STCCompilationOptions notNil ifTrue:[
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
  1701
        flags := STCCompilationOptions , ' ' , flags
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1702
    ].
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1703
101
claus
parents: 98
diff changeset
  1704
    command := stcPath , ' ' , flags , ' -c ' , stFileName.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1705
"/    command printNL.
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1706
120
claus
parents: 118
diff changeset
  1707
    ok := OperatingSystem executeCommand:command.
claus
parents: 118
diff changeset
  1708
    status := OperatingSystem lastExecStatus.
101
claus
parents: 98
diff changeset
  1709
120
claus
parents: 118
diff changeset
  1710
    "for debugging - leave c intermediate"
claus
parents: 118
diff changeset
  1711
    STCKeepCIntermediate == true ifTrue:[
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
  1712
        command := stcPath , ' ' , flags , ' -C ' , stFileName.
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
  1713
        command printNL.
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
  1714
        OperatingSystem executeCommand:command
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1715
    ].
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1716
94
claus
parents: 90
diff changeset
  1717
    oFileName asFilename exists ifTrue:[
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
  1718
        ok ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1719
            'oops - system says it failed - but o-file is there ...' printNL.
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
  1720
            ok := true
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
  1721
        ]
94
claus
parents: 90
diff changeset
  1722
    ] ifFalse:[
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
  1723
        ok := false
94
claus
parents: 90
diff changeset
  1724
    ].
claus
parents: 90
diff changeset
  1725
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1726
    ok ifFalse:[
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
  1727
        status >= 16r200 ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1728
            errorStream := 'errorOutput' asFilename readStream.
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
  1729
            errorStream notNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1730
                errorMessages := errorStream contents.
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
  1731
                errorMessages notNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1732
                    errorMessages := errorMessages asStringCollection.
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
  1733
                    errorMessages size > 20 ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1734
                        errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped'
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
  1735
                    ].
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
  1736
"/                    errorMessages := errorMessages collect:[:line |
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1737
"/                        (line startsWith:(stFileName , ':')) ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1738
"/                            'Line: ' , (line copyFrom:(stFileName size + 2))
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1739
"/                        ] ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1740
"/                            line
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1741
"/                        ]
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
  1742
"/                      ].
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
  1743
                    errorMessages := errorMessages asString
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
  1744
                ].
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
  1745
            ].
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
  1746
            errorMessages isNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1747
                errorMessages := ''
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
  1748
            ].
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
  1749
            eMsg := ('STC / CC error during compilation:\\',errorMessages) withCRs.
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
  1750
        ] ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1751
            eMsg := 'oops, no STC - cannot create machine code'
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
  1752
        ].
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
  1753
        'errorOutput' asFilename remove.
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
  1754
        self parseError:eMsg position:1.
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
  1755
        OperatingSystem removeFile:stFileName.
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
  1756
        ^ #Error
120
claus
parents: 118
diff changeset
  1757
    ].
claus
parents: 118
diff changeset
  1758
claus
parents: 118
diff changeset
  1759
    (ObjectFileLoader notNil 
claus
parents: 118
diff changeset
  1760
    and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[
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
  1761
        self parseError:'no dynamic load configured - cannot load machine code' position:1.
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
  1762
        OperatingSystem removeFile:stFileName.
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
  1763
        ^ #CannotLoad
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1764
    ].
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1765
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1766
    OperatingSystem getOSType = 'irix' ifTrue:[
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
  1767
        "
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
  1768
         link it to a shared object
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
  1769
        "
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
  1770
        soFileName := './' , initName , '.so'. 
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
  1771
        OperatingSystem executeCommand:'rm -f ' , soFileName.
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
  1772
        OperatingSystem executeCommand:'ld -shared -all -o ' , soFileName , ' ' , oFileName.
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
  1773
        OperatingSystem removeFile:oFileName.
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
  1774
        oFileName := soFileName. 
98
claus
parents: 97
diff changeset
  1775
    ] ifFalse:[
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
  1776
        OperatingSystem getOSType = 'sys5_4' ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1777
            "
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
  1778
             link it to a shared object
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
  1779
            "
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
  1780
            soFileName := './' , initName , '.so'. 
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
  1781
            OperatingSystem executeCommand:'rm -f ' , soFileName.
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
  1782
            OperatingSystem executeCommand:'ld -G -o ' , soFileName , ' ' , oFileName.
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
  1783
            OperatingSystem removeFile:oFileName.
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
  1784
            oFileName := soFileName. 
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
  1785
        ].
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1786
    ].
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1787
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1788
    "
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1789
     load the objectfile
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1790
    "
109
claus
parents: 108
diff changeset
  1791
    handle := ObjectFileLoader loadDynamicObject:oFileName.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1792
    handle isNil ifTrue:[
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
  1793
        OperatingSystem removeFile:stFileName.
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
  1794
        OperatingSystem removeFile:oFileName.
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
  1795
        self parseError:'dynamic load failed - cannot create machine code' position:1.
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
  1796
        ^ #CannotLoad
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1797
    ].
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1798
"/    ('handle is ' , handle printString) printNL.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1799
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1800
    address := ObjectFileLoader getFunction:'__' , initName , '_Init' from:handle.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1801
    address isNil ifTrue:[
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
  1802
        address := ObjectFileLoader getFunction:'_' , initName , '_Init' from:handle.
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
  1803
        address isNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1804
            (ObjectFileLoader getListOfUndefinedSymbolsFrom:handle) size > 0 ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1805
                ObjectFileLoader listUndefinedSymbolsIn:handle.
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
  1806
                eMsg := 'undefined symbols in primitive code'.
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
  1807
            ] ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1808
                eMsg := initName , '_Init() lookup failed'
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
  1809
            ].
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
  1810
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
  1811
            ObjectFileLoader unloadDynamicObject:handle.
125
Claus Gittinger <cg@exept.de>
parents: 124
diff changeset
  1812
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
  1813
            OperatingSystem removeFile:stFileName.
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
  1814
            OperatingSystem removeFile:oFileName.
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
  1815
            self parseError:(eMsg , ' - cannot create machine code') position:1.
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
  1816
            ^ #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
  1817
        ]
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1818
    ].
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1819
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1820
"/    ('init at ' , address printString) printNL.
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1821
156
2bf6dc265509 method loading
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
  1822
    m := ObjectFileLoader 
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
  1823
        callInitFunctionAt:address 
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
  1824
        specialInit:true
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
  1825
        forceOld:true 
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
  1826
        interruptable:false
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
  1827
        argument:2
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1828
        identifyAs:handle
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
  1829
        returnsObject:true.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1830
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1831
    "
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1832
     did it work ?
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1833
    "
96
claus
parents: 95
diff changeset
  1834
    newMethod := aClass compiledMethodAt:selector.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1835
    newMethod notNil ifTrue:[
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
  1836
        m ~~ newMethod ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1837
            'BCOMPILER: oops - loaded method installed itself elsewhere' errorPrintNL.
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
  1838
        ].
156
2bf6dc265509 method loading
Claus Gittinger <cg@exept.de>
parents: 155
diff changeset
  1839
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
  1840
        newMethod source:aString.
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
  1841
        Project notNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1842
            newMethod package:(Project currentPackageName)
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
  1843
        ].
160
5e01f0113d6e dont forget package-info in compiled methods
Claus Gittinger <cg@exept.de>
parents: 156
diff changeset
  1844
162
2349ee7039ce *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
  1845
"/        aClass updateRevisionString.
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
  1846
        aClass addChangeRecordForMethod:newMethod.
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
  1847
        (silent or:[Smalltalk silentLoading == true]) ifFalse:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1848
            Transcript showCr:('    compiled: ', className,' ',selector,' - machine code')
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
  1849
        ].
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
  1850
        ObjectMemory flushCaches.
120
claus
parents: 118
diff changeset
  1851
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
  1852
        OperatingSystem removeFile:stFileName.
120
claus
parents: 118
diff changeset
  1853
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
  1854
        handle method:newMethod.
120
claus
parents: 118
diff changeset
  1855
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
  1856
        "/ check for obsolete loaded objects and unload them
120
claus
parents: 118
diff changeset
  1857
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
  1858
        ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle |
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
  1859
            anotherHandle isMethodHandle ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1860
                anotherHandle method isNil ifTrue:[
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1861
                    ObjectFileLoader unloadObjectFile:anotherHandle pathName.
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
  1862
                    OperatingSystem removeFile:anotherHandle pathName.
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
  1863
                ]
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
  1864
            ]
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
  1865
        ].
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
  1866
        ^ newMethod.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1867
    ].
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1868
120
claus
parents: 118
diff changeset
  1869
    OperatingSystem removeFile:stFileName.
claus
parents: 118
diff changeset
  1870
    OperatingSystem removeFile:oFileName.
54
86c5b39c2eca *** empty log message ***
claus
parents: 49
diff changeset
  1871
    self parseError:'dynamic load failed' position:1.
172
85ad12831217 give user a chance to choose between trapCode and original code if compilation to binary is not possible
Claus Gittinger <cg@exept.de>
parents: 162
diff changeset
  1872
    ^ #CannotLoad
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1873
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1874
    "
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1875
     |m|
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1876
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1877
     Object subclass:#Test
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
  1878
            instanceVariableNames:''
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
  1879
            classVariableNames:''
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
  1880
            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
  1881
            category:'tests'.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1882
     m := ByteCodeCompiler
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
  1883
            compile:'foo ^ ''hello'''
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
  1884
            forClass:Test
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
  1885
            inCategory:'tests'
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
  1886
            notifying:nil
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
  1887
            install:false
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
  1888
            skipIfSame:false.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1889
     m inspect
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1890
    "
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1891
    "
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1892
     |m|
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1893
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1894
     Object subclass:#Test
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
  1895
            instanceVariableNames:''
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
  1896
            classVariableNames:''
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
  1897
            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
  1898
            category:'tests'.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1899
     m := ByteCodeCompiler
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
  1900
            compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}'
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
  1901
            forClass:Test
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
  1902
            inCategory:'tests'
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
  1903
            notifying:nil
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
  1904
            install:false
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
  1905
            skipIfSame:false
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
  1906
            silent:false.
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1907
     m inspect
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1908
    "
120
claus
parents: 118
diff changeset
  1909
claus
parents: 118
diff changeset
  1910
    "Modified: 14.9.1995 / 22:33:04 / claus"
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
  1911
    "Modified: 13.12.1995 / 20:19:32 / cg"
97
claus
parents: 96
diff changeset
  1912
!
claus
parents: 96
diff changeset
  1913
claus
parents: 96
diff changeset
  1914
trappingStubMethodFor:aString inCategory:cat
claus
parents: 96
diff changeset
  1915
    "return a stub method which traps and reports an error whenever
claus
parents: 96
diff changeset
  1916
     called."
claus
parents: 96
diff changeset
  1917
claus
parents: 96
diff changeset
  1918
    |newMethod lits|
claus
parents: 96
diff changeset
  1919
claus
parents: 96
diff changeset
  1920
    newMethod := Method new.
claus
parents: 96
diff changeset
  1921
    lits := self literalArray.
claus
parents: 96
diff changeset
  1922
    lits notNil ifTrue:[
claus
parents: 96
diff changeset
  1923
	"literals MUST be an array - not just any Collection"
claus
parents: 96
diff changeset
  1924
	lits := Array withAll:lits.
claus
parents: 96
diff changeset
  1925
	newMethod literals:lits
claus
parents: 96
diff changeset
  1926
    ].
124
claus
parents: 120
diff changeset
  1927
    newMethod makeUncompiled.
97
claus
parents: 96
diff changeset
  1928
    newMethod numberOfMethodVars:(self numberOfMethodVars).
claus
parents: 96
diff changeset
  1929
    newMethod numberOfMethodArgs:(self numberOfMethodArgs).
claus
parents: 96
diff changeset
  1930
    newMethod source:aString.
claus
parents: 96
diff changeset
  1931
    newMethod category:cat.
claus
parents: 96
diff changeset
  1932
    Project notNil ifTrue:[
98
claus
parents: 97
diff changeset
  1933
	newMethod package:(Project currentPackageName)
97
claus
parents: 96
diff changeset
  1934
    ].
claus
parents: 96
diff changeset
  1935
    ^ newMethod
49
02660b790c3e *** empty log message ***
claus
parents: 46
diff changeset
  1936
! !
128
61eb0b356b89 change classes versionString when class changes (prepare for sourceCode system)
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
  1937
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  1938
!ByteCodeCompiler class methodsFor:'documentation'!
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  1939
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  1940
version
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
  1941
    ^ '$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.56 1995-12-13 19:45:43 cg Exp $'
148
ef0e604209ec version method at the end
Claus Gittinger <cg@exept.de>
parents: 141
diff changeset
  1942
! !