Method.st
author Claus Gittinger <cg@exept.de>
Wed, 22 May 1996 16:43:43 +0200
changeset 1436 4eae8fd83654
parent 1293 02fb05148c98
child 1477 cbf97261a39c
permissions -rw-r--r--
checkin from browser
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
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    65
    [Instance variables:]
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    66
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    67
        source          <String>        the source itself (if sourcePosition isNil)
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    68
                                        or the fileName where the source is found
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
    69
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
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
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    72
        category        <Symbol>        the methods category
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
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
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    76
    [Class variables:]
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    77
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    78
        PrivateMethodSignal             raised on privacy violation (see docu)
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
    79
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    80
        LastFileReference               weak reference to the last sourceFile
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
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
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    84
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    85
    [author:]
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
    86
        Claus Gittinger
42
e33491f6f260 *** empty log message ***
claus
parents: 39
diff changeset
    87
"
176
48061f8659aa more queries
claus
parents: 159
diff changeset
    88
!
48061f8659aa more queries
claus
parents: 159
diff changeset
    89
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
    90
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
    91
"
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
    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
    93
    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
    94
    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
    95
    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
    96
    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
    97
    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
    98
    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
    99
    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
   100
"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   101
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   102
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   103
privacy 
48061f8659aa more queries
claus
parents: 159
diff changeset
   104
"
48061f8659aa more queries
claus
parents: 159
diff changeset
   105
    ST/X includes an EXPERIMENTAL implementation of method privacy.
48061f8659aa more queries
claus
parents: 159
diff changeset
   106
    Individual methods may be set to private or protected via the
48061f8659aa more queries
claus
parents: 159
diff changeset
   107
    #setPrivate and #setProtected messages. Also, categories may be
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
   108
    filedIn as a whole as private using #privateMethodsFor: or as
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
   109
    protected using #protectedMethodsFor: instead of the well known #methodsFor:.
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
   110
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   111
    The additional #publicMethodsFor: is for documentation purposes, and
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
   112
    is equivalent to #methodsFor: (also to support fileIn of ENVY methods).
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   113
48061f8659aa more queries
claus
parents: 159
diff changeset
   114
    Private methods may be executed only when called via a self or super-send
48061f8659aa more queries
claus
parents: 159
diff changeset
   115
    from the superclass, the class itself or subclasses.
415
claus
parents: 414
diff changeset
   116
    Protected methods may not be called from subclasses, i.e. they may only
claus
parents: 414
diff changeset
   117
    be called via self sends from within the current class.
claus
parents: 414
diff changeset
   118
    (i.e. private methods are less private than protected ones)
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   119
48061f8659aa more queries
claus
parents: 159
diff changeset
   120
    When such a situation arises, the VM (runtime system) will raise the
48061f8659aa more queries
claus
parents: 159
diff changeset
   121
    PrivateMethodSignal exception (if nonNil), which usually brings you into the
48061f8659aa more queries
claus
parents: 159
diff changeset
   122
    debugger.
48061f8659aa more queries
claus
parents: 159
diff changeset
   123
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
   124
    If PrivateMethodSignal is nil, the VM will not check for this, and
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   125
    execution is as usual. (you may want to nil-it for production code,
48061f8659aa more queries
claus
parents: 159
diff changeset
   126
    and leave it non nil during development).
48061f8659aa more queries
claus
parents: 159
diff changeset
   127
48061f8659aa more queries
claus
parents: 159
diff changeset
   128
    NOTICE: there is no (not yet ?) standard defined for method privacy,
48061f8659aa more queries
claus
parents: 159
diff changeset
   129
    however, the interface was designed to be somewhat ENVY compatible (from
48061f8659aa more queries
claus
parents: 159
diff changeset
   130
    what can be deduced by reading PD code).
48061f8659aa more queries
claus
parents: 159
diff changeset
   131
    Also, the usability of privacy is still to be tested.
415
claus
parents: 414
diff changeset
   132
    This interface, the implementation and the rules for when a privacy violation
claus
parents: 414
diff changeset
   133
    may change (in case of some ANSI standard being defined).
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
   134
    Be warned and send me suggestions & critics (constructive ;-)
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   135
"
42
e33491f6f260 *** empty log message ***
claus
parents: 39
diff changeset
   136
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   137
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   138
!Method class methodsFor:'initialization'!
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   139
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   140
initialize
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   141
    "create signals"
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   142
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   143
    PrivateMethodSignal isNil ifTrue:[
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   144
        "EXPERIMENTAL"
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   145
        PrivateMethodSignal := ExecutionErrorSignal newSignalMayProceed:true.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   146
        PrivateMethodSignal nameClass:self message:#privateMethodSignal.
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   147
        PrivateMethodSignal notifierString:'attempt to execute private/protected method'.
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   148
    ]
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   149
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   150
    "Modified: 22.4.1996 / 16:34:38 / cg"
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   151
! !
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
   152
345
claus
parents: 343
diff changeset
   153
!Method class methodsFor:'Signal constants'!
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   154
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   155
privateMethodSignal
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   156
    "return the signal raised when a private/protected method is called
48061f8659aa more queries
claus
parents: 159
diff changeset
   157
     by some other object (i.e. not a self- or super send)"
48061f8659aa more queries
claus
parents: 159
diff changeset
   158
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   159
    ^ PrivateMethodSignal
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   160
! !
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   161
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
   162
!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
   163
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
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
   165
    "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
   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 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
   168
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
    "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
   170
    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
   171
	"
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
	 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
   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 := 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
   175
	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
   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
	"
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
	 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
   179
	 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
   180
	"
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
	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
   182
	    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
   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
	^ 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
   185
    ].
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
    "
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
     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
   188
    "
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
    ^ 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
   190
!
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
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
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
   193
    "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
   194
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
    |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
   196
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
    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
   198
    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
   199
    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
   200
    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
   201
    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
   202
    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
   203
    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
   204
	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
   205
    ].
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
    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
   207
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
    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
   209
	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
   210
    ].
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
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
    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
   213
    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
   214
    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
   215
    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
   216
    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
   217
    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
   218
	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
   219
    ] 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
   220
	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
   221
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   222
    ^ 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
   223
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   224
    "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
   225
! !
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   226
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   227
!Method class methodsFor:'queries'!
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   228
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   229
isBuiltInClass
1264
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1260
diff changeset
   230
    "return true if this class is known by the run-time-system.
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1260
diff changeset
   231
     Here, true is returned for myself, false for subclasses."
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   232
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   233
    ^ self == Method
1264
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1260
diff changeset
   234
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1260
diff changeset
   235
    "Modified: 23.4.1996 / 15:59:50 / cg"
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   236
!
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   237
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   238
maxNumberOfArguments
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   239
    "this limit will be removed in one of the next versions ..."
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   240
423
claus
parents: 421
diff changeset
   241
    ^ 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
   242
!
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   243
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   244
methodPrivacySupported
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   245
    "return true, if the system was compiled to support methodPrivacy.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   246
     You should not depend on that feature being available."
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   247
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   248
%{  /* NOCONTEXT */
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   249
#if defined(F_PRIVATE) || defined(F_CLASSPRIVATE)
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   250
    RETURN (true);
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   251
#else
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   252
    RETURN (false);
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   253
#endif
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   254
%}
3
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   255
! !
24d81bf47225 *** empty log message ***
claus
parents: 2
diff changeset
   256
957
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   257
!Method class methodsFor:'special'!
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   258
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   259
flushSourceStreamCache
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   260
    LastSourceFileName := nil
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   261
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   262
    "Created: 9.2.1996 / 19:05:28 / cg"
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   263
! !
b405ae99d437 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 952
diff changeset
   264
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   265
!Method methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   266
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
   267
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
   268
    "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
   269
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
   270
    ^ category
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   271
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   272
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
   273
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
   274
    "set the methods category"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   275
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
   276
    category := aStringOrSymbol asSymbol
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   277
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   278
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   279
clearCalledFlag
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   280
    "mark the method as never called.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   281
     The called flag will be set by the interpreter whenever a method
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   282
     is called for the very first time, to support coverage tests.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   283
     This is EXPERIMENTAL, nonStandard and not yet fully implemented."
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   284
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   285
%{  /* NOCONTEXT */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   286
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   287
#ifdef F_CALLED
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   288
    int f = __intVal(__INST(flags));
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   289
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   290
    f &= ~F_CALLED;
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   291
    __INST(flags) = __MKSMALLINT(f);
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   292
#endif
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   293
%}
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   294
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   295
39
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   296
comment
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   297
    "return the methods comment.
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   298
     This is done by searching for and returning the first comment
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   299
     from the methods source (excluding any double-quotes). 
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   300
     Returns nil if there is no comment (or source is not available)."
39
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   301
1236
5c9bc68e3c71 use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
   302
    |src comments parser|
