Method.st
author Claus Gittinger <cg@exept.de>
Thu, 07 Mar 1996 19:34:33 +0100
changeset 1087 6cb00ecfbc6d
parent 1037 4488f834cb6b
child 1093 1e742016eea0
permissions -rw-r--r--
nicer message
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
253
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
    13
CompiledCode subclass:#Method
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    14
	instanceVariableNames:'source sourcePosition category package'
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    15
	classVariableNames:'PrivateMethodSignal LastFileReference LastSourceFileName
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    16
		LastWhoClass'
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    17
	poolDictionaries:''
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    18
	category:'Kernel-Methods'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
42
e33491f6f260 *** empty log message ***
claus
parents: 39
diff changeset
    21
!Method class methodsFor:'documentation'!
e33491f6f260 *** empty log message ***
claus
parents: 39
diff changeset
    22
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    23
copyright
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    24
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    25
 COPYRIGHT (c) 1989 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
    26
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    27
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    28
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    29
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    31
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    32
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    33
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    34
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    35
!
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    36
42
e33491f6f260 *** empty log message ***
claus
parents: 39
diff changeset
    37
documentation
e33491f6f260 *** empty log message ***
claus
parents: 39
diff changeset
    38
"
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    39
    this class defines protocol for executable methods;
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    40
    both compiled and interpreted methods are represented by this class.
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    41
    Compiled methods have a non-nil code field, while interpreted methods have
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    42
    a nil code field and non-nil byteCode field.
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    43
    If there are both non-nil code and bytecode fields, the VM will execute
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    44
    the machine-code of a method. If both are nil when executed, a noByteCode
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    45
    message is sent by the VM to the method where a signal is raised.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    46
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    47
    The methods sourcecode is represented by source and sourcePosition:
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    48
    - if sourcePosition is a Number, the source-field is the fileName and
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    49
      sourcePosition is the character offset of the source-chunk in this source file.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    50
    - If sourcePosition is nil, the source is the string in the source field.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    51
    (an old version used ExternalString instances here, but that lead to
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    52
     10000 additional little objects ...)
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    53
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    54
    The flags field defines things like the number of method-locals,
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    55
    method arguments and stack requirements (for interpreted methods).
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    56
    Do not depend on any value in the flags field - it may change without
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    57
    notice.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    58
438
claus
parents: 423
diff changeset
    59
    Notice, that in ST/X, method can be subclassed; executable code is
claus
parents: 423
diff changeset
    60
    identified not by being a subclass of Block or Method, but instead by
claus
parents: 423
diff changeset
    61
    having the executable flag bit set in the class. The VM can execute anything
claus
parents: 423
diff changeset
    62
    which is identified as executable (assuming that the first instance variable
claus
parents: 423
diff changeset
    63
    is the machine-code address) - this allows for easy future extension.
claus
parents: 423
diff changeset
    64
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    65
    Instance variables:
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    66
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
    67
	source          <String>        the source itself (if sourcePosition isNil)
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
    68
					or the fileName where the source is found
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    69
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
    70
	sourcePosition  <Integer>       the position of the methods chunk in the file
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    71
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
    72
	category        <Symbol>        the methods category
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
    73
	package         <Symbol>        the package, in which the methods was defined
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    74
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    75
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    76
    Class variables:
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    77
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    78
	PrivateMethodSignal             raised on privacy violation (see docu)
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    79
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    80
	LastFileReference               weak reference to the last sourceFile
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    81
	LastSourceFileName              to speedup source access via NFS
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    82
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    83
    WARNING: layout known by compiler and runtime system - dont change
42
e33491f6f260 *** empty log message ***
claus
parents: 39
diff changeset
    84
"
176
48061f8659aa more queries
claus
parents: 159
diff changeset
    85
!
48061f8659aa more queries
claus
parents: 159
diff changeset
    86
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    87
dynamicMethods
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    88
"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    89
    On systems which support dynamic loading of machine code (SYS5.4, Linux),
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    90
    methods may now be compiled to machine code from within the browser,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    91
    and the resulting machine code object be loaded in.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    92
    The ObjectFileLoader keeps (weak) handles to the resulting methods and
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    93
    invalidates the corresponding method objects, if the underlying methods
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    94
    object code is unloaded.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    95
    Invalid methods will trap into the debugger when executed;
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    96
    also, the browser marks them as '(* not executable *)' in its method list.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    97
"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    98
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
    99
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   100
privacy 
48061f8659aa more queries
claus
parents: 159
diff changeset
   101
"
48061f8659aa more queries
claus
parents: 159
diff changeset
   102
    ST/X includes an EXPERIMENTAL implementation of method privacy.
48061f8659aa more queries
claus
parents: 159
diff changeset
   103
    Individual methods may be set to private or protected via the
48061f8659aa more queries
claus
parents: 159
diff changeset
   104
    #setPrivate and #setProtected messages. Also, categories may be
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
   105
    filedIn as a whole as private using #privateMethodsFor: or as
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
   106
    protected using #protectedMethodsFor: instead of the well known #methodsFor:.
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
   107
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   108
    The additional #publicMethodsFor: is for documentation purposes, and
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
   109
    is equivalent to #methodsFor: (also to support fileIn of ENVY methods).
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   110
48061f8659aa more queries
claus
parents: 159
diff changeset
   111
    Private methods may be executed only when called via a self or super-send
48061f8659aa more queries
claus
parents: 159
diff changeset
   112
    from the superclass, the class itself or subclasses.
415
claus
parents: 414
diff changeset
   113
    Protected methods may not be called from subclasses, i.e. they may only
claus
parents: 414
diff changeset
   114
    be called via self sends from within the current class.
claus
parents: 414
diff changeset
   115
    (i.e. private methods are less private than protected ones)
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   116
48061f8659aa more queries
claus
parents: 159
diff changeset
   117
    When such a situation arises, the VM (runtime system) will raise the
48061f8659aa more queries
claus
parents: 159
diff changeset
   118
    PrivateMethodSignal exception (if nonNil), which usually brings you into the
48061f8659aa more queries
claus
parents: 159
diff changeset
   119
    debugger.
48061f8659aa more queries
claus
parents: 159
diff changeset
   120
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
   121
    If PrivateMethodSignal is nil, the VM will not check for this, and
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   122
    execution is as usual. (you may want to nil-it for production code,
48061f8659aa more queries
claus
parents: 159
diff changeset
   123
    and leave it non nil during development).
48061f8659aa more queries
claus
parents: 159
diff changeset
   124
48061f8659aa more queries
claus
parents: 159
diff changeset
   125
    NOTICE: there is no (not yet ?) standard defined for method privacy,
48061f8659aa more queries
claus
parents: 159
diff changeset
   126
    however, the interface was designed to be somewhat ENVY compatible (from
48061f8659aa more queries
claus
parents: 159
diff changeset
   127
    what can be deduced by reading PD code).
48061f8659aa more queries
claus
parents: 159
diff changeset
   128
    Also, the usability of privacy is still to be tested.
415
claus
parents: 414
diff changeset
   129
    This interface, the implementation and the rules for when a privacy violation
claus
parents: 414
diff changeset
   130
    may change (in case of some ANSI standard being defined).
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
   131
    Be warned and send me suggestions & critics (constructive ;-)
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   132
"
42
e33491f6f260 *** empty log message ***
claus
parents: 39
diff changeset
   133
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   134
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   135
!Method class methodsFor:'initialization'!
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   136
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   137
initialize
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   138
    PrivateMethodSignal isNil ifTrue:[
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   139
	"EXPERIMENTAL"
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   140
	PrivateMethodSignal := ExecutionErrorSignal newSignalMayProceed:true.
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   141
	PrivateMethodSignal nameClass:self message:#privateMethodSignal.
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   142
	PrivateMethodSignal notifierString:'attempt to execute private/protected method'.
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   143
    ]
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   144
! !
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   145
345
claus
parents: 343
diff changeset
   146
!Method class methodsFor:'Signal constants'!
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   147
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   148
privateMethodSignal
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   149
    "return the signal raised when a private/protected method is called
48061f8659aa more queries
claus
parents: 159
diff changeset
   150
     by some other object (i.e. not a self- or super send)"
48061f8659aa more queries
claus
parents: 159
diff changeset
   151
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   152
    ^ PrivateMethodSignal
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   153
! !
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   154
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   155
!Method class methodsFor:'binary storage'!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   156
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   157
binaryDefinitionFrom: stream manager: manager
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   158
    "read my definition from stream."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   159
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   160
    |cls sel|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   161
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   162
    "type-byte"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   163
    stream nextByte == 0 ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   164
	"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   165
	 built-in method
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   166
	"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   167
	cls := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   168
	sel := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   169
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   170
	"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   171
	 mhmh - on the source system, this was a machinecode
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   172
	 method, while here its an interpreted one ...
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   173
	"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   174
	cls isLoaded ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   175
	    cls autoload
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   176
	].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   177
	^ cls compiledMethodAt:sel
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   178
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   179
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   180
     bytecode method
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   181
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   182
    ^ super binaryDefinitionFrom:stream manager:manager
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   183
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   184
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   185
binaryFullDefinitionFrom:stream manager:manager
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   186
    "retrieve a full bytecoded-method."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   187
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   188
    |snapId cat flags code lits m sourceFilename sourcePos source|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   189
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   190
    snapId := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   191
    cat := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   192
    flags := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   193
    lits := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   194
    sourceFilename := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   195
    sourcePos := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   196
    sourcePos isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   197
	source := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   198
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   199
    code := manager nextObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   200
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   201
    snapId == ObjectMemory snapshotID ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   202
	ObjectMemory incrementSnapshotID
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   203
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   204
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   205
    m := Method basicNew.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   206
    cat notNil ifTrue:[m category:cat].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   207
    m flags:flags.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   208
    m literals:lits.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   209
    m byteCode:code.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   210
    sourcePos isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   211
	m source:source
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   212
    ] ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   213
	m sourceFilename:sourceFilename position:sourcePos
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   214
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   215
    ^ m
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   216
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   217
    "Created: 16.1.1996 / 14:44:08 / cg"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   218
