CompiledCode.st
author Claus Gittinger <cg@exept.de>
Wed, 03 Apr 1996 00:06:56 +0200
changeset 1133 961f2b095c22
parent 623 6795a71e39d1
child 1182 d8f8e18928a5
permissions -rw-r--r--
underline cleanup
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
249
claus
parents: 225
diff changeset
    13
ExecutableFunction subclass:#CompiledCode
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    14
	 instanceVariableNames:'flags byteCode literals'
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    15
	 classVariableNames:'NoByteCodeSignal InvalidByteCodeSignal InvalidInstructionSignal
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    16
                BadLiteralsSignal NonBooleanReceiverSignal ArgumentSignal'
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    17
	 poolDictionaries:''
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    18
	 category:'Kernel-Methods'
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    19
!
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    20
249
claus
parents: 225
diff changeset
    21
!CompiledCode class methodsFor:'documentation'!
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    22
88
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    23
copyright
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    24
"
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    25
 COPYRIGHT (c) 1994 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    26
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    27
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    28
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    29
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    31
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    32
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    33
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    34
"
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    35
!
81dacba7a63a *** empty log message ***
claus
parents: 84
diff changeset
    36
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    37
documentation
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    38
"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    39
    This is an abstract class, to merge common attributes of Blocks and
328
claus
parents: 326
diff changeset
    40
    Methods i.e. describe all objects consisting of either compiled or 
claus
parents: 326
diff changeset
    41
    interpreted code.
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    42
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    43
    Instance variables:
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    44
357
claus
parents: 345
diff changeset
    45
      flags       <SmallInteger>    special flag bits coded in a number
225
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    46
      byteCode    <ByteArray>       bytecode if its an interpreted codeobject
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    47
      literals    <Array>           the block/methods literal array
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    48
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    49
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    50
    Class variables:
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    51
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    52
      NoByteCodeSignal              raised if a codeObject is about to be executed
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    53
				    which has neither code nor byteCode (i.e. both are nil)
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    54
      InvalidByteCodeSignal         raised if byteCode is not an instance of ByteArray
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    55
      InvalidInstructionSignal      raised if an invalid instruction opcode is encountered
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    56
      BadLiteralsSignal             raised if literalArray is not an array
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    57
      NonBooleanReceiverSignal      raised for conditional jumps where receiver is not a boolean
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    58
      ArgumentSignal                raised if argument count is not what the codeObject expects
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    59
7c8e57cc5b13 commenting
claus
parents: 159
diff changeset
    60
    all of these signals are children of ExecutionErrorSignal.
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    61
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    62
    NOTICE: layout known by runtime system and compiler - do not change
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    63
"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    64
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    65
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
    66
version
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    67
    ^ '$Header: /cvs/stx/stx/libbasic/CompiledCode.st,v 1.22 1996-04-02 22:00:16 cg Exp $'
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    68
! !
1eba5946aea2 Initial revision
claus
parents:
diff changeset
    69
249
claus
parents: 225
diff changeset
    70
!CompiledCode class methodsFor:'initialization'!
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
    71
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
    72
initialize
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
    73
    NoByteCodeSignal isNil ifTrue:[
159
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    74
	NoByteCodeSignal := ExecutionErrorSignal newSignalMayProceed:true.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    75
	NoByteCodeSignal nameClass:self message:#noByteCodeSignal.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    76
	NoByteCodeSignal notifierString:'nil byteCode in code-object - not executable'.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    77
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    78
	InvalidByteCodeSignal := ExecutionErrorSignal newSignalMayProceed:true.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    79
	InvalidByteCodeSignal nameClass:self message:#invalidByteCodeSignal.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    80
	InvalidByteCodeSignal notifierString:'invalid byteCode in code-object - not executable'.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    81
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    82
	InvalidInstructionSignal := ExecutionErrorSignal newSignalMayProceed:true.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    83
	InvalidInstructionSignal nameClass:self message:#invalidInstructionSignal.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    84
	InvalidInstructionSignal notifierString:'invalid instruction in code-object - not executable'.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    85
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    86
	BadLiteralsSignal := ExecutionErrorSignal newSignalMayProceed:true.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    87
	BadLiteralsSignal nameClass:self message:#badLiteralsSignal.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    88
	BadLiteralsSignal notifierString:'bad literal table in code-object - should not happen'.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    89
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    90
	NonBooleanReceiverSignal := ExecutionErrorSignal newSignalMayProceed:true.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    91
	NonBooleanReceiverSignal nameClass:self message:#nonBooleanReceiverSignal.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    92
	NonBooleanReceiverSignal notifierString:'if/while on non-boolean receiver'.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    93
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    94
	ArgumentSignal := ExecutionErrorSignal newSignalMayProceed:true.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    95
	ArgumentSignal nameClass:self message:#argumentSignal.
514c749165c3 *** empty log message ***
claus
parents: 131
diff changeset
    96
	ArgumentSignal notifierString:'bad argument(s)'.
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
    97
    ]
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
    98