39
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   303
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   304
    src := self source.
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   305
    src isNil ifTrue:[^ nil].
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   306
1236
5c9bc68e3c71 use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
   307
    parser := Parser for:src in:nil.
5c9bc68e3c71 use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
   308
    parser ignoreErrors; ignoreWarnings; saveComments:true.
5c9bc68e3c71 use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
   309
    parser parseMethodSpec.
5c9bc68e3c71 use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
   310
    comments := parser comments.
5c9bc68e3c71 use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
   311
    comments size == 0 ifTrue:[^ nil].
1258
da1ef936ecdd commentary
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
   312
    (comments first endsWith:'}') ifTrue:[
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   313
        ^ comments at:2 ifAbsent:nil
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   314
    ].
1236
5c9bc68e3c71 use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
   315
    ^ comments first.
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   316
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   317
    "
1236
5c9bc68e3c71 use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
   318
     (Method compiledMethodAt:#comment) comment  
1254
48c2748b5197 commentary
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
   319
     (Object class compiledMethodAt:#infoPrinting:) comment  
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   320
    "
1236
5c9bc68e3c71 use new scanner feature to extract comment
Claus Gittinger <cg@exept.de>
parents: 1194
diff changeset
   321
1258
da1ef936ecdd commentary
Claus Gittinger <cg@exept.de>
parents: 1254
diff changeset
   322
    "Modified: 22.4.1996 / 19:53:58 / cg"
39
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   323
!
bcf183a31bbb *** empty log message ***
claus
parents: 13
diff changeset
   324
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   325
flags
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   326
    "return the flags (number of method variables, stacksize etc.).
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   327
     Dont depend on the values in the flag field - its interpretations
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   328
     may change without notice."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   329
a27a279701f8 Initial revision
claus
parents:
diff changeset
   330
    ^ flags
a27a279701f8 Initial revision
claus
parents:
diff changeset
   331
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   332
    "Modified: 8.3.1996 / 13:20:48 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   333
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   334
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
   335
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
   336
    ^ source
414
claus
parents: 400
diff changeset
   337
!
claus
parents: 400
diff changeset
   338
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   339
numberOfMethodArgs
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   340
    "return the number of arguments, the method expects." 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   341
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   342
%{  /* NOCONTEXT */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   343
    /* made this a primitive to get define in stc.h */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   344
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   345
#ifdef F_NARGS
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   346
    RETURN (__MKSMALLINT((__intVal(__INST(flags)) & F_NARGS) >> F_NARGSHIFT));
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   347
#endif
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   348
%}
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   349
.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   350
    "
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   351
     The old implementation simply counted the arguments from
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   352
     the methods source - new versions include this information
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   353
     in the flag instVar, for more security in #perform:
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   354
    "
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   355
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   356
    ^ self methodArgNames size
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   357
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   358
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   359
numberOfMethodVars
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   360
    "return the number of method local variables. 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   361
     Do not depend on the returned value - future optimizations
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   362
     may change things here (i.e. when moving block-locals into
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   363
     surrounding method for inlining).
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   364
     - for debugging only."
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   365
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   366
%{  /* NOCONTEXT */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   367
    /* made this a primitive to get define in stc.h */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   368
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   369
    RETURN (__MKSMALLINT((__intVal(__INST(flags)) & F_NVARS) >> F_NVARSHIFT));
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   370
%}
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   371
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   372
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   373
package
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   374
    "return the package-symbol"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   375
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   376
    ^ package
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   377
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   378
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   379
package:aSymbol
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   380
    "set the package-symbol"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   381
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   382
    package := aSymbol
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   383
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   384
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   385
source
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   386
    "return the sourcestring for the receiver"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   387
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   388
    |aStream fileName junk w myClass mgr className|
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   389
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   390
    "
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   391
     if sourcePosition is nonNil, its the fileName and
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   392
     sourcePosition is the offset.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   393
     Otherwise, source is the real source
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   394
    "
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   395
    sourcePosition isNil ifTrue:[^ source].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   396
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   397
    source notNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   398
"/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   399
"/ original (old) code:
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   400
"/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   401
"/        aStream := Smalltalk systemFileStreamFor:('source/' , source).
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   402
"/        aStream notNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   403
"/            aStream position:sourcePosition.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   404
"/            junk := aStream nextChunk.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   405
"/            aStream close
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   406
"/        ]
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   407
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   408
        "/ keep the last source file open, because open/close
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   409
        "/ operations maybe slow on NFS-mounted file systems.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   410
        "/ Since the reference to the file is weak, it will be closed
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   411
        "/ automatically if the file is not referenced for a while. 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   412
        "/ Neat trick.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   413
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   414
        LastSourceFileName = source ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   415
            aStream := LastFileReference at:1.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   416
        ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   417
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   418
        aStream isNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   419
            "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   420
            "/ if there is no SourceManager, look in standard places
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   421
            "/ first
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   422
            "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   423
            (mgr := Smalltalk at:#SourceCodeManager) isNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   424
                fileName := Smalltalk getSourceFileName:source.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   425
                fileName notNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   426
                    aStream := fileName asFilename readStream.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   427
                ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   428
            ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   429
            aStream isNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   430
                "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   431
                "/ nope - ask my class for the source (this also invokes the SCMgr)
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   432
                "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   433
                w := self who.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   434
                w notNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   435
                    myClass := w at:1.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   436
                    aStream := myClass sourceStreamFor:source.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   437
                ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   438
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   439
                aStream isNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   440
                    "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   441
                    "/ nope - look in standard places 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   442
                    "/ (if there is a source-code manager - otherwise, we already did that)
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   443
                    "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   444
                    mgr notNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   445
                        fileName := Smalltalk getSourceFileName:source.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   446
                        fileName notNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   447
                            aStream := fileName asFilename readStream.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   448
                        ]
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   449
                    ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   450
                    "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   451
                    "/ final chance: try current directory
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   452
                    "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   453
                    aStream isNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   454
                        aStream := source asFilename readStream.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   455
                    ]
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   456
                ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   457
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   458
                (aStream isNil and:[w isNil and:[source notNil]]) ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   459
                    "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   460
                    "/ mhmh - seems to be a method which used to be in some
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   461
                    "/ class, but has been overwritten by another or removed.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   462
                    "/ (i.e. it has no containing class anyMore)
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   463
                    "/ try to guess the class from the sourceFileName.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   464
                    "/ and retry.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   465
                    "/
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   466
                    className := Smalltalk classNameForFile:source.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   467
                    className knownAsSymbol ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   468
                        myClass := Smalltalk at:className asSymbol ifAbsent:nil.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   469
                        myClass notNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   470
                            aStream := myClass sourceStreamFor:source.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   471
                        ]
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   472
                    ]
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   473
                ]                
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   474
            ]
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   475
        ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   476
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   477
        aStream notNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   478
            aStream position:sourcePosition.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   479
            junk := aStream nextChunk.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   480
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   481
            "
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   482
             keep a weak reference - it may be needed again soon ...
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   483
            "
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   484
            LastFileReference isNil ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   485
                LastFileReference := WeakArray new:1
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   486
            ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   487
            LastFileReference at:1 put:aStream.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   488
            LastSourceFileName := source
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   489
        ]
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   490
    ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   491
    ^ junk
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   492
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   493
    "Modified: 9.2.1996 / 19:09:18 / cg"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   494
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   495
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   496
source:aString
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   497
    "set the methods sourcestring"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   498
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   499
    source := aString.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   500
    sourcePosition := nil
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   501
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   502
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   503
sourceFilename
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   504
    "return the sourcefilename if source is extern; nil otherwise"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   505
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   506
    sourcePosition notNil ifTrue:[^ source].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   507
    ^ nil
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   508
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   509
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   510
sourceFilename:aFileName position:aNumber
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   511
    "set the methods sourcefile/position"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   512
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   513
    source := aFileName.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   514
    sourcePosition := aNumber
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   515
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   516
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   517
sourcePosition
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   518
    "return the sourceposition if source is extern; nil otherwise"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   519
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   520
    ^ sourcePosition
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   521
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   522
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   523
stackSize
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   524
    "return the number of temporaries needed as stack in the context. 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   525
     Do not depend on the returned value - future optimizations
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   526
     may change things here.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   527
     - for debugging only."
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   528
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   529
%{  /* NOCONTEXT */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   530
    /* made this a primitive to get define in stc.h */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   531
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   532
    RETURN (__MKSMALLINT((__intVal(__INST(flags)) & F_NSTACK) >> F_NSTACKSHIFT));
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   533
%}
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   534
! !
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   535
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   536
!Method methodsFor:'accessing-visibility'!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
   537
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
   538
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
   539
    "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
   540
     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
   541
     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
   542
     it in its message lookup.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   543
     (i.e. setting a method to #ignored, and sending that selector,
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   544
      leads to either the superclasses implementation to be called, 
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   545
      or a doesNotUnderstand exception to be raised)
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   546
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
   547
     Notice: this is a nonstandard feature, not supported
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   548
     by other smalltalk implementations and not specified in the ANSI spec.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   549
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   550
     This is EXPERIMENTAL - and being evaluated for usability.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   551
     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
   552
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   553
%{  /* 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
   554
#if defined(F_IGNORED) && defined(M_PRIVACY)
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   555
    int f = __intVal(__INST(flags));
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   556
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
   557
    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
   558
	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
   559
    }
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   560
#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
   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
    ^ false
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   563
!
48061f8659aa more queries
claus
parents: 159
diff changeset
   564
48061f8659aa more queries
claus
parents: 159
diff changeset
   565
isPrivate
48061f8659aa more queries
claus
parents: 159
diff changeset
   566
    "return true, if this is a private method.
48061f8659aa more queries
claus
parents: 159
diff changeset
   567
     Execution of private methods is only allowed via self/super sends
48061f8659aa more queries
claus
parents: 159
diff changeset
   568
     from superclasses, the class itself or subclasses.
48061f8659aa more queries
claus
parents: 159
diff changeset
   569
     If a private method is called by some other class, a runtime
48061f8659aa more queries
claus
parents: 159
diff changeset
   570
     error (PrivateMethodSignal) is raised.
48061f8659aa more queries
claus
parents: 159
diff changeset
   571
     Notice: method privacy is a nonstandard feature, not supported
48061f8659aa more queries
claus
parents: 159
diff changeset
   572
     by other smalltalk implementations and not specified in the ANSI spec.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   573
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   574
     This is EXPERIMENTAL - and being evaluated for usability.
48061f8659aa more queries
claus
parents: 159
diff changeset
   575
     It may change or even vanish (if it shows to be not useful)."
48061f8659aa more queries
claus
parents: 159
diff changeset
   576
48061f8659aa more queries
claus
parents: 159
diff changeset
   577
%{  /* NOCONTEXT */
48061f8659aa more queries
claus
parents: 159
diff changeset
   578
    /* I made this a primitive to get the define constant from stc.h */
48061f8659aa more queries
claus
parents: 159
diff changeset
   579
748
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   580
#if defined(F_PRIVATE) && defined(M_PRIVACY)
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   581
    int f = __intVal(__INST(flags));
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   582
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   583
    if ((f & M_PRIVACY) == F_PRIVATE) {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   584
	RETURN (true);
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   585
    }
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   586
#endif
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   587
%}.
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   588
    ^ false
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   589
!
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   590
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   591
isProtected
48061f8659aa more queries
claus
parents: 159
diff changeset
   592
    "return true, if this is a protected method.