! !
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   219
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   220
!Method class methodsFor:'queries'!
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   221
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   222
isBuiltInClass
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   223
    "this class is known by the run-time-system"
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   224
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   225
    ^ self == Method
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   226
!
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   227
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   228
maxNumberOfArguments
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   229
    "this limit will be removed in one of the next versions ..."
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   230
423
claus
parents: 421
diff changeset
   231
    ^ 15  "cannot be easily changed; should ask the VM about this number"
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   232
!
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   233
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   234
methodPrivacySupported
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   235
    "return true, if the system was compiled to support methodPrivacy.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   236
     You should not depend on that feature being available."
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   237
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   238
%{  /* NOCONTEXT */
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   239
#if defined(F_PRIVATE) || defined(F_CLASSPRIVATE)
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   240
    RETURN (true);
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   241
#else
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   242
    RETURN (false);
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   243
#endif
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   244
%}
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   245
! !
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   246
957
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   247
!Method class methodsFor:'special'!
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   248
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   249
flushSourceStreamCache
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   250
    LastSourceFileName := nil
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   251
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   252
    "Created: 9.2.1996 / 19:05:28 / cg"
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   253
! !
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   254
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   255
!Method methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   256
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   257
category
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   258
    "return the methods category or nil"
737
4ed893ad3f0f try more to find source of obsolete methods
Claus Gittinger <cg@exept.de>
parents: 690
diff changeset
   259
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   260
    ^ category
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   261
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   262
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   263
category:aStringOrSymbol
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   264
    "set the methods category"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   265
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   266
    category := aStringOrSymbol asSymbol
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   267
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   268
39
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   269
comment
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   270
    "return the methods comment.
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   271
     This is done by searching for and returning the first comment
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   272
     from the methods source (excluding any double-quotes). 
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   273
     Returns nil if there is no comment (or source is not available)."
39
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   274
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   275
    |src stream|
39
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   276
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   277
    src := self source.
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   278
    src isNil ifTrue:[^ nil].
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   279
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   280
    stream := ReadStream on:src.
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   281
    (stream skipThrough:Character doubleQuote) isNil ifTrue:[^ nil].
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   282
    ^ stream upTo:Character doubleQuote.
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   283
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   284
    "
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   285
     (Method compiledMethodAt:#comment) comment 
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   286
    "
39
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   287
!
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   288
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   289
flags
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   290
    "return the flags (number of method variables, stacksize etc.).
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   291
     Dont depend on the values in the flag field - it may change
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   292
     without notice."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   293
a27a279701f8 Initial revision
claus
parents:
diff changeset
   294
    ^ flags
a27a279701f8 Initial revision
claus
parents:
diff changeset
   295
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   296
a27a279701f8 Initial revision
claus
parents:
diff changeset
   297
flags:newFlags
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   298
    "set the flags (number of method variables, stacksize).
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   299
     WARNING: for internal use by the compiler only."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   300
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   301
    "protect myself a bit - putting in an object would crash me ..."
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   302
    (newFlags isMemberOf:SmallInteger) ifTrue:[
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   303
	flags := newFlags
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   304
    ]
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   305
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   306
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   307
getSource
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   308
    ^ source
414
claus
parents: 400
diff changeset
   309
!
claus
parents: 400
diff changeset
   310
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   311
isIgnored
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   312
    "return true, if this is an ignored method.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   313
     Ignored methods are physically present in the source file,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   314
     but no code is generated for it by stc, and the VM does not see
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   315
     it in its message lookup.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   316
     (i.e. setting a method to #ignored, and sending that selector,
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   317
      leads to either the superclasses implementation to be called, 
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   318
      or a doesNotUnderstand exception to be raised)
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   319
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   320
     Notice: this is a nonstandard feature, not supported
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   321
     by other smalltalk implementations and not specified in the ANSI spec.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   322
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   323
     This is EXPERIMENTAL - and being evaluated for usability.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   324
     It may change or even vanish (if it shows to be not useful)."
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   325
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   326
%{  /* NOCONTEXT */
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   327
#if defined(F_IGNORED) && defined(M_PRIVACY)
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   328
    int f = _intVal(_INST(flags));
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   329
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   330
    if ((f & M_PRIVACY) == F_IGNORED) {
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   331
	RETURN (true);
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   332
    }
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   333
#endif
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   334
%}.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   335
    ^ false
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   336
!
48061f8659aa more queries
claus
parents: 159
diff changeset
   337
48061f8659aa more queries
claus
parents: 159
diff changeset
   338
isPrivate
48061f8659aa more queries
claus
parents: 159
diff changeset
   339
    "return true, if this is a private method.
48061f8659aa more queries
claus
parents: 159
diff changeset
   340
     Execution of private methods is only allowed via self/super sends
48061f8659aa more queries
claus
parents: 159
diff changeset
   341
     from superclasses, the class itself or subclasses.
48061f8659aa more queries
claus
parents: 159
diff changeset
   342
     If a private method is called by some other class, a runtime
48061f8659aa more queries
claus
parents: 159
diff changeset
   343
     error (PrivateMethodSignal) is raised.
48061f8659aa more queries
claus
parents: 159
diff changeset
   344
     Notice: method privacy is a nonstandard feature, not supported
48061f8659aa more queries
claus
parents: 159
diff changeset
   345
     by other smalltalk implementations and not specified in the ANSI spec.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   346
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   347
     This is EXPERIMENTAL - and being evaluated for usability.
48061f8659aa more queries
claus
parents: 159
diff changeset
   348
     It may change or even vanish (if it shows to be not useful)."
48061f8659aa more queries
claus
parents: 159
diff changeset
   349
48061f8659aa more queries
claus
parents: 159
diff changeset
   350
%{  /* NOCONTEXT */
48061f8659aa more queries
claus
parents: 159
diff changeset
   351
    /* I made this a primitive to get the define constant from stc.h */
48061f8659aa more queries
claus
parents: 159
diff changeset
   352
748
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   353
#if defined(F_PRIVATE) && defined(M_PRIVACY)
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   354
    int f = _intVal(_INST(flags));
48061f8659aa more queries
claus
parents: 159
diff changeset
   355
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   356
    if ((f & M_PRIVACY) == F_PRIVATE) {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   357
	RETURN (true);
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   358
    }
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   359
#endif
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   360
%}.
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   361
    ^ false
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   362
!
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   363
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   364
isProtected
48061f8659aa more queries
claus
parents: 159
diff changeset
   365
    "return true, if this is a protected method.
48061f8659aa more queries
claus
parents: 159
diff changeset
   366
     Execution of protected methods is only allowed via self sends
48061f8659aa more queries
claus
parents: 159
diff changeset
   367
     from superclasses or the class itself.
48061f8659aa more queries
claus
parents: 159
diff changeset
   368
     If a protected method is called by some other class, a runtime
48061f8659aa more queries
claus
parents: 159
diff changeset
   369
     error (PrivateMethodSignal) is raised.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   370
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   371
     Notice: method privacy is a nonstandard feature, not supported
48061f8659aa more queries
claus
parents: 159
diff changeset
   372
     by other smalltalk implementations and not specified in the ANSI spec.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   373
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   374
     This is EXPERIMENTAL - and being evaluated for usability.
48061f8659aa more queries
claus
parents: 159
diff changeset
   375
     It may change or even vanish (if it shows to be not useful)."
48061f8659aa more queries
claus
parents: 159
diff changeset
   376
48061f8659aa more queries
claus
parents: 159
diff changeset
   377
%{  /* NOCONTEXT */
48061f8659aa more queries
claus
parents: 159
diff changeset
   378
    /* I made this a primitive to get the define constant from stc.h */
48061f8659aa more queries
claus
parents: 159
diff changeset
   379
748
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   380
#if defined(F_CLASSPRIVATE) && defined(M_PRIVACY)
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   381
    int f = _intVal(_INST(flags));
48061f8659aa more queries
claus
parents: 159
diff changeset
   382
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   383
    if ((f & M_PRIVACY) == F_CLASSPRIVATE) {
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   384
	RETURN (true);
48061f8659aa more queries
claus
parents: 159
diff changeset
   385
    }
48061f8659aa more queries
claus
parents: 159
diff changeset
   386
#endif
48061f8659aa more queries
claus
parents: 159
diff changeset
   387
%}.
48061f8659aa more queries
claus
parents: 159
diff changeset
   388
    ^ false
48061f8659aa more queries
claus
parents: 159
diff changeset
   389
!
48061f8659aa more queries
claus
parents: 159
diff changeset
   390
48061f8659aa more queries
claus
parents: 159
diff changeset
   391
isPublic
48061f8659aa more queries
claus
parents: 159
diff changeset
   392
    "return true, if this is a public method - I.e. can be executed via any send.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   393
     This is the default and how other smalltalk implementations treat all methods.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   394
360
claus
parents: 350
diff changeset
   395
     Notice: method privacy is a nonstandard feature, not supported
claus
parents: 350
diff changeset
   396
     by other smalltalk implementations and not specified in the ANSI spec.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   397
360
claus
parents: 350
diff changeset
   398
     This is EXPERIMENTAL - and being evaluated for usability.
claus
parents: 350
diff changeset
   399
     It may change or even vanish (if it shows to be not useful)."
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   400
48061f8659aa more queries
claus
parents: 159
diff changeset
   401
%{  /* NOCONTEXT */
48061f8659aa more queries
claus
parents: 159
diff changeset
   402
    /* I made this a primitive to get the define constant from stc.h */
48061f8659aa more queries
claus
parents: 159
diff changeset
   403
748
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   404
#if defined(M_PRIVACY) && (defined(F_PRIVATE) || defined(F_CLASSPRIVATE) || defined(F_IGNORED))
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   405
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   406
    int f = _intVal(_INST(flags));
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   407
# ifdef F_PRIVATE
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   408
    if ((f & M_PRIVACY) == F_PRIVATE) {
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   409
	RETURN (false);
48061f8659aa more queries
claus
parents: 159
diff changeset
   410
    }
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   411
# endif
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   412
# ifdef F_CLASSPRIVATE
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   413
    if ((f & M_PRIVACY) == F_CLASSPRIVATE) {
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   414
	RETURN (false);
48061f8659aa more queries
claus
parents: 159
diff changeset
   415
    }
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   416
# endif
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   417
# ifdef F_IGNORED
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   418
    if ((f & M_PRIVACY) == F_IGNORED) {
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   419
	RETURN (false);
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   420
    }
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   421
# endif
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   422
#endif
48061f8659aa more queries
claus
parents: 159
diff changeset
   423
%}.
48061f8659aa more queries
claus
parents: 159
diff changeset
   424
    ^ true
48061f8659aa more queries
claus
parents: 159
diff changeset
   425
!
48061f8659aa more queries
claus
parents: 159
diff changeset
   426
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   427
isRestricted
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   428
    "return the flag bit stating that this method is restricted.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   429
     Execution of the receiver will only be allowed if the system is not in
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   430
     'trap restricted mode' (-->ObjectMemory) otherise a runtime 
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   431
     error (PrivateMethodSignal) is raised.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   432
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   433
     Notice: method restriction is a nonstandard feature, not supported
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   434
     by other smalltalk implementations and not specified in the ANSI spec.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   435
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   436
     This is EXPERIMENTAL - and being evaluated for usability.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   437
     It may change or even vanish (if it shows to be not useful)."
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   438
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   439
%{  /* NOCONTEXT */
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   440
#ifdef F_RESTRICTED
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   441
    int f = _intVal(_INST(flags));
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   442
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   443
    if (f & F_RESTRICTED) {
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   444
	RETURN (true);
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   445
    }
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   446
#endif
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   447
%}.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   448
    ^ false
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   449
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   450
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   451
numberOfMethodArgs
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   452
    "return the number of arguments, the method expects." 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   453
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   454
%{  /* NOCONTEXT */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   455
    /* made this a primitive to get define in stc.h */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   456
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   457
#ifdef F_NARGS
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   458
    RETURN (_MKSMALLINT((_intVal(_INST(flags)) & F_NARGS) >> F_NARGSHIFT));
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   459
#endif
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   460
%}
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   461
.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   462
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   463
     The old implementation simply counted the arguments from
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   464
     the methods source - new versions include this information
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   465
     in the flag instVar, for more security in #perform:
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   466
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   467
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   468
    ^ self methodArgNames size
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   469
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   470
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   471
numberOfMethodArgs:aNumber
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   472
    "currently, the number of arguments is NOT remembered in
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   473
     methods, but this will be added soon to allow for more checking
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   474
     in #perform:.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   475
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   476
     The limitation in the max. number of arguments is due to the
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   477
     missing SENDxx functions in the VM and cases in #perform. This too 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   478
     will be removed in a later release, allowing any number of arguments.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   479
     - for use by compiler only."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   480
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   481
    (aNumber between:0 and:self class maxNumberOfArguments) ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   482
	self error:('ST/X only supports up to a maximum of ' ,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   483
		    self class maxNumberOfArguments printString ,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   484
		    ' method arguments').
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   485
	^ self
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   486
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   487
%{
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   488
    /* made this a primitive to get define in stc.h */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   489
#ifdef F_NARGS
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   490
    _INST(flags) = _MKSMALLINT( (_intVal(_INST(flags)) & ~F_NARGS) | (_intVal(aNumber) << F_NARGSHIFT) );
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   491
#endif
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   492
%}
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   493
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   494
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   495
numberOfMethodVars
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   496
    "return the number of method local variables. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   497
     Do not depend on the returned value - future optimizations
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   498
     may change things here (i.e. when moving block-locals into
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   499
     surrounding method for inlining).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   500
     - for debugging only."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   501
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   502
%{  /* NOCONTEXT */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   503
    /* made this a primitive to get define in stc.h */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   504
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   505
    RETURN (_MKSMALLINT((_intVal(_INST(flags)) & F_NVARS) >> F_NVARSHIFT));
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   506
%}
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   507
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   508
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   509
numberOfMethodVars:aNumber
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   510
    "set the number of method variables - for use by compiler only.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   511
     WARNING: playing around here with incorrect values 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   512
	      may crash smalltalk badly."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   513
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   514
%{  /* NOCONTEXT */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   515
    int f = _intVal(_INST(flags));
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   516
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   517
    /* made this a primitive to get define in stc.h */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   518
    if (__isSmallInteger(aNumber)) {
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   519
	f = (f & ~F_NVARS) | (_intVal(aNumber) << F_NVARSHIFT);
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   520
	_INST(flags) = _MKSMALLINT(f);
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   521
    }
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   522
%}
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   523
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   524
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   525
package
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   526
    "return the package-symbol"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   527
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   528
    ^ package
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   529
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   530
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   531
package:aSymbol
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   532
    "set the package-symbol"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   533
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   534
    package := aSymbol
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   535
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   536
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   537
privacy
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   538
    "return a symbol describing the methods access rights (privacy);
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   539
     Currently, this is one of #private, #protected, #public or #ignored.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   540
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   541
     Notice: method privacy is a nonstandard feature, not supported
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   542
     by other smalltalk implementations and not specified in the ANSI spec.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   543
     If at all, use it for debugging purposes, to catch messagesends
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   544
     which are not supposed to be sent by others.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   545
     (especially, if working in a team, while integrating other peoples work)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   546
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   547
     This is EXPERIMENTAL - and being evaluated for usability.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   548
     It may change or even vanish (if it shows to be not useful)."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   549
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   550
    self isPrivate ifTrue:[^ #private].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   551
    self isProtected ifTrue:[^ #protected].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   552
    self isIgnored ifTrue:[^ #ignored].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   553
    ^ #public
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   554
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   555
    "Modified: 27.8.1995 / 22:53:31 / claus"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   556
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   557
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   558
privacy:aSymbol
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   559
    "set the methods access rights (privacy) from a symbol;
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   560
     Currently, this must be one of #private, #protected, #public or #ignored.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   561
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   562
     Notice: method privacy is a nonstandard feature, not supported
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   563
     by other smalltalk implementations and not specified in the ANSI spec.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   564
     If at all, use it for debugging purposes, to catch messagesends
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   565
     which are not supposed to be sent by others.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   566
     (especially, if working in a team, while integrating other peoples work)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   567
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   568
     This is EXPERIMENTAL - and being evaluated for usability.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   569
     It may change or even vanish (if it shows to be not useful)."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   570
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   571
    aSymbol == #public ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   572
	"/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   573
	"/ no need to flush, if changing from private to public
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   574
	"/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   575
	self isIgnored ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   576
	    ^ self setToPublic
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   577
	].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   578
	self setToPublic
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   579
    ] ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   580
	aSymbol == #private ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   581
	    self setToPrivate
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   582
	] ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   583
	    aSymbol == #protected ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   584
		self setToProtected
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   585
	    ] ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   586
		aSymbol == #ignored ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   587
		    self setToIgnored
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   588
		]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   589
	    ]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   590
	]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   591
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   592
    ObjectMemory flushCaches.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   593
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   594
    "Modified: 27.8.1995 / 22:58:08 / claus"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   595
