CompiledCode.st
author Stefan Vogel <sv@exept.de>
Thu, 13 Jun 1996 00:11:10 +0200
changeset 1461 dd25bb1e9973
parent 1293 02fb05148c98
child 1493 33e226c7d187
permissions -rw-r--r--
Use methodDictionary instead of selector/method arrays. Still backward compatible if UseMethodDictionary in Behavior is set to false.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
     1
"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
     3
	      All Rights Reserved
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
     4
1eba5946aea2 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
1eba5946aea2 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
1eba5946aea2 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
1eba5946aea2 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
1eba5946aea2 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    11
"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    12
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
    13
'From Smalltalk/X, Version:2.10.9 on 11-jun-1996 at 16:33:14'                   !
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
    14
249
claus
parents: 225
diff changeset
    15
ExecutableFunction subclass:#CompiledCode
1182
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    16
	instanceVariableNames:'flags byteCode literals'
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    17
	classVariableNames:'NoByteCodeSignal InvalidByteCodeSignal InvalidInstructionSignal
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    18
		BadLiteralsSignal NonBooleanReceiverSignal ArgumentSignal'
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    19
	poolDictionaries:''
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    20
	category:'Kernel-Methods'
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    21
!
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    22
249
claus
parents: 225
diff changeset
    23
!CompiledCode class methodsFor:'documentation'!
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    24
88
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    25
copyright
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    26
"
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    27
 COPYRIGHT (c) 1994 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    28
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    29
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    30
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    31
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    33
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    34
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    35
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    36
"
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    37
!
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    38
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    39
documentation
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    40
"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    41
    This is an abstract class, to merge common attributes of Blocks and
328
claus
parents: 326
diff changeset
    42
    Methods i.e. describe all objects consisting of either compiled or 
claus
parents: 326
diff changeset
    43
    interpreted code.
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    44
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    45
    Instances of CompiledCode are not to be created by user code
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    46
    (the compilers create Blocks, Methods etc.)
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    47
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    48
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    49
    [Instance variables:]
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    50
357
claus
parents: 345
diff changeset
    51
      flags       <SmallInteger>    special flag bits coded in a number
225
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    52
      byteCode    <ByteArray>       bytecode if its an interpreted codeobject
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    53
      literals    <Array>           the block/methods literal array
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    54
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    55
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    56
    [Class variables:]
225
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    57
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    58
      NoByteCodeSignal              raised if a codeObject is about to be executed
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    59
                                    which has neither code nor byteCode (i.e. both are nil)
225
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    60
      InvalidByteCodeSignal         raised if byteCode is not an instance of ByteArray
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    61
      InvalidInstructionSignal      raised if an invalid instruction opcode is encountered
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    62
      BadLiteralsSignal             raised if literalArray is not an array
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    63
      NonBooleanReceiverSignal      raised for conditional jumps where receiver is not a boolean
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    64
      ArgumentSignal                raised if argument count is not what the codeObject expects
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    65
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    66
    all of these signals are children of ExecutionErrorSignal.
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    67
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    68
    NOTICE: layout known by runtime system and compiler - do not change
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    69
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    70
    [author:]
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    71
        Claus Gittinger
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    72
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    73
"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    74
! !
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    75
249
claus
parents: 225
diff changeset
    76
!CompiledCode class methodsFor:'initialization'!
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
    77
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
    78