48061f8659aa more queries
claus
parents: 159
diff changeset
   593
     Execution of protected methods is only allowed via self sends
48061f8659aa more queries
claus
parents: 159
diff changeset
   594
     from superclasses or the class itself.
48061f8659aa more queries
claus
parents: 159
diff changeset
   595
     If a protected method is called by some other class, a runtime
48061f8659aa more queries
claus
parents: 159
diff changeset
   596
     error (PrivateMethodSignal) is raised.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   597
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   598
     Notice: method privacy is a nonstandard feature, not supported
48061f8659aa more queries
claus
parents: 159
diff changeset
   599
     by other smalltalk implementations and not specified in the ANSI spec.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   600
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   601
     This is EXPERIMENTAL - and being evaluated for usability.
48061f8659aa more queries
claus
parents: 159
diff changeset
   602
     It may change or even vanish (if it shows to be not useful)."
48061f8659aa more queries
claus
parents: 159
diff changeset
   603
48061f8659aa more queries
claus
parents: 159
diff changeset
   604
%{  /* NOCONTEXT */
48061f8659aa more queries
claus
parents: 159
diff changeset
   605
    /* I made this a primitive to get the define constant from stc.h */
48061f8659aa more queries
claus
parents: 159
diff changeset
   606
748
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   607
#if defined(F_CLASSPRIVATE) && defined(M_PRIVACY)
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   608
    int f = __intVal(__INST(flags));
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   609
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   610
    if ((f & M_PRIVACY) == F_CLASSPRIVATE) {
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   611
	RETURN (true);
48061f8659aa more queries
claus
parents: 159
diff changeset
   612
    }
48061f8659aa more queries
claus
parents: 159
diff changeset
   613
#endif
48061f8659aa more queries
claus
parents: 159
diff changeset
   614
%}.
48061f8659aa more queries
claus
parents: 159
diff changeset
   615
    ^ false
48061f8659aa more queries
claus
parents: 159
diff changeset
   616
!
48061f8659aa more queries
claus
parents: 159
diff changeset
   617
48061f8659aa more queries
claus
parents: 159
diff changeset
   618
isPublic
48061f8659aa more queries
claus
parents: 159
diff changeset
   619
    "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
   620
     This is the default and how other smalltalk implementations treat all methods.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   621
360
claus
parents: 350
diff changeset
   622
     Notice: method privacy is a nonstandard feature, not supported
claus
parents: 350
diff changeset
   623
     by other smalltalk implementations and not specified in the ANSI spec.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   624
360
claus
parents: 350
diff changeset
   625
     This is EXPERIMENTAL - and being evaluated for usability.
claus
parents: 350
diff changeset
   626
     It may change or even vanish (if it shows to be not useful)."
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   627
48061f8659aa more queries
claus
parents: 159
diff changeset
   628
%{  /* NOCONTEXT */
48061f8659aa more queries
claus
parents: 159
diff changeset
   629
    /* I made this a primitive to get the define constant from stc.h */
48061f8659aa more queries
claus
parents: 159
diff changeset
   630
748
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   631
#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
   632
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   633
    int f = __intVal(__INST(flags));
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   634
# ifdef F_PRIVATE
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   635
    if ((f & M_PRIVACY) == F_PRIVATE) {
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   636
	RETURN (false);
48061f8659aa more queries
claus
parents: 159
diff changeset
   637
    }
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   638
# endif
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   639
# ifdef F_CLASSPRIVATE
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   640
    if ((f & M_PRIVACY) == F_CLASSPRIVATE) {
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   641
	RETURN (false);
48061f8659aa more queries
claus
parents: 159
diff changeset
   642
    }
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   643
# endif
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   644
# ifdef F_IGNORED
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   645
    if ((f & M_PRIVACY) == F_IGNORED) {
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   646
	RETURN (false);
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   647
    }
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   648
# endif
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   649
#endif
48061f8659aa more queries
claus
parents: 159
diff changeset
   650
%}.
48061f8659aa more queries
claus
parents: 159
diff changeset
   651
    ^ true
48061f8659aa more queries
claus
parents: 159
diff changeset
   652
!
48061f8659aa more queries
claus
parents: 159
diff changeset
   653
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   654
isRestricted
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   655
    "return the flag bit stating that this method is restricted.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   656
     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
   657
     'trap restricted mode' (-->ObjectMemory) otherise a runtime 
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   658
     error (PrivateMethodSignal) is raised.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   659
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   660
     Notice: method restriction is a nonstandard feature, not supported
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   661
     by other smalltalk implementations and not specified in the ANSI spec.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   662
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   663
     This is EXPERIMENTAL - and being evaluated for usability.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   664
     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
   665
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   666
%{  /* NOCONTEXT */
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   667
#ifdef F_RESTRICTED
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   668
    int f = __intVal(__INST(flags));
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   669
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   670
    if (f & F_RESTRICTED) {
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   671
	RETURN (true);
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   672
    }
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   673
#endif
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   674
%}.
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   675
    ^ 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
   676
!
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
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
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
   679
    "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
   680
     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
   681
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
     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
   683
     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
   684
     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
   685
     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
   686
     (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
   687
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
     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
   689
     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
   690
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
    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
   692
    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
   693
    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
   694
    ^ #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
   695
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
    "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
   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
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
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
   700
    "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
   701
     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
   702
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
     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
   704
     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
   705
     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
   706
     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
   707
     (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
   708
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
     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
   710
     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
   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
    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
   713
	"/
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
	"/ 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
   715
	"/
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
	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
   717
	    ^ 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
   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
	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
   720
    ] 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
   721
	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
   722
	    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
   723
	] 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
   724
	    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
   725
		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
   726
	    ] 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
   727
		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
   728
		    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
   729
		]
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
	]
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
    ].
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
    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
   734
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
    "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
   736