!
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   596
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   597
restricted:aBoolean
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   598
    "set or clear the flag bit stating that this method is restricted. 
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   599
     Execution of the receiver will only be allowed if the system is not in
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   600
     'trap restricted mode' (-->ObjectMemory) otherise a runtime
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   601
     error (PrivateMethodSignal) is raised.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   602
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   603
     Notice: method restriction is a nonstandard feature, not supported
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   604
     by other smalltalk implementations and not specified in the ANSI spec.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   605
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   606
     This is EXPERIMENTAL - and being evaluated for usability.
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   607
     It may change or even vanish (if it shows to be not useful)."
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   608
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   609
%{  /* NOCONTEXT */
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   610
    /* I made this a primitive to get the define constant from stc.h */
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   611
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   612
#ifdef F_RESTRICTED
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   613
    int f = _intVal(_INST(flags));
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   614
    int old;
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   615
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   616
    old = f;
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   617
    if (aBoolean == true) 
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   618
	f |= F_RESTRICTED;
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   619
    else
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   620
	f &= ~F_RESTRICTED;
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   621
    _INST(flags) = _MKSMALLINT(f);
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   622
    if (old & F_RESTRICTED)
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   623
	RETURN(true);
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   624
#endif
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   625
%}.
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   626
    ^ false
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   627
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   628
    "
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   629
     (ObjectMemory class compiledMethodAt:#compressingGarbageCollect) restricted:true
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   630
    "
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   631
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   632
    "Created: 7.11.1995 / 20:36:19 / stefan"
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   633
!
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   634
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   635
setToIgnored
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   636
    "make this method be ignored w.r.t. method lookup.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   637
     (i.e. setting a method to #ignored, and sending that selector,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   638
      leads to either the superclasses implementation to be called, 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   639
      or a doesNotUnderstand exception to be raised)
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   640
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   641
     Notice: ignored methods are a nonstandard feature, not supported
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   642
     by other smalltalk implementations and not specified in the ANSI spec.
49
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   643
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   644
     This is EXPERIMENTAL - and being evaluated for usability.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   645
     It may change or even vanish (if it shows to be not useful)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   646
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   647
%{  /* NOCONTEXT */
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   648
    int f = _intVal(_INST(flags));
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   649
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   650
#if defined(F_IGNORED) && defined(M_PRIVACY)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   651
    f = (f & ~M_PRIVACY) | F_IGNORED;
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   652
#endif
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   653
    _INST(flags) = _MKSMALLINT(f);
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   654
%}
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   655
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   656
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   657
setToPrivate
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   658
    "set the flag bit stating that this method is private. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   659
     Execution of the receiver will only be allowed for self/super-sends from 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   660
     the class, superclasses or subclasses (or via #perform).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   661
     If a private method is called by some other class, a runtime
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   662
     error (PrivateMethodSignal) is raised.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   663
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   664
     Notice: method privacy is a nonstandard feature, not supported
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   665
     by other smalltalk implementations and not specified in the ANSI spec.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   666
     If at all, use it for debugging purposes, to catch messagesends
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   667
     which are not supposed to be sent by others.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   668
     (especially, if working in a team, while integrating other peoples work)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   669
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   670
     This is EXPERIMENTAL - and being evaluated for usability.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   671
     It may change or even vanish (if it shows to be not useful)."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   672
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   673
%{  /* NOCONTEXT */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   674
    /* I made this a primitive to get the define constant from stc.h */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   675
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   676
#if defined(F_PRIVATE) && defined(M_PRIVACY)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   677
    int f = _intVal(_INST(flags));
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   678
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   679
    f = (f & ~M_PRIVACY) | F_PRIVATE;
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   680
    _INST(flags) = _MKSMALLINT(f);
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   681
#endif
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   682
%}
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   683
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   684
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   685
setToProtected
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   686
    "set the flag bit stating that this method is protected. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   687
     Execution of the receiver will only be allowed for self sends from
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   688
     the class or superclasses. (or via #perform).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   689
     If a private method is called by some other class, a runtime
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   690
     error (PrivateMethodSignal) is raised.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   691
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   692
     Notice: method privacy is a nonstandard feature, not supported
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   693
     by other smalltalk implementations and not specified in the ANSI spec.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   694
     If at all, use it for debugging purposes, to catch messagesends
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   695
     which are not supposed to be sent by others.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   696
     (especially, if working in a team, while integrating other peoples work)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   697
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   698
     This is EXPERIMENTAL - and being evaluated for usability.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   699
     It may change or even vanish (if it shows to be not useful)."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   700
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   701
%{  /* NOCONTEXT */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   702
    /* I made this a primitive to get the define constant from stc.h */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   703
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   704
#if defined(F_CLASSPRIVATE) && defined(M_PRIVACY)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   705
    int f = _intVal(_INST(flags));
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   706
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   707
    f = (f & ~M_PRIVACY) | F_CLASSPRIVATE;
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   708
    _INST(flags) = _MKSMALLINT(f);
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   709
#endif
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   710
%}
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   711
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   712
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   713
setToPublic
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   714
    "clear any privacy/ignoreFlag of the receiver. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   715
     The receiver may be executed by any send. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   716
     This is the default anyway for methods, and how other smalltalk
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   717
     implementations treat all methods.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   718
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   719
     Notice: method privacy is a nonstandard feature, not supported
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   720
     by other smalltalk implementations and not specified in the ANSI spec.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   721
     If at all, use it for debugging purposes, to catch messagesends
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   722
     which are not supposed to be sent by others.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   723
     (especially, if working in a team, while integrating other peoples work)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   724
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   725
     This is EXPERIMENTAL - and being evaluated for usability.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   726
     It may change or even vanish (if it shows to be not useful)."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   727
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   728
%{  /* NOCONTEXT */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   729
    /* I made this a primitive to get the define constant from stc.h */
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   730
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   731
#ifdef M_PRIVACY
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   732
    int f = _intVal(_INST(flags));
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   733
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   734
    f = f & ~M_PRIVACY;
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   735
    _INST(flags) = _MKSMALLINT(f);
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   736
#endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   737
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   738
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   739
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   740
source
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   741
    "return the sourcestring for the receiver"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   742
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   743
    |aStream fileName junk w myClass mgr className|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   744
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   745
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   746
     if sourcePosition is nonNil, its the fileName and
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   747
     sourcePosition is the offset.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   748
     Otherwise, source is the real source
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   749
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   750
    sourcePosition isNil ifTrue:[^ source].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   751
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   752
    source notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   753
"/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   754
"/ original (old) code:
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   755
"/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   756
"/        aStream := Smalltalk systemFileStreamFor:('source/' , source).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   757
"/        aStream notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   758
"/            aStream position:sourcePosition.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   759
"/            junk := aStream nextChunk.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   760
"/            aStream close
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   761
"/        ]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   762
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   763
        "/ keep the last source file open, because open/close
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   764
        "/ operations maybe slow on NFS-mounted file systems.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   765
        "/ Since the reference to the file is weak, it will be closed
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   766
        "/ automatically if the file is not referenced for a while. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   767
        "/ Neat trick.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   768
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   769
        LastSourceFileName = source ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   770
            aStream := LastFileReference at:1.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   771
        ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   772
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   773
        aStream isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   774
            "/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   775
            "/ if there is no SourceManager, look in standard places
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   776
            "/ first
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   777
            "/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   778
            (mgr := Smalltalk at:#SourceCodeManager) isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   779
                fileName := Smalltalk getSourceFileName:source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   780
                fileName notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   781
                    aStream := fileName asFilename readStream.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   782
                ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   783
            ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   784
            aStream isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   785
                "/
957
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   786
                "/ nope - ask my class for the source (this also invokes the SCMgr)
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   787
                "/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   788
                w := self who.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   789
                w notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   790
                    myClass := w at:1.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   791
                    aStream := myClass sourceStreamFor:source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   792
                ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   793
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   794
                aStream isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   795
                    "/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   796
                    "/ nope - look in standard places 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   797
                    "/ (if there is a source-code manager - otherwise, we already did that)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   798
                    "/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   799
                    mgr notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   800
                        fileName := Smalltalk getSourceFileName:source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   801
                        fileName notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   802
                            aStream := fileName asFilename readStream.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   803
                        ]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   804
                    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   805
                    "/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   806
                    "/ final chance: try current directory
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   807
                    "/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   808
                    aStream isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   809
                        aStream := source asFilename readStream.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   810
                    ]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   811
                ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   812
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   813
                (aStream isNil and:[w isNil and:[source notNil]]) ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   814
                    "/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   815
                    "/ mhmh - seems to be a method which used to be in some
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   816
                    "/ class, but has been overwritten by another or removed.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   817
                    "/ (i.e. it has no containing class anyMore)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   818
                    "/ try to guess the class from the sourceFileName.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   819
                    "/ and retry.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   820
                    "/
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   821
                    className := Smalltalk classNameForFile:source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   822
                    className knownAsSymbol ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   823
                        myClass := Smalltalk at:className asSymbol ifAbsent:nil.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   824
                        myClass notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   825
                            aStream := myClass sourceStreamFor:source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   826
                        ]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   827
                    ]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   828
                ]                
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   829
            ]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   830
        ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   831
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   832
        aStream notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   833
            aStream position:sourcePosition.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   834
            junk := aStream nextChunk.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   835
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   836
            "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   837
             keep a weak reference - it may be needed again soon ...
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   838
            "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   839
            LastFileReference isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   840
                LastFileReference := WeakArray new:1
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   841
            ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   842
            LastFileReference at:1 put:aStream.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   843
            LastSourceFileName := source
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   844
        ]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   845
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   846
    ^ junk
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   847
957
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   848
    "Modified: 9.2.1996 / 19:09:18 / cg"
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   849
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   850
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   851
source:aString
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   852
    "set the methods sourcestring"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   853
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   854
    source := aString.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   855
    sourcePosition := nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   856
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   857
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   858
sourceFilename
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   859
    "return the sourcefilename if source is extern; nil otherwise"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   860
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   861
    sourcePosition notNil ifTrue:[^ source].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   862
    ^ nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   863
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   864
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   865
sourceFilename:aFileName position:aNumber
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   866
    "set the methods sourcefile/position"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   867
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   868
    source := aFileName.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   869
    sourcePosition := aNumber
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   870
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   871
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   872
sourcePosition
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   873
    "return the sourceposition if source is extern; nil otherwise"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   874
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   875
    ^ sourcePosition
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   876
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   877
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   878
stackSize
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   879
    "return the number of temporaries needed as stack in the context. 