! !
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
    99
345
claus
parents: 328
diff changeset
   100
!CompiledCode class methodsFor:'Signal constants'!
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   101
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   102
argumentSignal
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   103
    "return the signal raised when something's wrong with the
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   104
     arguments"
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   105
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   106
    ^ ArgumentSignal
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   107
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   108
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   109
executionErrorSignal
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   110
    "return the parent-signal of all execution errors"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   111
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   112
    ^ ExecutionErrorSignal
106
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   113
! !
a5906085b3e5 errors now raise signals
claus
parents: 92
diff changeset
   114
249
claus
parents: 225
diff changeset
   115
!CompiledCode class methodsFor:'queries'!
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   116
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   117
isBuiltInClass
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   118
    "this class is known by the run-time-system"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   119
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   120
    ^ true
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   121
! !
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   122
249
claus
parents: 225
diff changeset
   123
!CompiledCode methodsFor:'accessing'!
84
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   124
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   125
byteCode
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   126
    "return the bytecode (a ByteArray)"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   127
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   128
    ^ byteCode
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   129
!
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   130
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   131
literals
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   132
    "return the literal array"
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   133
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   134
    ^ literals
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   135
! !
1eba5946aea2 Initial revision
claus
parents:
diff changeset
   136
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   137
!CompiledCode methodsFor:'error handling'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   138
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   139
badArgumentArray
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   140
    "this error is triggered, if a non array is passed to 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   141
     #valueWithReceiver:.. methods"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   142
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   143
    ^ ArgumentSignal
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   144
	raiseRequestWith:self
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   145
	errorString:'argumentArray must be an Array'
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   146
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   147
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   148
badLiteralTable
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   149
    "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
   150
     array (i.e. non-array) - this can only happen, if the
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   151
     compiler is broken or someone played around with a block/methods
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   152
     literal table or the GC is broken and corrupted it."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   153
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   154
    ^ BadLiteralsSignal raise.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   155
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   156
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   157
invalidByteCode
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   158
    "this error is triggered when the interpreter tries to execute a
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   159
     code object, where the byteCode is nonNil, but not a ByteArray.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   160
     Can only happen when Compiler/runtime system is broken or
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   161
     someone played around with a block/method."
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
    ^ InvalidByteCodeSignal raise.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   164
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   165
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   166
invalidInstruction
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   167
    "this error is triggered when the bytecode-interpreter tries to
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   168
     execute an invalid bytecode instruction.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   169
     Can only happen when Compiler/runtime system is broken or
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   170
     someone played around with the block/methods code."
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
    ^ InvalidInstructionSignal raise.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   173
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   174
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   175
noByteCode
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   176
    "this error is triggered when the interpreter tries to execute a
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   177
     code object, where both the code and byteCode instances are nil.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   178
     This can happen if:
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   179
	the Compiler/runtime system is broken,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   180
	someone played around with a block/method, 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   181
	compilation of a lazy method failed
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   182
	(i.e. the lazy method contains an error or
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   183
	 it contains primitive code and there is no stc compiler available)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   184
	an unloaded object modules method is called for.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   185
     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
   186
     if the system is used correctly."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   187
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   188
    ^ NoByteCodeSignal raise.
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
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   191
receiverNotBoolean:anObject
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   192
    "this error is triggered when the bytecode-interpreter tries to
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   193
     execute ifTrue:/ifFalse or whileTrue: type of expressions where the
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   194
     receiver is neither true nor false."
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
    ^ NonBooleanReceiverSignal 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