!
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   737
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   738
restricted:aBoolean
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   739
    "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
   740
     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
   741
     'trap restricted mode' (-->ObjectMemory) otherise a runtime
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   742
     error (PrivateMethodSignal) is raised.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   743
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   744
     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
   745
     by other smalltalk implementations and not specified in the ANSI spec.
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   746
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   747
     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
   748
     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
   749
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   750
%{  /* NOCONTEXT */
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   751
    /* 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
   752
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   753
#ifdef F_RESTRICTED
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   754
    int f = __intVal(__INST(flags));
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   755
    int old;
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   756
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   757
    old = f;
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   758
    if (aBoolean == true) 
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   759
	f |= F_RESTRICTED;
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   760
    else
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   761
	f &= ~F_RESTRICTED;
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   762
    __INST(flags) = __MKSMALLINT(f);
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   763
    if (old & F_RESTRICTED)
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   764
	RETURN(true);
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   765
#endif
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   766
%}.
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   767
    ^ false
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   768
747
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   769
    "
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   770
     (ObjectMemory class compiledMethodAt:#compressingGarbageCollect) restricted:true
ea3b6f7fd7ce added ignoredMethods
Claus Gittinger <cg@exept.de>
parents: 737
diff changeset
   771
    "
532
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   772
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   773
    "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
   774
!
2511c99de912 New code to trap restricted (RT) methods.
Stefan Vogel <sv@exept.de>
parents: 530
diff changeset
   775
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
   776
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
   777
    "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
   778
     (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
   779
      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
   780
      or a doesNotUnderstand exception to be raised)
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
   781
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
   782
     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
   783
     by other smalltalk implementations and not specified in the ANSI spec.
49
f1c2d75f2eb6 *** empty log message ***
claus
parents: 44
diff changeset
   784
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
   785
     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
   786
     It may change or even vanish (if it shows to be not useful)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   787
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
   788
%{  /* NOCONTEXT */
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   789
    int f = __intVal(__INST(flags));
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   790
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
   791
#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
   792
    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
   793
#endif
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   794
    __INST(flags) = __MKSMALLINT(f);
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
   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
!
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
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
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
   799
    "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
   800
     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
   801
     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
   802
     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
   803
     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
   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
     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
   806
     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
   807
     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
   808
     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
   809
     (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
   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
     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
   812
     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
   813
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
%{  /* 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
   815
    /* 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
   816
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
#if defined(F_PRIVATE) && defined(M_PRIVACY)
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   818
    int f = __intVal(__INST(flags));
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
   819
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
    f = (f & ~M_PRIVACY) | F_PRIVATE;
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   821
    __INST(flags) = __MKSMALLINT(f);
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
   822
#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
   823
%}
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
!
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
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
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
   827
    "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
   828
     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
   829
     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
   830
     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
   831
     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
   832
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
     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
   834
     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
   835
     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
   836
     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
   837
     (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
   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
     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
   840
     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
   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
%{  /* 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
   843
    /* 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
   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
#if defined(F_CLASSPRIVATE) && defined(M_PRIVACY)
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   846
    int f = __intVal(__INST(flags));
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
   847
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   848
    f = (f & ~M_PRIVACY) | F_CLASSPRIVATE;
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   849
    __INST(flags) = __MKSMALLINT(f);
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
   850
#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
   851
%}
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
!
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
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
   855
    "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
   856
     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
   857
     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
   858
     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
   859
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
     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
   861
     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
   862
     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
   863
     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
   864
     (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
   865
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
     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
   867
     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
   868
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
%{  /* 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
   870
    /* 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
   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
#ifdef M_PRIVACY
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   873
    int f = __intVal(__INST(flags));
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
   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
    f = f & ~M_PRIVACY;
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
   876
    __INST(flags) = __MKSMALLINT(f);
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
   877
#endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   878
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
   879
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   880
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
!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
   882
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   883
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
   884
    "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
   885
     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
   886
     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
   887
     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
   888
     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
   889
     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
   890
     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
   891
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   892
    |doMachineCode mthd|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   893
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
   894
    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
   895
	"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   896
	 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
   897
	"
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   898
	^ 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
   899
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   900
    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
   901
    [
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   902
	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
   903
    ] 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
   904
	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
   905
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   906
    ^ mthd
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
   907
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
   908
    "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
   909
    "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
   910
!
306
365e65400c93 *** empty log message ***
claus
parents: 302
diff changeset
   911
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
   912
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
   913
    "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
   914
     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
   915
     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
   916
     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
   917
     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
   918
     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
   919
     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
   920
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   921
    |temporaryMethod cls sourceString silent lazy|
306
365e65400c93 *** empty log message ***
claus
parents: 302
diff changeset
   922
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
   923
    byteCode notNil ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   924
        "
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   925
         is already a bytecoded method
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   926
        "
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   927
        ^ 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
   928
    ].
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
    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
   931
    cls isNil ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   932
        'METHOD: cannot generate bytecode (no class for compilation)' errorPrintNL.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   933
        ^ 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
   934
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   935
    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
   936
    sourceString isNil ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   937
        'METHOD: cannot generate bytecode (no source for compilation)' errorPrintNL.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   938
        ^ nil
306
365e65400c93 *** empty log message ***
claus
parents: 302
diff changeset
   939
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   940
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
   941
    "
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
   942
     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
   943
     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
   944
     dont want a lazy method ...
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   945
    "
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
   946
    Class withoutUpdatingChangesDo:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   947
        silent := Smalltalk silentLoading:true.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   948
        lazy := Compiler compileLazy:false.
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   949
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   950
        [
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   951
            |compiler|
176
48061f8659aa more queries
claus
parents: 159
diff changeset
   952
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   953
            compiler := cls compilerClass.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   954
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   955
            "/
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   956
            "/ kludge - have to make ST/X's compiler protocol
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   957
            "/ be compatible to ST-80's
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   958
            "/
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   959
            (compiler respondsTo:#compile:forClass:inCategory:notifying:install:skipIfSame:)
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   960
            ifTrue:[
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   961
                temporaryMethod := compiler
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   962
                                     compile:sourceString
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   963
                                     forClass:cls
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   964
                                     inCategory:(self category)
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   965
                                     notifying:nil
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   966
                                     install:false.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   967
            ] ifFalse:[
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   968
                temporaryMethod := compiler new
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   969
                                     compile:sourceString 
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   970
                                     in:cls 
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   971
                                     notifying:nil 
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   972
                                     ifFail:nil
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   973
            ].
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   974
        ] valueNowOrOnUnwindDo:[
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   975
            Compiler compileLazy:lazy.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   976
            Smalltalk silentLoading:silent.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   977
        ]
463
447ead9f870c be silent on transcript when parsing for args, vars and primitiveCode
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
   978
    ].
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
   979
    (temporaryMethod isNil or:[temporaryMethod == #Error]) ifTrue:[
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   980
        'METHOD: cannot generate bytecode (contains primitive code or error)' errorPrintNL.
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   981
        ^ 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
   982
    ].
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
   983
    "
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
   984
     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
   985
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
   986
    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
   987
    ^ temporaryMethod
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   988
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
   989
    "Created: 24.10.1995 / 14:02:30 / cg"
1087
6cb00ecfbc6d nicer message
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
   990
    "Modified: 7.3.1996 / 19:19:12 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   991
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   992
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
   993
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
   994
    "tell the newly restored Font about restoration"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   995
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
   996
    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
   997
	"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
   998
	^ self
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   999
    ].
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1000
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
  1001
    ^ super readBinaryContentsFrom: stream manager: manager
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1002
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1003
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
  1004
storeBinaryDefinitionOn:stream manager:manager
1260
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1005
    "store the receiver in a binary format on stream.
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1006
     This is an internal interface for binary storage mechanism.
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1007
     only store bytecode-methods - machinecode methods are stored
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
  1008
     as class/selector pair and a lookup is done when restored.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1009
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
     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
  1011
     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
  1012
     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
  1013
     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
  1014
     method does not contain primitive code."
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1015
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
  1016
    |storedMethod who|
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1017
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
  1018
    byteCode isNil ifTrue:[
1260
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1019
        self code notNil ifTrue:[
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1020
            (who := self who) notNil ifTrue:[
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1021
                "
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1022
                 machine code only - assume its a built-in method,
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1023
                 and store the class/selector information.
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1024
                 The restored method may not be exactly the same ...
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1025
                "
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1026
                manager putIdOfClass:(self class) on:stream.
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1027
                stream nextPutByte:0.   "means: built-in method" 
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1028
                manager putIdOf:(who at:1) on:stream.
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1029
                manager putIdOf:(who at:2) on:stream.
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1030
                ^ self
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1031
            ]
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1032
        ].
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1033
1260
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1034
        storedMethod := self asByteCodeMethod.
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1035
        storedMethod isNil ifTrue:[
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1036
            self error:'store of built-in method failed'.
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1037
            ^ nil
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1038
        ].
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1039
        ^ storedMethod storeBinaryDefinitionOn:stream manager:manager
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
  1040
    ].
93
e31220cb391f *** empty log message ***
claus
parents: 88
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
    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
  1043
    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
  1044
    self storeBinaryDefinitionBodyOn:stream manager:manager
1260
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1045
2a8ba44e8957 commentary
Claus Gittinger <cg@exept.de>
parents: 1258
diff changeset
  1046
    "Modified: 23.4.1996 / 09:31:05 / cg"
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1047
!
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1048
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
  1049
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
  1050
    "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
  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
    |m code srcPos|
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1053
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
  1054
    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
  1055
    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
  1056
    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
  1057
	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
  1058
	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
  1059
	    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
  1060
	] 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
  1061
	    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
  1062
	]
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
    ] 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
  1064
	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
  1065
	code := byteCode
391
claus
parents: 384
diff changeset
  1066
    ].
362
claus
parents: 360
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
    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
  1069
    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
  1070
    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
  1071
	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
  1072
	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
  1073
	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
  1074
    ] 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
  1075
	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
  1076
	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
  1077
	    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
  1078
	] 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
  1079
	    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
  1080
	].
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
	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
  1082
	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
  1083
	    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
  1084
	].
391
claus
parents: 384
diff changeset
  1085
    ].
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
  1086
    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
  1087
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
    "Created: 16.1.1996 / 14:41:45 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1089
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1090
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
  1091
!Method methodsFor:'copying'!
438
claus
parents: 423
diff changeset
  1092
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
  1093
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
  1094
    "redefined to change source ref into a real string"
438
claus
parents: 423
diff changeset
  1095
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
  1096
    |aCopy|
438
claus
parents: 423
diff changeset
  1097
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
  1098
    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
  1099
    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
  1100
	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
  1101
    ].
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
    ^ aCopy
438
claus
parents: 423
diff changeset
  1103
! !
claus
parents: 423
diff changeset
  1104
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1105
!Method methodsFor:'error handling'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1106
328
claus
parents: 326
diff changeset
  1107
invalidCodeObject
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1108
    "this method is triggered by the interpreter when a nil or non method
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1109
     is about to be executed.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1110
     In this case, the VM sends this to the bad method (the receiver).
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1111
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1112
     Also, the Compiler creates methods with their code/bytecode set to
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1113
     this method if - after a class change - a method cannot be compiled
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1114
     and is therefore no longer executable (for example, after an instvar
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1115
     has been removed, and a method still tries to access this instvar)
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1116
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1117
     Thus, we arrive here, when playing around in a classes methodArray,
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1118
     or compiler/runtime system is broken :-(, 
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1119
     or you ignore the error messages during some recompile."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1120
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1121
    ^ InvalidCodeSignal
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1122
	raiseRequestWith:self
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1123
	errorString:'invalid method - not executable'.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1124
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1125
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1126
privateMethodCalled
980
0ab2f56ecfc7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 957
diff changeset
  1127
    "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
  1128
360
claus
parents: 350
diff changeset
  1129
     If you continue in the debugger, the method will be called,
415
claus
parents: 414
diff changeset
  1130
     and further privacy exceptions will NOT be reported at this call location, 
360
claus
parents: 350
diff changeset
  1131
     until any new method is compiled, or the privacy of any method changes,
claus
parents: 350
diff changeset
  1132
     or the caches are flushed.
claus
parents: 350
diff changeset
  1133
     (the reason is that after the continue, the method is enterred into the
claus
parents: 350
diff changeset
  1134
      calling cache, for which method privacy is not checked.
claus
parents: 350
diff changeset
  1135
      Any of the above actions flushes this cache and a privacy check
claus
parents: 350
diff changeset
  1136
      is performed again.)
claus
parents: 350
diff changeset
  1137
     Future versions may not enter private methods into the cache, to fix this
claus
parents: 350
diff changeset
  1138
     (unobvious) behavior. However, then you will get an exception for EVERY
claus
parents: 350
diff changeset
  1139
     call to a private method ...
claus
parents: 350
diff changeset
  1140
claus
parents: 350
diff changeset
  1141
     Notice: method privacy is a nonstandard feature, not supported
claus
parents: 350
diff changeset
  1142
     by other smalltalk implementations and not specified in the ANSI spec.
claus
parents: 350
diff changeset
  1143
     This is EXPERIMENTAL - and being evaluated for usability.
claus
parents: 350
diff changeset
  1144
     It may change or even vanish (if it shows to be not useful)."
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1145
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  1146
    ^ 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
  1147
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1148
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1149
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
  1150
    "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
  1151
     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
  1152
     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
  1153
     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
  1154
     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
  1155
     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
  1156
     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
  1157
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1158
    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
  1159
    ^ 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
  1160
	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
  1161
	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
  1162
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1163
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1164
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
  1165
    "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
  1166
     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
  1167
     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
  1168
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1169
    ^ 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
  1170
	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
  1171
	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
  1172
		     ' args while ' , self numberOfMethodArgs printString , ' where expected')
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1173
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1174
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1175
!Method methodsFor:'executing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1176
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1177
valueWithReceiver:anObject arguments:argArray
2
claus
parents: 1
diff changeset
  1178
    "low level call of a methods code - BIG DANGER ALERT.
claus
parents: 1
diff changeset
  1179
     Perform the receiver-method on anObject as receiver and argArray as
claus
parents: 1
diff changeset
  1180
     arguments. This does NO message lookup at all and mimics a
claus
parents: 1
diff changeset
  1181
     traditional function call.
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1182
     This method is provided for debugging- and breakpoint-support 
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1183
     (replacing a method by a stub and recalling the original), or to implement
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1184
     experimental MI implementations - it is not for general use. 
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1185
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1186
     The receiver must be a method compiled in anObjects class or one of its 
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1187
     superclasses and also, the number of arguments given must match the methods
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1188
     expectations -
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1189
     - otherwise strange things (and also strange crashes) can occur.
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1190
     The system is NOT always detecting a wrong method/receiver combination.
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1191
     YOU HAVE BEEN WARNED."
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1192
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1193
    ^ self valueWithReceiver:anObject arguments:argArray selector:nil search:nil
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1194
!
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1195
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1196
valueWithReceiver:anObject arguments:argArray selector:aSymbol
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1197
    "low level call of a methods code - BIG DANGER ALERT.
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1198
     Perform the receiver-method on anObject as receiver and argArray as
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1199
     arguments. This does NO message lookup at all and mimics a
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1200
     traditional function call.
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1201
     This method is provided for debugging- and breakpoint-support 
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1202
     (replacing a method by a stub and recalling the original), or to implement
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1203
     experimental MI implementations - it is not for general use. 
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1204
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1205
     The receiver must be a method compiled in anObjects class or one of its 
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1206
     superclasses and also, the number of arguments given must match the methods
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1207
     expectations -
44
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1208
     - otherwise strange things (and also strange crashes) can occur.
b262907c93ea *** empty log message ***
claus
parents: 42
diff changeset
  1209
     The system is NOT always detecting a wrong method/receiver combination.
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1210
     YOU HAVE BEEN WARNED."
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1211
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1212
    ^ self valueWithReceiver:anObject 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1213
		   arguments:argArray 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1214
		    selector:aSymbol 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1215
		      search:nil
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1216
		      sender:nil
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1217
!
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1218
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1219
valueWithReceiver:anObject arguments:argArray selector:aSymbol search:aClass
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1220
    "low level call of a methods code - BIG DANGER ALERT.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1221
     Perform the receiver-method on anObject as receiver and argArray as
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1222
     arguments. This does NO message lookup at all and mimics a
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1223
     traditional function call.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1224
     This method is provided for debugging- and breakpoint-support 
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1225
     (replacing a method by a stub and recalling the original), or to implement
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1226
     experimental MI implementations - it is not for general use. 
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1227
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1228
     The receiver must be a method compiled in anObjects class or one of its 
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1229
     superclasses and also, the number of arguments given must match the methods
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1230
     expectations -
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1231
     - otherwise strange things (and also strange crashes) can occur.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1232
     The system is NOT always detecting a wrong method/receiver combination.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1233
     YOU HAVE BEEN WARNED."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1234
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1235
    ^ self valueWithReceiver:anObject 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1236
		   arguments:argArray 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1237
		    selector:aSymbol 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1238
		      search:nil
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1239
		      sender:nil
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1240
!
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1241
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1242
valueWithReceiver:anObject arguments:argArray selector:aSymbol search:aClass sender:virtualSender
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1243
    "low level call of a methods code - BIG DANGER ALERT.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1244
     Perform the receiver-method on anObject as receiver and argArray as
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1245
     arguments. This does NO message lookup at all and mimics a
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1246
     traditional function call.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1247
     This method is provided for debugging- and breakpoint-support 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1248
     (replacing a method by a stub and recalling the original), or to implement
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1249
     experimental MI implementations - it is not for general use. 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1250
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1251
     The receiver must be a method compiled in anObjects class or one of its 
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1252
     superclasses and also, the number of arguments given must match the methods
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1253
     expectations -
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1254
     - otherwise strange things (and also strange crashes) can occur.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1255
     The system is NOT always detecting a wrong method/receiver combination.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1256
     YOU HAVE BEEN WARNED."
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1257
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1258
%{
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1259
    OBJFUNC code;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1260
    OBJ searchClass;
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1261
    static struct inlineCache dummy = _DUMMYILC0;
2
claus
parents: 1
diff changeset
  1262
    int nargs;
claus
parents: 1
diff changeset
  1263
    OBJ *ap;
claus
parents: 1
diff changeset
  1264
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1265
    if (__isArray(argArray)) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1266
	nargs = __arraySize(argArray);
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1267
	ap = __ArrayInstPtr(argArray)->a_element;
2
claus
parents: 1
diff changeset
  1268
    } else {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1269
	if (argArray == nil) {
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1270
	    nargs = 0;
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1271
	} else
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1272
	    nargs = -1;
2
claus
parents: 1
diff changeset
  1273
    }
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1274
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1275
#ifdef F_NARGS
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1276
    if (((__intVal(__INST(flags)) & F_NARGS) >> F_NARGSHIFT) == nargs) 
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1277
#endif
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1278
    {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1279
	code = __MethodInstPtr(self)->m_code;
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1280
	if (aClass == nil) {
328
claus
parents: 326
diff changeset
  1281
	    searchClass = dummy.ilc_class = __Class(anObject);
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1282
	} else {
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1283
	    searchClass = dummy.ilc_class = aClass;
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1284
	}
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1285
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1286
	if (nargs <= 15) {
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1287
	  /*
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1288
	   * add virtual sender (unwinding) here later,
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1289
	   * to allow hiding contexts in lazy methods.
328
claus
parents: 326
diff changeset
  1290
	   * (this is cosmetics only; therefore its done later)
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1291
	   */
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1292
	  if (code) {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1293
	    /* compiled code */
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1294
	    switch (nargs) {
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1295
		case 0:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1296
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1297
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1298
		case 1:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1299
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, ap[0]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1300
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1301
		case 2:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1302
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, ap[0], ap[1]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1303
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1304
		case 3:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1305
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, ap[0], ap[1], ap[2]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1306
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1307
		case 4:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1308
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1309
				 ap[0], ap[1], ap[2], ap[3]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1310
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1311
		case 5:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1312
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1313
				 ap[0], ap[1], ap[2], ap[3], ap[4]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1314
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1315
		case 6:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1316
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1317
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1318
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1319
		case 7:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1320
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1321
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1322
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1323
		case 8:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1324
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1325
				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1326
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1327
		case 9:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1328
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1329
				 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
  1330
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1331
		case 10:
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], ap[4], ap[5], ap[6], ap[7], ap[8], 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1334
				 ap[9]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1335
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1336
		case 11:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1337
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1338
				 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
  1339
				 ap[9], ap[10]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1340
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1341
		case 12:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1342
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1343
				 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
  1344
				 ap[9], ap[10], ap[11]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1345
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1346
		case 13:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1347
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1348
				 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
  1349
				 ap[9], ap[10], ap[11], ap[12]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1350
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1351
		case 14:
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], 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1354
				 ap[9], ap[10], ap[11], ap[12], ap[13]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1355
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1356
		case 15:
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1357
		    RETURN ( (*code)(anObject, aSymbol, SND_COMMA searchClass, &dummy, 
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1358
				 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
  1359
				 ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]) );
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1360
	    }
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1361
	  } else {
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1362
	    /* interpreted code */
328
claus
parents: 326
diff changeset
  1363
#ifdef PASS_ARG_POINTER
claus
parents: 326
diff changeset
  1364
	    RETURN ( __interpret(self, nargs, anObject, aSymbol, SND_COMMA searchClass, ap) );
claus
parents: 326
diff changeset
  1365
#else
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1366
	    switch (nargs) {
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1367
		case 0:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1368
		    RETURN ( __interpret(self, 0, anObject, aSymbol, SND_COMMA searchClass) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1369
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1370
		case 1:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1371
		    RETURN ( __interpret(self, 1, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1372
				   ap[0]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1373
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1374
		case 2:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1375
		    RETURN ( __interpret(self, 2, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1376
				   ap[0], ap[1]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1377
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1378
		case 3:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1379
		    RETURN ( __interpret(self, 3, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1380
				   ap[0], ap[1], ap[2]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1381
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1382
		case 4:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1383
		    RETURN ( __interpret(self, 4, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1384
				   ap[0], ap[1], ap[2], ap[3]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1385
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1386
		case 5:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1387
		    RETURN ( __interpret(self, 5, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1388
				   ap[0], ap[1], ap[2], ap[3], ap[4]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1389
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1390
		case 6:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1391
		    RETURN ( __interpret(self, 6, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1392
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1393
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1394
		case 7:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1395
		    RETURN ( __interpret(self, 7, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1396
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1397
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1398
		case 8:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1399
		    RETURN ( __interpret(self, 8, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1400
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1401
				   ap[7]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1402
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1403
		case 9:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1404
		    RETURN ( __interpret(self, 9, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1405
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1406
				   ap[7], ap[8]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1407
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1408
		case 10:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1409
		    RETURN ( __interpret(self, 10, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1410
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1411
				   ap[7], ap[8], ap[9]) );
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1412
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1413
		case 11:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1414
		    RETURN ( __interpret(self, 11, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1415
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1416
				   ap[7], ap[8], ap[9], ap[10]) );
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1417
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1418
		case 12:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1419
		    RETURN ( __interpret(self, 12, 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],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1421
				   ap[7], ap[8], ap[9], ap[11]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1422
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1423
		case 13:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1424
		    RETURN ( __interpret(self, 13, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1425
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1426
				   ap[7], ap[8], ap[9], ap[11], ap[12]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1427
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1428
		case 14:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1429
		    RETURN ( __interpret(self, 14, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1430
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1431
				   ap[7], ap[8], ap[9], ap[11], ap[12], ap[13]) );
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1432
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1433
		case 15:
1037
4488f834cb6b only one __interpret
Claus Gittinger <cg@exept.de>
parents: 980
diff changeset
  1434
		    RETURN ( __interpret(self, 15, anObject, aSymbol, SND_COMMA searchClass,
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1435
				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1436
				   ap[7], ap[8], ap[9], ap[11], ap[12], ap[13], ap[14]) );
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1437
	    }
328
claus
parents: 326
diff changeset
  1438
#endif
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1439
	  }
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1440
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1441
    }
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1442
%}
2
claus
parents: 1
diff changeset
  1443
.
claus
parents: 1
diff changeset
  1444
    (argArray isMemberOf:Array) ifFalse:[
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1445
	"
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1446
	 arguments must be either nil or an array
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1447
	"
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1448
	^ self badArgumentArray
2
claus
parents: 1
diff changeset
  1449
    ].
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1450
    (argArray size ~~ self numberOfMethodArgs) ifTrue:[
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1451
	"
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1452
	 the method expects a different number of arguments
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1453
	"
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1454
	^ self wrongNumberOfArguments:argArray size
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1455
    ].
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1456
    "
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1457
     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
  1458
    "
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1459
    ^ self tooManyArguments
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1460
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1461
    "
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1462
     (Float compiledMethodAt:#+) 
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1463
	valueWithReceiver:1.0 arguments:#(2.0)
2
claus
parents: 1
diff changeset
  1464
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1465
     '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
  1466
     (True compiledMethodAt:#printString) 
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1467
	valueWithReceiver:false arguments:nil
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1468
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1469
     '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
  1470
      and a wrong value returned ...'.
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1471
     (Point compiledMethodAt:#x) 
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1472
	valueWithReceiver:(1->2) arguments:nil
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1473
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1474
     '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
  1475
      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
  1476
     (Point compiledMethodAt:#x) 
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1477
	valueWithReceiver:(Object new) arguments:nil
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1478
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1479
     '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
  1480
     (Object compiledMethodAt:#printOn:)
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1481
	valueWithReceiver:false arguments:nil
109
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
     '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
  1484
     (Object compiledMethodAt:#printOn:)
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1485
	valueWithReceiver:false arguments:#() 
109
1fae65190b17 errors raise signals; check arg-count in valueWith...
claus
parents: 93
diff changeset
  1486
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1487
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1488
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1489
!Method methodsFor:'printing & storing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1490
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1491
printOn:aStream
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1492
    "put a printed representation of the receiver onto aStream.
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1493
     Since methods do not store their class/selector, we have to search
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1494
     for it here."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1495
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1496
    |classAndSelector m wrapped|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1497
253
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1498
    wrapped := false.
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1499
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1500
    aStream nextPutAll:(self classNameWithArticle).
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1501
    aStream nextPut:$(.
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1502
176
48061f8659aa more queries
claus
parents: 159
diff changeset
  1503
    classAndSelector := self who.
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1504
    classAndSelector isNil ifTrue:[
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1505
	"
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1506
	 not anchored in any class.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1507
	 check if wrapped (to be more informative in inspectors)
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1508
	"
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1509
	m := self wrapper.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1510
	m notNil ifTrue:[
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1511
	    classAndSelector := m who.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1512
	    wrapped := true.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1513
	]
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1514
    ].
176
48061f8659aa more queries
claus
parents: 159
diff changeset
  1515
    classAndSelector notNil ifTrue:[
48061f8659aa more queries
claus
parents: 159
diff changeset
  1516
	(classAndSelector at:1) name printOn:aStream.
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1517
	aStream nextPutAll:' '.
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1518
	(classAndSelector at:2) printOn:aStream.
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1519
	wrapped ifTrue:[
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1520
	    aStream nextPutAll:'; wrapped'
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1521
	].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1522
    ] ifFalse:[
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
  1523
	"
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  1524
	 sorry, a method which is nowhere anchored
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 192
diff changeset
  1525
	"
253
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1526
	aStream nextPutAll:'unbound'
56
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1527
    ].
be0ed17e6f85 *** empty log message ***
claus
parents: 49
diff changeset
  1528
    aStream nextPut:$)
176
48061f8659aa more queries
claus
parents: 159
diff changeset
  1529
48061f8659aa more queries
claus
parents: 159
diff changeset
  1530
    "
253
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1531
     (Object compiledMethodAt:#at:) printOn:Transcript. Transcript cr.
30daee717a53 *** empty log message ***
claus
parents: 227
diff changeset
  1532
     (Object compiledMethodAt:#at:) copy printOn:Transcript. Transcript cr.
176
48061f8659aa more queries
claus
parents: 159
diff changeset
  1533
    "
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
  1534
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1535
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1536
printStringForBrowserWithSelector:selector
1436
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1537
    "return a printString to represent myself to the user in a browser.
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1538
     Defined here to allow for browsers to deal with nonStandard pseudoMethods"
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1539
1436
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1540
    |s moreInfo p em|
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1541
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1542
    moreInfo := ''.
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1543
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1544
    (p := self privacy) ~~ #public ifTrue:[
1436
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1545
        moreInfo := Text string:'    (* ' , p , ' *)' emphasis:#italic.
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1546
    ].
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1547
    self isWrapped ifTrue:[
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1548
        (MessageTracer isCounting:self) ifTrue:[
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1549
            (MessageTracer isCountingMemoryUsage:self) ifTrue:[
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1550
                moreInfo := moreInfo , 
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1551
                     '    (mem usage ' , (MessageTracer memoryUsageOfMethod:self) printString , ' Bytes)'.
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1552
            ] ifFalse:[
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1553
                moreInfo := moreInfo , 
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1554
                     '    (called ' , (MessageTracer executionCountOfMethod:self) printString , ' times)'.
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1555
            ]
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1556
        ] ifFalse:[
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1557
            moreInfo := ' !!'
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1558
        ]
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1559
    ].
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1560
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1561
    self isInvalid ifTrue:[
1436
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1562
        moreInfo := '    (** not executable **)'.
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1563
        em := #color->Color red.
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1564
    ].
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1565
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1566
    self isLazyMethod ifTrue:[
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1567
"/                moreInfo := '    (lazy)'
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1568
    ] ifFalse:[
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1569
        self isUnloaded ifTrue:[
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1570
            moreInfo := '    (** unloaded **)'
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1571
        ]
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1572
    ].
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1573
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1574
    moreInfo size == 0 ifTrue:[^ selector].
1436
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1575
    s := selector , moreInfo.
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1576
    em notNil ifTrue:[
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1577
        ^ Text string:s emphasis:em
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1578
    ].
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1579
    ^ s
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1580
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1581
    "Created: 16.4.1996 / 20:11:12 / cg"
1436
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  1582
    "Modified: 22.5.1996 / 16:43:25 / cg"
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1583
!
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1584
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
  1585
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
  1586
    "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
  1587
     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
  1588
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
    |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
  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
    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
  1592
    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
  1593
	^ (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
  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
    ^ '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
  1596
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
    "
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
     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
  1599
     (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
  1600
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1601
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1602
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1603
!Method methodsFor:'private-compiler interface'!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1604
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1605
flags:newFlags
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1606
    "set the flags (number of method variables, stacksize).
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1607
     WARNING: for internal use by the compiler only.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1608
              playing around here with incorrect values 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1609
              may crash smalltalk badly.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1610
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1611
     Dont depend on the values in the flag field - its interpretations
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1612
     may change without notice."
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1613
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1614
    "/ protect myself a bit - putting in an object would crash me ...
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1615
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1616
    (newFlags isMemberOf:SmallInteger) ifTrue:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1617
        flags := newFlags
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1618
    ]
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1619
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1620
    "Modified: 8.3.1996 / 13:26:05 / cg"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1621
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1622
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1623
numberOfMethodArgs:aNumber
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1624
    "set the number of arguments, the method expects.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1625
     WARNING: for internal use by the compiler only.     
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1626
              playing around here with incorrect values 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1627
              may (will ?)  crash smalltalk badly.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1628
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1629
     The limitation in the max. number of arguments is due to the
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1630
     missing SENDxx functions in the VM and cases in #perform. This too 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1631
     will be removed in a later release, allowing any number of arguments.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1632
     - for use by compiler only."
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1633
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1634
    (aNumber between:0 and:self class maxNumberOfArguments) ifFalse:[
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1635
        self error:('ST/X only supports up to a maximum of ' ,
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1636
                    self class maxNumberOfArguments printString ,
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1637
                    ' method arguments').
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1638
        ^ self
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1639
    ].
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1640
%{
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1641
    /* made this a primitive to get define in stc.h */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1642
#ifdef F_NARGS
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1643
    __INST(flags) = __MKSMALLINT( (__intVal(__INST(flags)) & ~F_NARGS) | (__intVal(aNumber) << F_NARGSHIFT) );
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1644
#endif
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1645
%}
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1646
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1647
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1648
numberOfMethodVars:aNumber
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1649
    "set the number of method variables - for use by compiler only.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1650
     WARNING: for internal use by the compiler only.     
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1651
              playing around here with incorrect values 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1652
              may (will ?)  crash smalltalk badly."
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1653
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1654
%{  /* NOCONTEXT */
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1655
    int f = __intVal(__INST(flags));
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1656
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1657
    /* made this a primitive to get define in stc.h */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1658
    if (__isSmallInteger(aNumber)) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1659
        f = (f & ~F_NVARS) | (__intVal(aNumber) << F_NVARSHIFT);
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1660
        __INST(flags) = __MKSMALLINT(f);
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1661
    }
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1662
%}
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1663
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1664
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1665
setResourceFlag
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1666
    "mark the method as having a <resource> definition in its
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1667
     source. 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1668
     These resource definitions were found in ST-80 methods, and are
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1669
     currently not supported by ST/X (except for remembering this flag).
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1670
     It can be used to find resource-flagged methods quicker."
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1671
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1672
%{  /* NOCONTEXT */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1673
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1674
#ifdef F_RESOURCE
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1675
    int f = __intVal(__INST(flags));
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1676
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1677
    f |= F_RESOURCE;
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1678
    __INST(flags) = __MKSMALLINT(f);
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1679
#endif
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1680
%}
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1681
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1682
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1683
stackSize:aNumber
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1684
    "set the depth of the local stack.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1685
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1686
     WARNING: for internal use by the compiler only.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1687
              playing around here with incorrect values 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1688
              may crash smalltalk badly.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1689
              (if the runtime library was compiled with DEBUG, 
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1690
               a bad stack will be detected and triggers an error)"
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1691
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1692
%{  /* NOCONTEXT */
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1693
    int f = __intVal(__INST(flags));
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1694
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1695
    /* made this a primitive to get define in stc.h */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1696
    if (__isSmallInteger(aNumber)) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1697
        f = (f & ~F_NSTACK) | (__intVal(aNumber) << F_NSTACKSHIFT);
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1698
        __INST(flags) = __MKSMALLINT(f);
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1699
    }
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1700
%}
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1701
! !
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1702
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
  1703
!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
  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
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
  1706
    "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
  1707
     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
  1708
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1709
    "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
  1710
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
    |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
  1712
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
    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
  1714
    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
  1715
    "
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
     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
  1717
    "
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
    ^ 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
  1719
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
    "
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
     |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
  1722
     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
  1723
     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
  1724
    "
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
!
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1726
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
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
  1728
    "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
  1729
     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
  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
    |src|
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1732
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
  1733
    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
  1734
    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
  1735
	(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
  1736
	    "/ 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
  1737
	    ^ 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
  1738
	]
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
    ^ 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
  1741
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
     (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
  1744
     (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
  1745
     (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
  1746
    "
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1747
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
  1748
    "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
  1749
!
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
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1751
hasResource
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1752
    "return true if the method had a <resource> definition in its
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1753
     source. This was found in ST-80 methods, and currently not supported
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1754
     by ST/X (except for remembering this flag).
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1755
     It can be used to find resource-flagged methods quicker."
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1756
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1757
%{  /* NOCONTEXT */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1758
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1759
#ifdef F_RESOURCE
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1760
    RETURN (((INT)__INST(flags) & __MASKSMALLINT(F_RESOURCE)) ? true : false);
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1761
#endif
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1762
%}.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1763
    ^ false
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1764
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1765
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1766
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1767
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
  1768
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
  1769
    "return true, if this method is not executable due to
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1770
     a (re)-compilation error. Since invalidation is by patching the
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1771
     methods code-pointer to a trap function, check for that here.
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1772
     (see comment in Method>>invalidCodeObject)."
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
  1773
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
    |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
  1775
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
    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
  1777
    self ~~ m ifTrue:[
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1778
        (self code notNil and:[self code = m code]) ifTrue:[^ true].
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1779
        (byteCode notNil and:[byteCode == m byteCode]) ifTrue:[^ true].
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
  1780
    ].
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1781
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
  1782
    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
  1783
    self ~~ m ifTrue:[
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1784
        (self code notNil and:[self code = m code]) ifTrue:[^ true].
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1785
        (byteCode notNil and:[byteCode == m byteCode]) ifTrue:[^ true].
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
  1786
    ].
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
    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
  1788
    self ~~ m ifTrue:[
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1789
        (self code notNil and:[self code = m code]) ifTrue:[^ true].
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1790
        (byteCode notNil and:[byteCode == m byteCode]) ifTrue:[^ true].
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
  1791
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1792
    ^ false
1194
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1793
628abcb5fbb6 moved some protocol from to upper levels
Claus Gittinger <cg@exept.de>
parents: 1190
diff changeset
  1794
    "Modified: 16.4.1996 / 17:53:08 / 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
  1795
!
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
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
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
  1798
    "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
  1799
     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
  1800
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1801
    ^ 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
  1802
!
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
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
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
  1805
    "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
  1806
     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
  1807
     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
  1808
     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
  1809
     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
  1810
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1811
    |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
  1812
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
    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
  1814
    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
  1815
	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
  1816
	(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
  1817
	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
  1818
	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
  1819
	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
  1820
	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
  1821
	^ (argNames , varNames)
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1822
    ].
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
  1823
    ^ 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
  1824
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1825
    "
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
  1826
     (Method compiledMethodAt:#printOn:) methodArgAndVarNames
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1827
    "
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
  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
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
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
  1831
    "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
  1832
     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
  1833
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1834
    ^ 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
  1835
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
    "
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
     (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
  1838
    "
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
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
    "Modified: 31.10.1995 / 14:36:46 / cg"
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1841
!
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1842
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
  1843
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
  1844
    "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
  1845
     This is a somewhat stupid implementation."
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1846
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
  1847
    |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
  1848
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
    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
  1850
    (text size < 2) ifTrue:[^nil].
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1851
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
  1852
    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
  1853
    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
  1854
    (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
  1855
	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
  1856
	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
  1857
	^ line copyFrom:(qIndex + 1) to:(qIndex2 - 1)
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1858
    ].
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
  1859
    (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
  1860
	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
  1861
	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
  1862
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
	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
  1864
	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
  1865
	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
  1866
	[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
  1867
	    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
  1868
	    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
  1869
	    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
  1870
	    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
  1871
	].
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
	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
  1873
	^ 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
  1874
    ].
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
    ^ 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
  1876
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1877
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1878
     (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
  1879
    "
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
!
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1881
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
  1882
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
  1883
    "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
  1884
     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
  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
    ^ 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
  1887
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1888
    "
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
     (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
  1890
    "
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
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1892
    "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
  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
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
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
  1896
    "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
  1897
     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
  1898
     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
  1899
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1900
    |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
  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
    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
  1903
    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
  1904
    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
  1905
    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
  1906
    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
  1907
    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
  1908
    ^ 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
  1909
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
     (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
  1912
     (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
  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
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1915
    "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
  1916
!
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
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
  1919
    "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
  1920
     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
  1921
     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
  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
    |parser sourceString|
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  1924
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
  1925
    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
  1926
    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
  1927
	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
  1928
	(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
  1929
	^ 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
  1930
    ].
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
    ^ 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
  1932
!
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  1933
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
  1934
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
  1935
    "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
  1936
     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
  1937
     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
  1938
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
    "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
  1940
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
    |pair|
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1942
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
  1943
    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
  1944
    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
  1945
    "
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
     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
  1947
    "
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
    ^ 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
  1949
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
     |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
  1952
     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
  1953
     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
  1954
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1955
!
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  1956
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1957
wasCalled
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1958
    "return true if the method has ever been executed.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1959
     The called flag will be set by the interpreter whenever a method
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1960
     is called for the very first time, to support coverage tests.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1961
     This is EXPERIMENTAL, nonStandard and not yet fully implemented."
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1962
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1963
%{  /* NOCONTEXT */
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1964
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1965
#ifdef F_CALLED
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1103
diff changeset
  1966
    RETURN (((INT)__INST(flags) & __MASKSMALLINT(F_CALLED)) ? true : false);
1093
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1967
#endif
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1968
%}.
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1969
    ^ false
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1970
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1971
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1972
!
1e742016eea0 category rename / added access to RESOURCE and CALLED flags
Claus Gittinger <cg@exept.de>
parents: 1087
diff changeset
  1973
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
  1974
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
  1975
    "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
  1976
     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
  1977
     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
  1978
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
     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
  1980
     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
  1981
     (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
  1982
     - 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
  1983
     defined in is lost in this case.
68
59faa75185ba *** empty log message ***
claus
parents: 56
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
     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
  1986
	      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
  1987
	      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
  1988
     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
  1989
	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
  1990
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1991
    |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
  1992
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1993
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1994
     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
  1995
     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
  1996
     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
  1997
     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
  1998
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  1999
    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
  2000
	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
  2001
	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
  2002
	    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
  2003
	    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
  2004
	]
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  2005
    ].
227
23b1c4de3402 package & cleanup
claus
parents: 216
diff changeset
  2006
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  2007
    "
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
  2008
     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
  2009
     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
  2010
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2011
    classes := Smalltalk allClasses.
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  2012
    "
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
  2013
     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
  2014
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2015
    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
  2016
	|sel|
350
claus
parents: 345
diff changeset
  2017
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
  2018
	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
  2019
	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
  2020
			   ^ Array with:aClass with:sel].
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  2021
    ].
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
  2022
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2023
    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
  2024
    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
  2025
	|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
  2026
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2027
	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
  2028
	sel notNil ifTrue:[^ Array with:aClass class with:sel].
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  2029
    ].
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  2030
    "
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
  2031
     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
  2032
     in the Smalltalk dictionary). Search all instances of Behavior
142
c7844287bddf *** empty log message ***
claus
parents: 109
diff changeset
  2033
    "
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
  2034
    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
  2035
	|sel|
444
071b4f32272c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
  2036
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
  2037
	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
  2038
	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
  2039
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2040
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2041
     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
  2042
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2043
    ^ nil
444
071b4f32272c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
  2044
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
  2045
    "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
  2046
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2047
     |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
  2048
     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
  2049
     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
  2050
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2051
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2052
    "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
  2053
    "
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2054
     |m cls|
444
071b4f32272c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
  2055
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
  2056
     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
  2057
	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
  2058
	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
  2059
	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
  2060
	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
  2061
	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
  2062
     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
  2063
     Smalltalk removeClass:cls.
444
071b4f32272c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
  2064
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
  2065
     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
  2066
     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
  2067
     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
  2068
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2069
     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
  2070
    "
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  2071
!
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
  2072
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
  2073
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
  2074
    "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
  2075
     Thats the WrapperMethod which contains myself."
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  2076
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
  2077
    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
  2078
	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
  2079
    ].
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2080
    ^ 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
  2081
! !
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2082
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
  2083
!Method methodsFor:'trap methods'!
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
  2084
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
  2085
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
  2086
    "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
  2087
     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
  2088
     the objectFileLoader to invalidate methods whose code is unloaded."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2089
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
  2090
    |invldMethod|
159
514c749165c3 *** empty log message ***
claus
parents: 142
diff changeset
  2091
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
  2092
    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
  2093
    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
  2094
    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
  2095
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2096
    "Created: 17.9.1995 / 15:00:52 / claus"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2097
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2098
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
  2099
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
  2100
    "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
  2101
     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
  2102
     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
  2103
     after a class definition change (for example: instvars are no longer there)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2104
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
  2105
    |invldMethod|
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  2106
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
  2107
    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
  2108
    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
  2109
    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
  2110
d600e08a5936 handle the case where a method has a sourceFileInfo, but the class has not
Claus Gittinger <cg@exept.de>
parents: 934
diff changeset
  2111
    "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
  2112
! !
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  2113
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
  2114
!Method class methodsFor:'documentation'!
872
af04035b443d binary class storage support
Claus Gittinger <cg@exept.de>
parents: 829
diff changeset
  2115
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
  2116
version
1436
4eae8fd83654 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
  2117
    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.89 1996-05-22 14:43:43 cg Exp $'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2118
! !
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
  2119
Method initialize!