49
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   880
     Do not depend on the returned value - future optimizations
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   881
     may change things here.
49
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   882
     - for debugging only."
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   883
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   884
%{  /* NOCONTEXT */
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   885
    /* made this a primitive to get define in stc.h */
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   886
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   887
    RETURN (_MKSMALLINT((_intVal(_INST(flags)) & F_NSTACK) >> F_NSTACKSHIFT));
49
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   888
%}
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   889
!
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   890
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   891
stackSize:aNumber
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   892
    "set the depth of the local stack - for use by compiler only.
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   893
     WARNING: playing around here with incorrect values 
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   894
	      may crash smalltalk badly.
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   895
	      (if the runtime library was compiled with DEBUG, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   896
	       a bad stack will be detected and triggers an error)"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   897
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   898
%{  /* NOCONTEXT */
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   899
    int f = _intVal(_INST(flags));
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   900
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   901
    /* made this a primitive to get define in stc.h */
253
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
   902
    if (__isSmallInteger(aNumber)) {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   903
	f = (f & ~F_NSTACK) | (_intVal(aNumber) << F_NSTACKSHIFT);
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   904
	_INST(flags) = _MKSMALLINT(f);
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   905
    }
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   906
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   907
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   908
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   909
!Method methodsFor:'binary storage'!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   910
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   911
asByteCodeMethod
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   912
    "if the receiver has no bytecodes, create & return a method having
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   913
     the same semantics as the receiver, but uses interpreted bytecodes.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   914
     Otherwise, return the receiver. The new method is not installed in
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   915
     the methodDictionary of any class - just returned.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   916
     Can be used to obtain a bytecode version of a machine-code method, 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   917
     for binary storage or dynamic recompilation (which is not yet finished)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   918
     or to compile lazy methods down to executable ones."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   919
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   920
    |doMachineCode mthd|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   921
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   922
    byteCode notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   923
	"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   924
	 is already a bytecoded method
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   925
	"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   926
	^ self
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   927
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   928
    doMachineCode := Compiler stcCompilation:#never.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   929
    [
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   930
	mthd := self asExecutableMethod.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   931
    ] valueNowOrOnUnwindDo:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   932
	Compiler stcCompilation:doMachineCode.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   933
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   934
    ^ mthd
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   935
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   936
    "Created: 24.10.1995 / 14:02:32 / cg"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   937
    "Modified: 24.10.1995 / 14:17:21 / cg"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   938
!
306
365e65400c93 *** empty log message ***
claus
parents: 302
diff changeset
   939
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   940
asExecutableMethod
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   941
    "if the receiver has neither bytecodes nor machinecode, create & return a 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   942
     method having semantics as the receivers source. This may be machine code,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   943
     if the system supports dynamic loading of object code and the source includes
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   944
     primitive code. However, bytecode is preferred, since it compiles faster.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   945
     Otherwise, return the receiver. The new method is not installed in
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   946
     the methodDictionary of any class - just returned.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   947
     Can be used to compile lazy methods down to executable ones."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   948
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   949
    |temporaryMethod cls sourceString silent lazy|
306
365e65400c93 *** empty log message ***
claus
parents: 302
diff changeset
   950
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   951
    byteCode notNil ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   952
        "
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   953
         is already a bytecoded method
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   954
        "
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   955
        ^ self
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   956
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   957
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   958
    cls := self containingClass.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   959
    cls isNil ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   960
        'METHOD: cannot generate bytecode (no class for compilation)' errorPrintNL.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   961
        ^ nil
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   962
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   963
    sourceString := self source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   964
    sourceString isNil ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   965
        'METHOD: cannot generate bytecode (no source for compilation)' errorPrintNL.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   966
        ^ nil
306
365e65400c93 *** empty log message ***
claus
parents: 302
diff changeset
   967
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   968
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   969
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   970
     dont want this to go into the changes file,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   971
     dont want output on Transcript and definitely 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   972
     dont want a lazy method ...
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   973
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   974
    Class withoutUpdatingChangesDo:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   975
        silent := Smalltalk silentLoading:true.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   976
        lazy := Compiler compileLazy:false.
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   977
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   978
        [
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   979
            |compiler|
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   980
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   981
            compiler := cls compilerClass.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   982
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   983
            "/
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   984
            "/ kludge - have to make ST/X's compiler protocol
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   985
            "/ be compatible to ST-80's
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   986
            "/
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   987
            (compiler respondsTo:#compile:forClass:inCategory:notifying:install:skipIfSame:)
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   988
            ifTrue:[
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   989
                temporaryMethod := compiler
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   990
                                     compile:sourceString
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   991
                                     forClass:cls
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   992
                                     inCategory:(self category)
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   993
                                     notifying:nil
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   994
                                     install:false.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   995
            ] ifFalse:[
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   996
                temporaryMethod := compiler new
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   997
                                     compile:sourceString 
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   998
                                     in:cls 
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   999
                                     notifying:nil 
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1000
                                     ifFail:nil
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1001
            ].
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1002
        ] valueNowOrOnUnwindDo:[
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1003
            Compiler compileLazy:lazy.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1004
            Smalltalk silentLoading:silent.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1005
        ]
463
447ead9f870c be silent on transcript when parsing for args, vars and primitiveCode
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
  1006
    ].
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1007
    (temporaryMethod isNil or:[temporaryMethod == #Error]) ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1008
        'METHOD: cannot generate bytecode (contains primitive code or error)' errorPrintNL.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1009
        ^ nil.
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1010
    ].
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1011
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1012
     try to save a bit of memory, by sharing the source (whatever it is)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1013
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1014
    temporaryMethod sourceFilename:source position:sourcePosition. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1015
    ^ temporaryMethod
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1016
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1017
    "Created: 24.10.1995 / 14:02:30 / cg"
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1018
    "Modified: 7.3.1996 / 19:19:12 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1019
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1020
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1021
readBinaryContentsFrom: stream manager: manager
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1022
    "tell the newly restored Font about restoration"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1023
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1024
    self code notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1025
	"built-in method - already complete"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1026
	^ self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1027
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1028
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1029
    ^ super readBinaryContentsFrom: stream manager: manager
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1030
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1031
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1032
storeBinaryDefinitionOn:stream manager:manager
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1033
    "only store bytecode-methods - machinecode methods are stored
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1034
     as class/selector pair and a lookup is done when restored.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1035
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1036
     If the receiver method is a built-in (i.e. machine coded)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1037
     method, a temporary interpreted byte code method is created,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1038
     and its bytecode stored. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1039
     This works only, if the source of the method is available and the
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1040
     method does not contain primitive code."
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1041
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1042
    |storedMethod who|
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1043
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1044
    byteCode isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1045
	self code notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1046
	    (who := self who) notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1047
		"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1048
		 machine code only - assume its a built-in method,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1049
		 and store the class/selector information.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1050
		 The restored method may not be exactly the same ...
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1051
		"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1052
		manager putIdOfClass:(self class) on:stream.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1053
		stream nextPutByte:0.   "means: built-in method" 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1054
		manager putIdOf:(who at:1) on:stream.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1055
		manager putIdOf:(who at:2) on:stream.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1056
		^ self
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1057
	    ]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1058
	].
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1059
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1060
	storedMethod := self asByteCodeMethod.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1061
	storedMethod isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1062
	    self error:'store of built-in method failed'.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1063
	    ^ nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1064
	].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1065
	^ storedMethod storeBinaryDefinitionOn:stream manager:manager
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1066
    ].
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1067
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1068
    manager putIdOfClass:(self class) on:stream.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1069
    stream nextPutByte:1.       "means: byte-coded method"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1070
    self storeBinaryDefinitionBodyOn:stream manager:manager
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1071
!
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1072
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1073
storeFullBinaryDefinitionOn:stream manager:manager
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1074
    "store full bytecoded-method."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1075
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1076
    |m code srcPos|
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1077
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1078
    ObjectMemory snapshotID storeBinaryOn:stream manager:manager.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1079
    category storeBinaryOn:stream manager:manager.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1080
    byteCode isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1081
	m := self asByteCodeMethod.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1082
	code notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1083
	    code := m byteCode
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1084
	] ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1085
	    m := self
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1086
	]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1087
    ] ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1088
	m := self.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1089
	code := byteCode