tooManyArguments
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   200
    "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
   201
     more arguments than supported by the interpreter. This can only happen,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   202
     if the compiler has been changed without updating the VM."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   203
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   204
    ^ ArgumentSignal
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   205
	raiseRequestWith:self
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   206
	errorString:'too many args in send'
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   207
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   208
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   209
!CompiledCode methodsFor:'private accessing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   210
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   211
byteCode:aByteArray
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   212
    "set the bytecode field - DANGER ALERT"
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
    byteCode := aByteArray
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   215
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   216
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   217
dynamic
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   218
    "return the flag stating that the machine code was created
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   219
     dynamically (from bytecode)."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   220
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   221
%{  /* NOCONTEXT */
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
    /* made this a primitive to get define in stc.h */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   224
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   225
    RETURN ((__intVal(__INST(flags)) & F_DYNAMIC) ? true : false);
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   226
%}
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
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   229
dynamic:aBoolean
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   230
    "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
   231
     dynamically and should be flushed on image-restart.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   232
     Obsolete - now done in VM"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   233
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   234
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   235
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   236
    int newFlags = __intVal(__INST(flags));
623
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
    /* made this a primitive to get define in stc.h */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   239
    if (aBoolean == true)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   240
	newFlags |= F_DYNAMIC;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   241
    else
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   242
	newFlags &= ~F_DYNAMIC;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   243
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   244
    __INST(flags) = __MKSMALLINT(newFlags);
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   245
%}
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
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   248
literals:aLiteralArray 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   249
    "set the literal array for evaluation - DANGER ALERT"
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
    literals := aLiteralArray
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
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   254
markFlag
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   255
    "return the mark bits value as a boolean"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   256
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   257
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   258
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   259
    /* made this a primitive to get define in stc.h */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   260
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   261
    RETURN ((__intVal(__INST(flags)) & F_MARKBIT) ? true : false);
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   262
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   263
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   264
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   265
markFlag:aBoolean
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   266
    "set/clear the mark flag bit.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   267
     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
   268
     for any (debugging/tracing) use. For example, the coverage test uses
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   269
     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
   270
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   271
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   272
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   273
    int newFlags = __intVal(__INST(flags));
623
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
    /* made this a primitive to get define in stc.h */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   276
    if (aBoolean == true)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   277
	newFlags |= F_MARKBIT;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   278
    else
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   279
	newFlags &= ~F_MARKBIT;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   280
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   281
    __INST(flags) = __MKSMALLINT(newFlags);
623
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
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   284
328
claus
parents: 326
diff changeset
   285
!CompiledCode methodsFor:'queries'!
claus
parents: 326
diff changeset
   286
claus
parents: 326
diff changeset
   287
messages
claus
parents: 326
diff changeset
   288
    "return a Set of all symbols referenced by this thingy.
claus
parents: 326
diff changeset
   289
     (this is more than the message selectors, since also global names
claus
parents: 326
diff changeset
   290
     and symbols found in immediate arrays are included)."
claus
parents: 326
diff changeset
   291
claus
parents: 326
diff changeset
   292
    |symbolSet|
claus
parents: 326
diff changeset
   293
claus
parents: 326
diff changeset
   294
    symbolSet := IdentitySet new.
claus
parents: 326
diff changeset
   295
    literals notNil ifTrue:[
claus
parents: 326
diff changeset
   296
	literals do: [ :lit |
370
claus
parents: 359
diff changeset
   297
	    lit isSymbol ifTrue: [
328
claus
parents: 326
diff changeset
   298
		symbolSet add: lit
claus
parents: 326
diff changeset
   299
	    ] ifFalse: [
370
claus
parents: 359
diff changeset
   300
		lit isArray ifTrue: [
328
claus
parents: 326
diff changeset
   301
		    lit traverse: [ :el |
370
claus
parents: 359
diff changeset
   302
			el isSymbol ifTrue: [symbolSet add: el]
328
claus
parents: 326
diff changeset
   303
		    ]
claus
parents: 326
diff changeset
   304
		]
claus
parents: 326
diff changeset
   305
	    ]
claus
parents: 326
diff changeset
   306
	]
claus
parents: 326
diff changeset
   307
    ].
claus
parents: 326
diff changeset
   308
    ^ symbolSet
claus
parents: 326
diff changeset
   309
claus
parents: 326
diff changeset
   310
    "
claus
parents: 326
diff changeset
   311
     (CompiledCode compiledMethodAt:#messages) messages 
claus
parents: 326
diff changeset
   312
    "
claus
parents: 326
diff changeset
   313
! !
claus
parents: 326
diff changeset
   314
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   315
CompiledCode initialize!