ExecutableFunction.st
branchjv
changeset 25415 4ea1fe7c363f
parent 23547 c69c97cec351
equal deleted inserted replaced
25414:dffa84757e23 25415:4ea1fe7c363f
   109     }
   109     }
   110 %}.
   110 %}.
   111     ^ nil
   111     ^ nil
   112 !
   112 !
   113 
   113 
       
   114 getCode
       
   115     "return the code field. This is not an object but the address of the machine instructions.
       
   116      Therefore an externalAddress representing the code-address is returned"
       
   117 
       
   118     ^ self code
       
   119 !
       
   120 
   114 instVarAt:index
   121 instVarAt:index
   115     "have to catch instVar access to code - since its no object"
   122     "have to catch instVar access to code - since its no object"
   116 
   123 
   117     (index == 1) ifTrue:[^ self code].
   124     (index == 1) ifTrue:[^ self code].
   118     ^ super instVarAt:index
   125     ^ super instVarAt:index
   122     "have to catch instVar access to code - since its no object"
   129     "have to catch instVar access to code - since its no object"
   123 
   130 
   124     (index == 1) ifTrue:[^ self code:value].
   131     (index == 1) ifTrue:[^ self code:value].
   125     ^ super instVarAt:index put:value
   132     ^ super instVarAt:index put:value
   126 ! !
   133 ! !
   127 
       
   128 
   134 
   129 !ExecutableFunction methodsFor:'error handling'!
   135 !ExecutableFunction methodsFor:'error handling'!
   130 
   136 
   131 invalidCode
   137 invalidCode
   132     "{ Pragma: +optSpace }"
   138     "{ Pragma: +optSpace }"
   147 printOn:aStream
   153 printOn:aStream
   148     "append a printed representation of the receiver to aStream"
   154     "append a printed representation of the receiver to aStream"
   149 
   155 
   150     |addr|
   156     |addr|
   151 
   157 
   152     addr := self code.
   158     addr := self getCode.
   153     addr isNil ifTrue:[^ super printOn:aStream].
   159     addr isNil ifTrue:[^ super printOn:aStream].
   154 
   160 
   155     aStream nextPutAll:self class name; nextPutAll:'(address: 0x'.
   161     aStream nextPutAll:self class name; nextPutAll:'(address: 0x'.
   156     addr address printOn:aStream base:16.
   162     addr address printOn:aStream base:16.
   157     aStream nextPut:$)
   163     aStream nextPut:$)
   370 messagesSentToSelf
   376 messagesSentToSelf
   371     ^ #()       "/ actually: unknown here in this abstract class
   377     ^ #()       "/ actually: unknown here in this abstract class
   372 !
   378 !
   373 
   379 
   374 privacy
   380 privacy
   375     "return a symbol describing the methods access rights (privacy);
   381     "return a symbol describing the method's access rights (privacy);
   376      Currently, this is one of #private, #protected, #public or #ignored.
   382      Currently, this is one of #private, #protected, #public or #ignored.
   377 
   383 
   378      Here we unconditionally return #public, to allow alien code objects
   384      Here we unconditionally return #public, to allow alien code objects
   379      to be handled by the browsers."
   385      to be handled by the browsers."
   380 
   386 
   381     ^ #public
   387     ^ #public
   382 
   388 
   383     "Created: 16.4.1996 / 16:35:18 / cg"
   389     "Created: / 16-04-1996 / 16:35:18 / cg"
       
   390     "Modified (comment): / 21-11-2017 / 13:01:32 / cg"
   384 !
   391 !
   385 
   392 
   386 referencesGlobal:aGlobalSymbol
   393 referencesGlobal:aGlobalSymbol
   387     "return true, if this method references the global
   394     "return true, if this method references the global
   388      bound to aGlobalSymbol.
   395      bound to aGlobalSymbol.
   442 
   449 
   443     "Created: / 3.11.1997 / 09:09:01 / cg"
   450     "Created: / 3.11.1997 / 09:09:01 / cg"
   444 !
   451 !
   445 
   452 
   446 sends:aSelectorSymbol
   453 sends:aSelectorSymbol
   447     "return true, if this code object contains a message-send with aSelectorSymbol as selector. 
   454     <resource: #obsolete>
   448      - due to the simple check in the literal array, also simple uses 
   455 
       
   456     "return true, if this code object contains a message-send with aSelectorSymbol as selector.
       
   457      - due to the simple check in the literal array, also simple uses
   449        of aSelectorSymbol as symbol will return true.
   458        of aSelectorSymbol as symbol will return true.
   450        Should ask compiler, if there is really a send."
   459        Should ask compiler, if there is really a send."
   451 
   460 
       
   461     self obsoleteFeatureWarning:'please use #sendsSelector:'.
       
   462     ^ self sendsSelector:aSelectorSymbol
       
   463 
       
   464     "Created: / 16-04-1996 / 16:35:53 / cg"
       
   465     "Modified: / 05-02-2017 / 01:21:26 / cg"
       
   466 !
       
   467 
       
   468 sendsAny:aCollectionOfSelectorSymbols
       
   469     <resource: #obsolete>
       
   470 
       
   471     "return true, if this method contains a message-send
       
   472      to any of aCollectionOfSelectorSymbols."
       
   473 
       
   474     self obsoleteFeatureWarning:'please use #sendsAnySelector:'.
       
   475     ^ self sendsAnySelector:aCollectionOfSelectorSymbols
       
   476 
       
   477     "Created: / 08-08-2011 / 18:53:24 / cg"
       
   478     "Modified: / 05-02-2017 / 01:31:22 / cg"
       
   479 !
       
   480 
       
   481 sendsAnySelector:aCollectionOfSelectorSymbols
       
   482     "return true, if this method contains a message-send
       
   483      to any of aCollectionOfSelectorSymbols."
       
   484 
       
   485     (aCollectionOfSelectorSymbols contains:[:sym | self referencesLiteral:sym]) ifTrue:[
       
   486 	^ true.
       
   487     ].
       
   488     ^ false
       
   489 
       
   490     "Created: / 05-02-2017 / 01:27:11 / cg"
       
   491 !
       
   492 
       
   493 sendsSelector:aSelectorSymbol
       
   494     "return true, if this code object contains a message-send with aSelectorSymbol as selector.
       
   495      - due to the simple check in the literal array, also simple uses
       
   496        of aSelectorSymbol as symbol will return true.
       
   497        Should ask compiler, if there is really a send."
       
   498 
   452     ^ self referencesLiteral:aSelectorSymbol
   499     ^ self referencesLiteral:aSelectorSymbol
   453 
   500 
   454     "Created: 16.4.1996 / 16:35:53 / cg"
   501     "Created: / 05-02-2017 / 01:19:03 / cg"
   455 !
   502 !
   456 
   503 
   457 usedGlobals
   504 usedGlobals
   458     "return a collection with the global names referred to by the receiver.
   505     "return a collection with the global names referred to by the receiver.
   459      Uses Parser to parse methods source and extract them."
   506      Uses Parser to parse methods source and extract them."