391
claus
parents: 384
diff changeset
  1090
    ].
362
claus
parents: 360
diff changeset
  1091
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1092
    m flags storeBinaryOn:stream manager:manager.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1093
    m literals storeBinaryOn:stream manager:manager.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1094
    manager sourceMode == #discard ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1095
	nil storeBinaryOn:stream manager:manager. "/ sourceFileName
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1096
	nil storeBinaryOn:stream manager:manager. "/ sourcePosition
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1097
	nil storeBinaryOn:stream manager:manager. "/ source
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1098
    ] ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1099
	m sourceFilename storeBinaryOn:stream manager:manager.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1100
	manager sourceMode == #reference ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1101
	    srcPos := m sourcePosition.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1102
	] ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1103
	    srcPos := nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1104
	].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1105
	srcPos storeBinaryOn:stream manager:manager.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1106
	srcPos isNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1107
	    m source storeBinaryOn:stream manager:manager.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1108
	].
391
claus
parents: 384
diff changeset
  1109
    ].
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1110
    code storeBinaryOn:stream manager:manager.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1111
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1112
    "Created: 16.1.1996 / 14:41:45 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1113
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1114
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1115
!Method methodsFor:'copying'!
438
claus
parents: 423
diff changeset
  1116
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1117
copy
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1118
    "redefined to change source ref into a real string"
438
claus
parents: 423
diff changeset
  1119
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1120
    |aCopy|
438
claus
parents: 423
diff changeset
  1121
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1122
    aCopy := super copy.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1123
    sourcePosition notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1124
	aCopy source:(self source)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1125
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1126
    ^ aCopy
438
claus
parents: 423
diff changeset
  1127
! !
claus
parents: 423
diff changeset
  1128
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1129
!Method methodsFor:'error handling'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1130
328
claus
parents: 326
diff changeset
  1131