initialize
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    79
    "create signals raised by various errors"
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    80
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
    81
    NoByteCodeSignal isNil ifTrue:[
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    82
        NoByteCodeSignal := ExecutionErrorSignal newSignalMayProceed:true.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    83
        NoByteCodeSignal nameClass:self message:#noByteCodeSignal.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    84
        NoByteCodeSignal notifierString:'nil byteCode in code-object - not executable'.
159
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    85
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    86
        InvalidByteCodeSignal := ExecutionErrorSignal newSignalMayProceed:true.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    87
        InvalidByteCodeSignal nameClass:self message:#invalidByteCodeSignal.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    88
        InvalidByteCodeSignal notifierString:'invalid byteCode in code-object - not executable'.
159
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    89
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    90
        InvalidInstructionSignal := ExecutionErrorSignal newSignalMayProceed:true.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    91
        InvalidInstructionSignal nameClass:self message:#invalidInstructionSignal.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    92
        InvalidInstructionSignal notifierString:'invalid instruction in code-object - not executable'.
159
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    93
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    94
        BadLiteralsSignal := ExecutionErrorSignal newSignalMayProceed:true.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    95
        BadLiteralsSignal nameClass:self message:#badLiteralsSignal.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    96
        BadLiteralsSignal notifierString:'bad literal table in code-object - should not happen'.
159
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    97
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    98
        NonBooleanReceiverSignal := ExecutionErrorSignal newSignalMayProceed:true.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
    99
        NonBooleanReceiverSignal nameClass:self message:#nonBooleanReceiverSignal.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
   100
        NonBooleanReceiverSignal notifierString:'if/while on non-boolean receiver'.
159
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
   101
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
   102
        ArgumentSignal := ExecutionErrorSignal newSignalMayProceed:true.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
   103
        ArgumentSignal nameClass:self message:#argumentSignal.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
   104
        ArgumentSignal notifierString:'bad argument(s)'.
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   105
    ]
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
   106
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1196
diff changeset
   107
    "Modified: 22.4.1996 / 16:33:38 / cg"
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   108
! !
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   109
345
claus
parents: 328
diff changeset
   110
!CompiledCode class methodsFor:'Signal constants'!
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   111
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   112
argumentSignal
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   113
    "return the signal raised when something's wrong with the
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   114
     arguments"
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   115
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   116
    ^ ArgumentSignal
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   117
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   118
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   119
executionErrorSignal
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   120
    "return the parent-signal of all execution errors"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   121
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   122
    ^ ExecutionErrorSignal
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   123
! !
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   124
249
claus
parents: 225
diff changeset
   125
!CompiledCode class methodsFor:'queries'!
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   126
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   127
isBuiltInClass
1264
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
   128
    "return true if this class is known by the run-time-system.
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
   129
     Here, true is returned for myself, false for subclasses."
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   130
1182
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   131
    ^ self == CompiledCode
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   132
1264
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
   133
    "Modified: 23.4.1996 / 15:57:03 / cg"
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   134
! !
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   135
249
claus
parents: 225
diff changeset
   136
!CompiledCode methodsFor:'accessing'!
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   137
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   138
byteCode
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   139
    "return the bytecode (a ByteArray)"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   140
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   141
    ^ byteCode
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   142
!
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   143
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   144
literals
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   145
    "return the literal array"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   146
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   147
    ^ literals
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   148
! !
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   149
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   150
!CompiledCode methodsFor:'converting'!
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   151
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   152
makeRealMethod
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   153
    "by default, we are a real method.
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   154
     Subclasses (e.g. LazyMethod) may redefine this"
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   155
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   156
    ^ self
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   157
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   158
    "Created: 7.6.1996 / 12:45:50 / stefan"
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   159
! !
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   160
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   161
!CompiledCode methodsFor:'error handling'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   162
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   163
badArgumentArray
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   164
    "this error is triggered, if a non array is passed to 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   165
     #valueWithReceiver:.. methods"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   166
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   167
    ^ ArgumentSignal
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   168
	raiseRequestWith:self
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   169
	errorString:'argumentArray must be an Array'
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   170
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   171
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   172
badLiteralTable
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   173
    "this error is triggered, when a block/method is called with a bad literal
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   174
     array (i.e. non-array) - this can only happen, if the
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   175
     compiler is broken or someone played around with a block/methods
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   176
     literal table or the GC is broken and corrupted it."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   177
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   178
    ^ BadLiteralsSignal raise.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   179
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   180
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   181
invalidByteCode
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   182
    "this error is triggered when the interpreter tries to execute a
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   183
     code object, where the byteCode is nonNil, but not a ByteArray.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   184
     Can only happen when Compiler/runtime system is broken or
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   185
     someone played around with a block/method."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   186
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   187
    ^ InvalidByteCodeSignal raise.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   188
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   189
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   190
invalidInstruction
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   191
    "this error is triggered when the bytecode-interpreter tries to
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   192
     execute an invalid bytecode instruction.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   193
     Can only happen when Compiler/runtime system is broken or
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   194
     someone played around with the block/methods code."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   195
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   196
    ^ InvalidInstructionSignal raise.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   197
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   198
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   199
noByteCode
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   200
    "this error is triggered when the interpreter tries to execute a
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   201
     code object, where both the code and byteCode instances are nil.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   202
     This can happen if:
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   203
	the Compiler/runtime system is broken,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   204
	someone played around with a block/method, 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   205
	compilation of a lazy method failed
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   206
	(i.e. the lazy method contains an error or
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   207
	 it contains primitive code and there is no stc compiler available)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   208
	an unloaded object modules method is called for.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   209
     Only the first case is to be considered serious - it should not happen
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   210
     if the system is used correctly."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   211
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   212
    ^ NoByteCodeSignal raise.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   213
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   214
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   215
receiverNotBoolean:anObject
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   216
    "this error is triggered when the bytecode-interpreter tries to
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   217
     execute ifTrue:/ifFalse or whileTrue: type of expressions where the
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   218
     receiver is neither true nor false."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   219
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   220
    ^ NonBooleanReceiverSignal raise.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   221
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   222
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   223
tooManyArguments
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   224
    "this error is triggered, when a method/block tries to perform a send with
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   225
     more arguments than supported by the interpreter. This can only happen,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   226
     if the compiler has been changed without updating the VM."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   227
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   228
    ^ ArgumentSignal
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   229
	raiseRequestWith:self
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   230
	errorString:'too many args in send'
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   231
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   232
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   233
!CompiledCode methodsFor:'private accessing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   234
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   235
byteCode:aByteArray
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   236
    "set the bytecode field - DANGER ALERT"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   237
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   238
    byteCode := aByteArray
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   239
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   240
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   241
dynamic
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   242
    "return the flag stating that the machine code was created
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   243
     dynamically (from bytecode)."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   244
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   245
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   246
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   247
    /* made this a primitive to get define in stc.h */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   248
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   249
    RETURN ((__intVal(__INST(flags)) & F_DYNAMIC) ? true : false);
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   250
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   251
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   252
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   253
dynamic:aBoolean
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   254
    "set/clear the flag bit stating that the machine code was created
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   255
     dynamically and should be flushed on image-restart.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   256
     Obsolete - now done in VM"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   257
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   258
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   259
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   260
    int newFlags = __intVal(__INST(flags));
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   261
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   262
    /* made this a primitive to get define in stc.h */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   263
    if (aBoolean == true)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   264
	newFlags |= F_DYNAMIC;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   265
    else
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   266
	newFlags &= ~F_DYNAMIC;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   267
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   268
    __INST(flags) = __MKSMALLINT(newFlags);
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   269
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   270
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   271
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   272
literals:aLiteralArray 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   273
    "set the literal array for evaluation - DANGER ALERT"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   274
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   275
    literals := aLiteralArray
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   276
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   277
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   278
markFlag
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   279
    "return the mark bits value as a boolean"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   280
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   281
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   282
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   283
    /* made this a primitive to get define in stc.h */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   284
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   285
    RETURN ((__intVal(__INST(flags)) & F_MARKBIT) ? true : false);
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   286
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   287
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   288
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   289
markFlag:aBoolean
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   290
    "set/clear the mark flag bit.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   291
     This bit is not used by the VM, but instead free to mark codeObjects
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   292
     for any (debugging/tracing) use. For example, the coverage test uses
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   293
     these to mark reached methods. (inspired by a note in c.l.s)"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   294
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   295
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   296
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   297
    int newFlags = __intVal(__INST(flags));
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   298
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   299
    /* made this a primitive to get define in stc.h */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   300
    if (aBoolean == true)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   301
	newFlags |= F_MARKBIT;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   302
    else
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   303
	newFlags &= ~F_MARKBIT;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   304
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   305
    __INST(flags) = __MKSMALLINT(newFlags);
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   306
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   307
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   308
328
claus
parents: 326
diff changeset
   309
!CompiledCode methodsFor:'queries'!
claus
parents: 326
diff changeset
   310
1196
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   311
decompileTo:aStream
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   312
    Decompiler notNil ifTrue:[
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   313
        Autoload autoloadFailedSignal handle:[:ex |
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   314
            ex return
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   315
        ] do:[
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   316
            Decompiler autoload.
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   317
        ].
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   318
    ].
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   319
    (Decompiler isNil or:[Decompiler isLoaded not]) ifTrue:[
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   320
        ^ false
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   321
    ].
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   322
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   323
    Decompiler decompile:self to:aStream.
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   324
    ^ true
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   325
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   326
    "Created: 16.4.1996 / 20:25:40 / cg"
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   327
    "Modified: 16.4.1996 / 20:31:26 / cg"
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   328
!
7b3eeec128d3 moved decompilation into codeObject (allows handling of alien codeObjects)
Claus Gittinger <cg@exept.de>
parents: 1195
diff changeset
   329