invalidCodeObject
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1132
    "this method is triggered by the interpreter when a nil or non method
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1133
     is about to be executed.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1134
     In this case, the VM sends this to the bad method (the receiver).
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1135
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1136
     Also, the Compiler creates methods with their code/bytecode set to
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1137
     this method if - after a class change - a method cannot be compiled
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1138
     and is therefore no longer executable (for example, after an instvar
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1139
     has been removed, and a method still tries to access this instvar)
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1140
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1141
     Thus, we arrive here, when playing around in a classes methodArray,
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1142
     or compiler/runtime system is broken :-(, 
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1143
     or you ignore the error messages during some recompile."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1144
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1145
    ^ InvalidCodeSignal
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1146
	raiseRequestWith:self
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1147
	errorString:'invalid method - not executable'.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1148
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1149
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1150
privateMethodCalled
980
0ab2f56ecfc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 957
diff changeset
  1151
    "this error is triggered, if a private or protected method is called.
0ab2f56ecfc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 957
diff changeset
  1152
360
claus
parents: 350
diff changeset
  1153
     If you continue in the debugger, the method will be called,
415
claus
parents: 414
diff changeset
  1154
     and further privacy exceptions will NOT be reported at this call location, 
360
claus
parents: 350
diff changeset
  1155
     until any new method is compiled, or the privacy of any method changes,
claus
parents: 350
diff changeset
  1156
     or the caches are flushed.
claus
parents: 350
diff changeset
  1157
     (the reason is that after the continue, the method is enterred into the
claus
parents: 350
diff changeset
  1158
      calling cache, for which method privacy is not checked.
claus
parents: 350
diff changeset
  1159
      Any of the above actions flushes this cache and a privacy check
claus
parents: 350
diff changeset
  1160
      is performed again.)
claus
parents: 350
diff changeset
  1161
     Future versions may not enter private methods into the cache, to fix this
claus
parents: 350
diff changeset
  1162
     (unobvious) behavior. However, then you will get an exception for EVERY
claus
parents: 350
diff changeset
  1163
     call to a private method ...
claus
parents: 350
diff changeset
  1164
claus
parents: 350
diff changeset
  1165
     Notice: method privacy is a nonstandard feature, not supported
claus
parents: 350
diff changeset
  1166
     by other smalltalk implementations and not specified in the ANSI spec.
claus
parents: 350
diff changeset
  1167
     This is EXPERIMENTAL - and being evaluated for usability.
claus
parents: 350
diff changeset
  1168
     It may change or even vanish (if it shows to be not useful)."
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1169
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1170
    ^ PrivateMethodSignal raise
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1171
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1172
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1173
uncompiledCodeObject
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1174
    "this method is invoked by methods which contain primitive code,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1175
     but have not been compiled to machine code (either due to an error
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1176
     when compiling, or simply because no stc is available.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1177
     For those methods, the compiler generated a method object consisting
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1178
     of the original source code, but with this methods machine/byte code.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1179
     Therefore, we patch (kludge) the lineNumber information, to show the
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1180
     first line (instead of the real line below)"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1181
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1182
    thisContext setLineNumber:1.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1183
    ^ InvalidCodeSignal
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1184
	raiseRequestWith:self
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1185
	errorString:'invalid method - not compiled'.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1186
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1187
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1188
wrongNumberOfArguments:numberGiven
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1189
    "this error is triggered, if a method is called with a wrong number
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1190
     of arguments. This only applies to #valueWithReceiverXXX - sends.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1191
     With a normal send, this error cannot happen."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1192
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1193
    ^ ArgumentSignal
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1194
	raiseRequestWith:self
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1195
	errorString:('method got ' , numberGiven printString ,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1196
		     ' args while ' , self numberOfMethodArgs printString , ' where expected')
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1197
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1198
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1199
!Method methodsFor:'executing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1200
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1201
valueWithReceiver:anObject arguments:argArray
2
claus
parents: 1
diff changeset
  1202
    "low level call of a methods code - BIG DANGER ALERT.
claus
parents: 1
diff changeset
  1203
     Perform the receiver-method on anObject as receiver and argArray as
claus
parents: 1
diff changeset
  1204
     arguments. This does NO message lookup at all and mimics a
claus
parents: 1
diff changeset
  1205
     traditional function call.
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1206
     This method is provided for debugging- and breakpoint-support 
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1207
     (replacing a method by a stub and recalling the original), or to implement
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1208
     experimental MI implementations - it is not for general use. 
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1209
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1210
     The receiver must be a method compiled in anObjects class or one of its 
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1211
     superclasses and also, the number of arguments given must match the methods
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1212
     expectations -
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1213
     - otherwise strange things (and also strange crashes) can occur.
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1214
     The system is NOT always detecting a wrong method/receiver combination.
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1215
     YOU HAVE BEEN WARNED."
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1216
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1217
    ^ self valueWithReceiver:anObject arguments:argArray selector:nil search:nil
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1218
!
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1219
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1220
valueWithReceiver:anObject arguments:argArray selector:aSymbol
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1221
    "low level call of a methods code - BIG DANGER ALERT.
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1222
     Perform the receiver-method on anObject as receiver and argArray as
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1223
     arguments. This does NO message lookup at all and mimics a
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1224
     traditional function call.
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1225
     This method is provided for debugging- and breakpoint-support 
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1226
     (replacing a method by a stub and recalling the original), or to implement
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1227
     experimental MI implementations - it is not for general use. 
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1228
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1229
     The receiver must be a method compiled in anObjects class or one of its 
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1230
     superclasses and also, the number of arguments given must match the methods
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1231
     expectations -
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1232
     - otherwise strange things (and also strange crashes) can occur.
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1233
     The system is NOT always detecting a wrong method/receiver combination.
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1234
     YOU HAVE BEEN WARNED."
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1235
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1236
    ^ self valueWithReceiver:anObject 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1237
		   arguments:argArray 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1238
		    selector:aSymbol 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1239
		      search:nil
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1240
		      sender:nil
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1241
!
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1242
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1243
valueWithReceiver:anObject arguments:argArray selector:aSymbol search:aClass
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1244
    "low level call of a methods code - BIG DANGER ALERT.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1245
     Perform the receiver-method on anObject as receiver and argArray as
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1246
     arguments. This does NO message lookup at all and mimics a
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1247
     traditional function call.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1248
     This method is provided for debugging- and breakpoint-support 
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1249
     (replacing a method by a stub and recalling the original), or to implement
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1250
     experimental MI implementations - it is not for general use. 
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1251
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1252
     The receiver must be a method compiled in anObjects class or one of its 
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1253
     superclasses and also, the number of arguments given must match the methods
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1254
     expectations -
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1255
     - otherwise strange things (and also strange crashes) can occur.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1256
     The system is NOT always detecting a wrong method/receiver combination.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1257
     YOU HAVE BEEN WARNED."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1258
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1259
    ^ self valueWithReceiver:anObject 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1260
		   arguments:argArray 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1261
		    selector:aSymbol 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1262
		      search:nil
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1263
		      sender:nil
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1264
!
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1265
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1266
valueWithReceiver:anObject arguments:argArray selector:aSymbol search:aClass sender:virtualSender
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1267
    "low level call of a methods code - BIG DANGER ALERT.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1268
     Perform the receiver-method on anObject as receiver and argArray as
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1269
     arguments. This does NO message lookup at all and mimics a
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1270
     traditional function call.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1271
     This method is provided for debugging- and breakpoint-support 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1272
     (replacing a method by a stub and recalling the original), or to implement
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1273
     experimental MI implementations - it is not for general use. 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1274
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1275
     The receiver must be a method compiled in anObjects class or one of its 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1276
     superclasses and also, the number of arguments given must match the methods
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1277
     expectations -
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1278
     - otherwise strange things (and also strange crashes) can occur.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1279
     The system is NOT always detecting a wrong method/receiver combination.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1280
     YOU HAVE BEEN WARNED."
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1281
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1282
%{
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1283
    OBJFUNC code;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1284
    OBJ searchClass;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1285
    static struct inlineCache dummy = _DUMMYILC0;
2
claus
parents: 1
diff changeset
  1286
    int nargs;
claus
parents: 1
diff changeset
  1287
    OBJ *ap;
claus
parents: 1
diff changeset
  1288
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1289
    if (__isArray(argArray)) {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1290
	nargs = _arraySize(argArray);
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1291
	ap = _ArrayInstPtr(argArray)->a_element;
2
claus
parents: 1
diff changeset
  1292
    } else {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1293
	if (argArray == nil) {
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1294
	    nargs = 0;
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1295
	} else
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1296
	    nargs = -1;
2
claus
parents: 1
diff changeset
  1297
    }
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1298
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1299
#ifdef F_NARGS
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1300
    if (((_intVal(_INST(flags)) & F_NARGS) >> F_NARGSHIFT) == nargs) 
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1301
#endif
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1302
    {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1303
	code = _MethodInstPtr(self)->m_code;
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1304
	if (aClass == nil) {
328
claus
parents: 326
diff changeset
  1305
	    searchClass = dummy.ilc_class = __Class(anObject);
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1306
	} else {
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1307
	    searchClass = dummy.ilc_class = aClass;
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1308
	}
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1309
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1310
	if (nargs <= 15) {
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1311
	  /*
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1312
	   * add virtual sender (unwinding) here later,
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1313
	   * to allow hiding contexts in lazy methods.
328
claus
parents: 326
diff changeset
  1314
	   * (this is cosmetics only; therefore its done later)
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1315
	   */
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1316
	  if (code) {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1317
	    /* compiled code */
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1318
	    switch (nargs) {
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1319
		case 0:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1320
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1321
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1322
		case 1:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1323
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, ap[0]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1324
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1325
		case 2:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1326
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, ap[0], ap[1]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1327
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1328
		case 3:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1329
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, ap[0], ap[1], ap[2]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1330
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1331
		case 4:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1332
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1333
				 ap[0], ap[1], ap[2], ap[3]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1334
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1335
		case 5:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1336
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1337
				 ap[0], ap[1], ap[2], ap[3], ap[4]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1338
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1339
		case 6:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1340
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1341
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1342
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1343
		case 7:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1344
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1345
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1346
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1347
		case 8:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1348
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1349
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1350
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1351
		case 9:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1352
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1353
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1354
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1355
		case 10:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1356
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1357
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1358
				 ap[9]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1359
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1360
		case 11:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1361
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1362
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1363
				 ap[9], ap[10]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1364
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1365
		case 12:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1366
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1367
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1368
				 ap[9], ap[10], ap[11]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1369
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1370
		case 13:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1371
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1372
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1373
				 ap[9], ap[10], ap[11], ap[12]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1374
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1375
		case 14:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1376
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1377
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1378
				 ap[9], ap[10], ap[11], ap[12], ap[13]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1379
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1380
		case 15:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1381
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1382
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1383
				 ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]) );
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1384
	    }
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1385
	  } else {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1386
	    /* interpreted code */
328
claus
parents: 326
diff changeset
  1387
#ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
  1388
	    RETURN ( __interpret(self, nargs, anObject, aSymbol, SND_COMMA searchClass, ap) );
claus
parents: 326
diff changeset
  1389
#else
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1390
	    switch (nargs) {
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1391
		case 0:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1392
		    RETURN ( __interpret(self, 0, anObject, aSymbol, SND_COMMA searchClass) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1393
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1394
		case 1:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1395
		    RETURN ( __interpret(self, 1, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1396
				   ap[0]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1397
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1398
		case 2:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1399
		    RETURN ( __interpret(self, 2, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1400
				   ap[0], ap[1]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1401
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1402
		case 3:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1403
		    RETURN ( __interpret(self, 3, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1404
				   ap[0], ap[1], ap[2]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1405
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1406
		case 4:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1407
		    RETURN ( __interpret(self, 4, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1408
				   ap[0], ap[1], ap[2], ap[3]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1409
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1410
		case 5:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1411
		    RETURN ( __interpret(self, 5, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1412
				   ap[0], ap[1], ap[2], ap[3], ap[4]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1413
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1414
		case 6:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1415
		    RETURN ( __interpret(self, 6, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1416
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1417
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1418
		case 7:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1419
		    RETURN ( __interpret(self, 7, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1420
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1421
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1422
		case 8:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1423
		    RETURN ( __interpret(self, 8, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1424
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1425
				   ap[7]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1426
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1427
		case 9:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1428
		    RETURN ( __interpret(self, 9, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1429
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1430
				   ap[7], ap[8]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1431
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1432
		case 10:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1433
		    RETURN ( __interpret(self, 10, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1434
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1435
				   ap[7], ap[8], ap[9]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1436
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1437
		case 11:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1438
		    RETURN ( __interpret(self, 11, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1439
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1440
				   ap[7], ap[8], ap[9], ap[10]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1441
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1442
		case 12:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1443
		    RETURN ( __interpret(self, 12, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1444
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1445
				   ap[7], ap[8], ap[9], ap[11]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1446
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1447
		case 13:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1448
		    RETURN ( __interpret(self, 13, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1449
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1450
				   ap[7], ap[8], ap[9], ap[11], ap[12]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1451
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1452
		case 14:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1453
		    RETURN ( __interpret(self, 14, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1454
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1455
				   ap[7], ap[8], ap[9], ap[11], ap[12], ap[13]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1456
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1457
		case 15:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1458
		    RETURN ( __interpret(self, 15, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1459
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1460
				   ap[7], ap[8], ap[9], ap[11], ap[12], ap[13], ap[14]) );
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1461
	    }
328
claus
parents: 326
diff changeset
  1462
#endif
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1463
	  }
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1464
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1465
    }
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1466
%}
2
claus
parents: 1
diff changeset
  1467
.
claus
parents: 1
diff changeset
  1468
    (argArray isMemberOf:Array) ifFalse:[
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1469
	"
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1470
	 arguments must be either nil or an array
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1471
	"
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1472
	^ self badArgumentArray
2
claus
parents: 1
diff changeset
  1473
    ].
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1474
    (argArray size ~~ self numberOfMethodArgs) ifTrue:[
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1475
	"
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1476
	 the method expects a different number of arguments
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1477
	"
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1478
	^ self wrongNumberOfArguments:argArray size
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1479
    ].
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1480
    "
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1481
     the VM only supports a limited number of arguments in sends
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1482
    "
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1483
    ^ self tooManyArguments
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1484
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1485
    "
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1486
     (Float compiledMethodAt:#+) 
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1487
	valueWithReceiver:1.0 arguments:#(2.0)
2
claus
parents: 1
diff changeset
  1488
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1489
     'the next example is a wrong one - which is detected by True's method ...'.
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1490
     (True compiledMethodAt:#printString) 
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1491
	valueWithReceiver:false arguments:nil
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1492
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1493
     'the next example is a wrong one - it is nowhere detected
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1494
      and a wrong value returned ...'.
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1495
     (Point compiledMethodAt:#x) 
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1496
	valueWithReceiver:(1->2) arguments:nil
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1497
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1498
     'the next example is VERY bad one - it is nowhere detected
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1499
      and may crash the system WARNING: save your work before doing this ...'.
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1500
     (Point compiledMethodAt:#x) 
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1501
	valueWithReceiver:(Object new) arguments:nil
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1502
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1503
     'the next example is a wrong one - which is detected here ...'.
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1504
     (Object compiledMethodAt:#printOn:)
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1505
	valueWithReceiver:false arguments:nil
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1506
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1507
     'the next example is a wrong one - which is detected here ...'.
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1508
     (Object compiledMethodAt:#printOn:)
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1509
	valueWithReceiver:false arguments:#() 
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1510
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1511
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1512
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1513
!Method methodsFor:'printing & storing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1514
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1515
printOn:aStream
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1516
    "put a printed representation of the receiver onto aStream.
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1517
     Since methods do not store their class/selector, we have to search
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1518
     for it here."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1519
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1520
    |classAndSelector m wrapped|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1521
253
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1522
    wrapped := false.
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1523
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1524
    aStream nextPutAll:(self classNameWithArticle).
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1525
    aStream nextPut:$(.
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1526
176
48061f8659aa more queries
claus
parents: 159
diff changeset
  1527
    classAndSelector := self who.
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1528
    classAndSelector isNil ifTrue:[
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1529
	"
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1530
	 not anchored in any class.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1531
	 check if wrapped (to be more informative in inspectors)
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1532
	"
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1533
	m := self wrapper.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1534
	m notNil ifTrue:[
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1535
	    classAndSelector := m who.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1536
	    wrapped := true.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1537
	]
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1538
    ].
176
48061f8659aa more queries
claus
parents: 159
diff changeset
  1539
    classAndSelector notNil ifTrue:[
48061f8659aa more queries
claus
parents: 159
diff changeset
  1540
	(classAndSelector at:1) name printOn:aStream.
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1541
	aStream nextPutAll:' '.
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1542
	(classAndSelector at:2) printOn:aStream.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1543
	wrapped ifTrue:[
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1544
	    aStream nextPutAll:'; wrapped'
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1545
	].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1546
    ] ifFalse:[
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
  1547
	"
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1548
	 sorry, a method which is nowhere anchored
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
  1549
	"
253
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1550
	aStream nextPutAll:'unbound'
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1551
    ].
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1552
    aStream nextPut:$)
176
48061f8659aa more queries
claus
parents: 159
diff changeset
  1553
48061f8659aa more queries
claus
parents: 159
diff changeset
  1554
    "
253
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1555
     (Object compiledMethodAt:#at:) printOn:Transcript. Transcript cr.
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1556
     (Object compiledMethodAt:#at:) copy printOn:Transcript. Transcript cr.
176
48061f8659aa more queries
claus
parents: 159
diff changeset
  1557
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1558
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1559
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1560
whoString
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1561
    "return a string as className>>selector, if this is not an unbound
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1562
     method. Otherwise return 'unbound'. Used with debugging."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1563
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1564
    |w|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1565
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1566
    w := self who.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1567
    w notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1568
	^ (w at:1) name , '>>' , (w at:2)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1569
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1570
    ^ 'unbound'
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1571
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1572
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1573
     Method new whoString
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1574
     (Method compiledMethodAt:#whoString) whoString
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1575
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1576
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1577
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1578
!Method methodsFor:'queries'!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1579
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1580
containingClass
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1581
    "return the class I am defined in. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1582
     See comment in who."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1583
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1584
    "based on who, which has been added for ST-80 compatibility"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1585
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1586
    |pair|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1587
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1588
    pair := self who.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1589
    pair notNil ifTrue:[^ pair at:1].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1590
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1591
     none found - sorry
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1592
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1593
    ^ nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1594
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1595
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1596
     |m|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1597
     m := Object compiledMethodAt:#at:.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1598
     m containingClass
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1599
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1600
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1601
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1602
hasPrimitiveCode
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1603
    "return true, if the method contains primitive code; false if not.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1604
     Uses Parser to parse methods source and get the information."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1605
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1606
    |src|
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1607
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1608
    src := self source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1609
    src notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1610
	(src includesString:'%{' ) ifFalse:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1611
	    "/ cannot contain primitive code.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1612
	    ^ false
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1613
	]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1614
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1615
    ^ self parse:#'parseMethodSilent:' return:#hasPrimitiveCode or:false
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1616
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1617
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1618
     (Method compiledMethodAt:#hasPrimitiveCode) hasPrimitiveCode 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1619
     (Object compiledMethodAt:#at:) hasPrimitiveCode   
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1620
     (Object compiledMethodAt:#basicAt:) hasPrimitiveCode 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1621
    "
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1622
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1623
    "Modified: 31.10.1995 / 14:43:37 / cg"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1624
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1625
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1626
isInvalid
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1627
    "return true, if this method is not executable due to
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1628
     a (re)-compilation error. (see comment in Method>>invalidCodeObject)"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1629
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1630
    |m|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1631
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1632
    m := Method compiledMethodAt:#invalidCodeObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1633
    self ~~ m ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1634
	(self code notNil and:[self code = m code]) ifTrue:[^ true].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1635
	(byteCode notNil and:[byteCode == m byteCode]) ifTrue:[^ true].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1636
    ].
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1637
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1638
    m := Method compiledMethodAt:#uncompiledCodeObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1639
    self ~~ m ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1640
	(self code notNil and:[self code = m code]) ifTrue:[^ true].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1641
	(byteCode notNil and:[byteCode == m byteCode]) ifTrue:[^ true].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1642
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1643
    m := Metaclass compiledMethodAt:#invalidCodeObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1644
    self ~~ m ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1645
	(self code notNil and:[self code = m code]) ifTrue:[^ true].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1646
	(byteCode notNil and:[byteCode == m byteCode]) ifTrue:[^ true].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1647
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1648
    ^ false
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1649
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1650
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1651
isLazyMethod
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1652
    "return true, if this is a lazy method.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1653
     False is returned here - this method is redefined in LazyMethod"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1654
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1655
    ^ false
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1656
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1657
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1658
isMethod
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1659
    "return true, if the receiver is some kind of method;
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1660
     true returned here - the method is redefined from Object."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1661
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1662
    ^ true
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1663
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1664
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1665
isWrapped
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1666
    "return true, if this is a wrapper method.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1667
     False is returned here - this method is redefined in WrappedMethod"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1668
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1669
    ^ false
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1670
!
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1671
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1672
methodArgAndVarNames
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1673
    "return a collection with the methods argument and variable names.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1674
     Uses Parser to parse methods source and extract the names.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1675
     Returns nil if the source is not available, or some other
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1676
     syntax/parse error occurred. For methods with no args and no vars,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1677
     an empty collection is returned."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1678
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1679
    |parser sourceString argNames varNames|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1680
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1681
    sourceString := self source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1682
    sourceString notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1683
	parser := Parser parseMethodArgAndVarSpecificationSilent:sourceString.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1684
	(parser isNil or:[parser == #Error]) ifTrue:[^ nil].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1685
	argNames := parser methodArgs.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1686
	varNames := parser methodVars.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1687
	argNames isNil ifTrue:[^ varNames].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1688
	varNames isNil ifTrue:[^ argNames].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1689
	^ (argNames , varNames)
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1690
    ].
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1691
    ^ nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1692
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1693
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1694
     (Method compiledMethodAt:#printOn:) methodArgAndVarNames
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1695
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1696
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1697
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1698
methodArgNames
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1699
    "return a collection with the methods argument names.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1700
     Uses Parser to parse methods source and extract the names."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1701
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1702
    ^ self parse:#'parseMethodSpecificationSilent:' return:#methodArgs or:nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1703
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1704
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1705
     (Method compiledMethodAt:#printOn:) methodArgNames
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1706
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1707
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1708
    "Modified: 31.10.1995 / 14:36:46 / cg"
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1709
!
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1710
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1711
methodComment
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1712
    "return the methods first comment, nil if there is none.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1713
     This is a somewhat stupid implementation."
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1714
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1715
    |text line nQuote index qIndex qIndex2 comment|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1716
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1717
    text := self source asCollectionOfLines.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1718
    (text size < 2) ifTrue:[^nil].
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1719
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1720
    line := (text at:2).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1721
    nQuote := line occurrencesOf:(Character doubleQuote).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1722
    (nQuote == 2) ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1723
	qIndex := line indexOf:(Character doubleQuote).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1724
	qIndex2 := line indexOf:(Character doubleQuote) startingAt:(qIndex + 1).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1725
	^ line copyFrom:(qIndex + 1) to:(qIndex2 - 1)
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1726
    ].
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1727
    (nQuote == 1) ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1728
	qIndex := line indexOf:(Character doubleQuote).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1729
	comment := line copyFrom:(qIndex + 1).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1730
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1731
	index := 3.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1732
	line := text at:index.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1733
	nQuote := line occurrencesOf:(Character doubleQuote).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1734
	[nQuote ~~ 1] whileTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1735
	    comment := comment , Character cr asString , line withoutSpaces.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1736
	    index := index + 1.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1737
	    line := text at:index.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1738
	    nQuote := line occurrencesOf:(Character doubleQuote)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1739
	].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1740
	qIndex := line indexOf:(Character doubleQuote).
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1741
	^ comment , Character cr asString , (line copyTo:(qIndex - 1)) withoutSpaces
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1742
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1743
    ^ nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1744
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1745
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1746
     (Method compiledMethodAt:#methodComment) methodComment
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1747
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1748
!
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1749
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1750
methodVarNames
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1751
    "return a collection with the methods local-variable names.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1752
     Uses Parser to parse methods source and extract the names."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1753
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1754
    ^ self parse:#'parseMethodArgAndVarSpecificationSilent:' return:#methodVars or:nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1755
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1756
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1757
     (Method compiledMethodAt:#printOn:) methodVarNames
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1758
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1759
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1760
    "Modified: 31.10.1995 / 14:36:49 / cg"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1761
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1762
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1763
modificationTime
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1764
    "try to extract the modificationTime as a timeStamp from
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1765
     the receivers source. If there is no source or no history line, 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1766
     we do not know the modification time, and nil is returned."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1767
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1768
    |s list histLine|
877
63ebb325ed20 flush global-access cache (using snapshotID) when saving a methods binary code
Claus Gittinger <cg@exept.de>
parents: 872
diff changeset
  1769
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1770
    HistoryManager isNil ifTrue:[^ nil].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1771
    s := self source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1772
    s isNil ifTrue:[^ nil].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1773
    list := HistoryManager getAllHistoriesFrom:s.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1774
    list size == 0 ifTrue:[^ nil].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1775
    histLine := list last.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1776
    ^ AbsoluteTime date:histLine date time:histLine time
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1777
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1778
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1779
     (Method compiledMethodAt:#modificationTime) modificationTime
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1780
     (Method compiledMethodAt:#isMethod) modificationTime 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1781
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1782
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1783
    "Modified: 8.9.1995 / 15:08:22 / claus"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1784
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1785
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1786
parse:parseSelector return:accessSelector or:valueIfNoSource 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1787
    "helper for methodArgNames, methodVarNames etc.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1788
     Get the source, let parser parse it using parseSelector,
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1789
     return parser info using accessSelector"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1790
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1791
    |parser sourceString|
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1792
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1793
    sourceString := self source.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1794
    sourceString notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1795
	parser := Parser perform:parseSelector with:sourceString.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1796
	(parser isNil or:[parser == #Error]) ifTrue:[^ nil].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1797
	^ parser perform:accessSelector
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1798
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1799
    ^ valueIfNoSource 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1800
!
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1801
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1802
referencesGlobal:aGlobalSymbol
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1803
    "return true, if this method references the global
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1804
     bound to aGlobalSymbol."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1805
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1806
    |lits|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1807
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1808
    (lits := self literals) isNil ifTrue:[^ false].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1809
    ^ (lits identityIndexOf:aGlobalSymbol startingAt:1) ~~ 0
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1810
!
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  1811
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1812
selector
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1813
    "return the selector under which I am found in my containingClasses
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1814
     method-table. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1815
     See comment in who."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1816
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1817
    "based on who, which has been added for ST-80 compatibility"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1818
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1819
    |pair|
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1820
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1821
    pair := self who.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1822
    pair notNil ifTrue:[^ pair at:2].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1823
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1824
     none found - sorry
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1825
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1826
    ^ nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1827
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1828
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1829
     |m|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1830
     m := Object compiledMethodAt:#at:.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1831
     m selector
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1832
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1833
!
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1834
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1835
sends:aSelectorSymbol
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1836
    "return true, if this method contains a message-send
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1837
     with aSelectorSymbol as selector. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1838
     - due to the simple check in the literal array, also simple uses 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1839
       of aSelectorSymbol as symbol will return true.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1840
       Should ask compiler, if there is really a send."
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1841
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1842
    ^ self referencesGlobal:aSelectorSymbol
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1843
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1844
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1845
who
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1846
    "return the class and selector of where I am defined in. 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1847
     Since there is no information of the containing class 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1848
     in the method, we have to do a search here.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1849
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1850
     Normally, this is not a problem, except when a method is
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1851
     accepted in the debugger or redefined from within a method
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1852
     (maybe done indirectly, if doIt is done recursively)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1853
     - the information about which class the original method was 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1854
     defined in is lost in this case.
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1855
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1856
     Problem: this is heavily called for in the debugger to create
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1857
	      a readable context walkback. For unbound methods, it is
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1858
	      slow, since the search (over all classes) will always fail.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1859
     Q: should we add a backref from the method to the class 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1860
	and/or add a subclass of Method for unbound ones ?"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1861
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1862
    |classes cls sel|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1863
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1864
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1865
     very first, look in the class we found something the last time
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1866
     this may often give a hit, when asking who repeatingly for
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1867
     a context chain. (keep last by its name, to not keep classes from
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1868
     being garbage collected)
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1869
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1870
    LastWhoClass notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1871
	cls := Smalltalk at:LastWhoClass.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1872
	cls notNil ifTrue:[
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1873
	    sel := cls selectorAtMethod:self.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1874
	    sel notNil ifTrue:[^ Array with:cls with:sel].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1875
	]
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1876
    ].
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1877
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1878
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1879
     first, limit the search to global classes only - 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1880
     since probability is high, that the receiver is found in there ...
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1881
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1882
    classes := Smalltalk allClasses.
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1883
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1884
     instance methods are usually more common - search those first
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1885
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1886
    classes do:[:aClass |
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1887
	|sel|
350
claus
parents: 345
diff changeset
  1888
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1889
	sel := aClass selectorAtMethod:self.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1890
	sel notNil ifTrue:[LastWhoClass := aClass name.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1891
			   ^ Array with:aClass with:sel].
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1892
    ].
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1893
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1894
    LastWhoClass := nil.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1895
    classes do:[:aClass |
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1896
	|sel|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1897
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1898
	sel := aClass class selectorAtMethod:self.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1899
	sel notNil ifTrue:[^ Array with:aClass class with:sel].
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1900
    ].
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1901
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1902
     mhmh - must be a method of some anonymous class (i.e. one not
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1903
     in the Smalltalk dictionary). Search all instances of Behavior
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1904
    "
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1905
    Behavior allSubInstancesDo:[:someClass |
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1906
	|sel|
444
071b4f32272c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
  1907
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1908
	sel := someClass selectorAtMethod:self.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1909
	sel notNil ifTrue:[^ Array with:someClass with:sel]
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1910
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1911
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1912
     none found - sorry
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1913
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1914
    ^ nil
444
071b4f32272c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
  1915
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1916
    "typical situation: some well-known class"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1917
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1918
     |m|
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1919
     m := Object compiledMethodAt:#copy.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1920
     m who
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1921
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1922
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1923
    "untypical situation: an anonymous class"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1924
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1925
     |m cls|
444
071b4f32272c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
  1926
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1927
     Object 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1928
	subclass:#FunnyClass 
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1929
	instanceVariableNames:'foo'
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1930
	classVariableNames:''
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1931
	poolDictionaries:''
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1932
	category:'testing'.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1933
     cls := Smalltalk at:#FunnyClass.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1934
     Smalltalk removeClass:cls.
444
071b4f32272c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
  1935
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1936
     cls compile:'testMethod1:arg foo:=arg'.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1937
     cls compile:'testMethod2 ^ foo'.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1938
     m := cls compiledMethodAt:#testMethod1:.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1939
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1940
     m who
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1941
    "
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1942
!
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1943
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1944
wrapper
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1945
    "only for wrapped methods: return the wrapper.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1946
     Thats the WrapperMethod which contains myself."
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1947
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1948
    WrappedMethod allInstancesDo:[:m |
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1949
	m originalMethod == self ifTrue:[^ m].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1950
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1951
    ^ nil
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1952
! !
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  1953
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1954
!Method methodsFor:'trap methods'!
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  1955
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1956
makeInvalid
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1957
    "make the receiver an invalid method, which raises an invalidCodeObject
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1958
     signal when executed. This is not for public use - it is required for
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1959
     the objectFileLoader to invalidate methods whose code is unloaded."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1960
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1961
    |invldMethod|
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1962
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1963
    invldMethod := self class compiledMethodAt:#invalidCodeObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1964
    self code:invldMethod code.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1965
    self byteCode:invldMethod byteCode.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1966
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1967
    "Created: 17.9.1995 / 15:00:52 / claus"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1968
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1969
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1970
makeUncompiled
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1971
    "make the receiver an uncompiled method, which raises an invalidCodeObject
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1972
     signal when executed. This is not for public use - it is required for
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1973
     the compiler to invalidate methods which cannot be compiled due to errors
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1974
     after a class definition change (for example: instvars are no longer there)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1975
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1976
    |invldMethod|
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1977
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1978
    invldMethod := self class compiledMethodAt:#uncompiledCodeObject.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1979
    self code:invldMethod code.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1980
    self byteCode:invldMethod byteCode.
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1981
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1982
    "Created: 17.9.1995 / 15:01:14 / claus"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1983
! !
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1984
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1985
!Method class methodsFor:'documentation'!
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1986
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1987
version
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  1988
    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.77 1996-03-07 18:34:00 cg Exp $'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1989
! !
952
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1990
Method initialize!