1195
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   330
isExecutable
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   331
    "return true, if this method is executable.
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   332
     I.e. neither an invalidated nor an unloaded method"
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   333
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   334
    self isInvalid ifTrue:[^ false].
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   335
    ^ self byteCode notNil or:[self code notNil]
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   336
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   337
    "Created: 16.4.1996 / 17:52:16 / cg"
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   338
!
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   339
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   340
isUnloaded
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   341
    "return true, if the methods machine code has been unloaded
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   342
     from the system (i.e. it is not executable)."
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   343
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   344
    ^ (self code isNil and:[self byteCode isNil])
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   345
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   346
    "Created: 16.4.1996 / 17:51:47 / cg"
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   347
!
618e2cf3fb56 moved some protocol to upper levels; generalized queries
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
   348
328
claus
parents: 326
diff changeset
   349
messages
claus
parents: 326
diff changeset
   350
    "return a Set of all symbols referenced by this thingy.
claus
parents: 326
diff changeset
   351
     (this is more than the message selectors, since also global names
claus
parents: 326
diff changeset
   352
     and symbols found in immediate arrays are included)."
claus
parents: 326
diff changeset
   353
claus
parents: 326
diff changeset
   354
    |symbolSet|
claus
parents: 326
diff changeset
   355
claus
parents: 326
diff changeset
   356
    symbolSet := IdentitySet new.
claus
parents: 326
diff changeset
   357
    literals notNil ifTrue:[
claus
parents: 326
diff changeset
   358
	literals do: [ :lit |
370
claus
parents: 359
diff changeset
   359
	    lit isSymbol ifTrue: [
328
claus
parents: 326
diff changeset
   360
		symbolSet add: lit
claus
parents: 326
diff changeset
   361
	    ] ifFalse: [
370
claus
parents: 359
diff changeset
   362
		lit isArray ifTrue: [
328
claus
parents: 326
diff changeset
   363
		    lit traverse: [ :el |
370
claus
parents: 359
diff changeset
   364
			el isSymbol ifTrue: [symbolSet add: el]
328
claus
parents: 326
diff changeset
   365
		    ]
claus
parents: 326
diff changeset
   366
		]
claus
parents: 326
diff changeset
   367
	    ]
claus
parents: 326
diff changeset
   368
	]
claus
parents: 326
diff changeset
   369
    ].
claus
parents: 326
diff changeset
   370
    ^ symbolSet
claus
parents: 326
diff changeset
   371
claus
parents: 326
diff changeset
   372
    "
claus
parents: 326
diff changeset
   373
     (CompiledCode compiledMethodAt:#messages) messages 
claus
parents: 326
diff changeset
   374
    "
1190
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   375
!
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   376
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   377
referencesGlobal:aGlobalSymbol
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   378
    "return true, if this method references the global
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   379
     bound to aGlobalSymbol."
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   380
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   381
    |lits|
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   382
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   383
    (lits := self literals) isNil ifTrue:[^ false].
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   384
    ^ (lits identityIndexOf:aGlobalSymbol startingAt:1) ~~ 0
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   385
4ad1c8d6d94d moved & added some query methods (from method) to upper abstract classes
Claus Gittinger <cg@exept.de>
parents: 1182
diff changeset
   386
    "Created: 16.4.1996 / 16:36:32 / cg"
328
claus
parents: 326
diff changeset
   387
! !
claus
parents: 326
diff changeset
   388
1182
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   389
!CompiledCode class methodsFor:'documentation'!
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   390
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   391
version
1461
dd25bb1e9973 Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents: 1293
diff changeset
   392
    ^ '$Header: /cvs/stx/stx/libbasic/CompiledCode.st,v 1.30 1996-06-12 22:10:44 stefan Exp $'
1182
d8f8e18928a5 only CompiledCode, Method & Block are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   393
! !
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   394
CompiledCode initialize!