InstrumentedMethod.st
author Claus Gittinger <cg@exept.de>
Sun, 24 May 2020 03:18:13 +0200
changeset 4670 4ec715f14ddd
parent 4622 d39fbcb89f9c
permissions -rw-r--r--
#BUGFIX by cg class: Parser changed: #selectorCheck:for:positions:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4622
d39fbcb89f9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
     1
"{ Encoding: utf8 }"
d39fbcb89f9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
     2
2355
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 2010 by eXept Software AG
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
              All Rights Reserved
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libcomp' }"
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
3558
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
    16
"{ NameSpace: Smalltalk }"
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
    17
2355
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
Method variableSubclass:#InstrumentedMethod
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'System-Compiler-Instrumentation'
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!InstrumentedMethod class methodsFor:'documentation'!
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 2010 by eXept Software AG
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
              All Rights Reserved
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
!
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    Instances of me are created by the instrumenting compiler.
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    [author:]
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
        Claus Gittinger
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
"
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
! !
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
2367
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    50
!InstrumentedMethod class methodsFor:'cleanup'!
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    51
2572
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
    52
cleanAllInfoWithChange:withChange
2707
f9eb45d7729d changed: #cleanAllInfoWithChange:
Claus Gittinger <cg@exept.de>
parents: 2631
diff changeset
    53
    InstrumentationInfo cleanAllInfoWithChange:withChange
2367
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    54
2572
Claus Gittinger <cg@exept.de>
parents: 2389
diff changeset
    55
    "Created: / 20-07-2011 / 19:01:21 / cg"
2367
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    56
! !
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    57
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    58
!InstrumentedMethod methodsFor:'accessing'!
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    59
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    60
blockInvocationInfo
2631
40ea34fb8e58 changed:
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
    61
    "return a collection of all block-info objects"
40ea34fb8e58 changed:
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
    62
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    63
    |info|
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    64
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    65
    info := OrderedCollection new.
2631
40ea34fb8e58 changed:
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
    66
    self literalsDo:[:lit |
2978
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
    67
        (lit isSpecialInstrumentationInfoLiteral
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
    68
        and:[ lit isBlockExecutionInfo ]) ifTrue:[
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
    69
            info add:lit
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    70
        ]
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    71
    ].
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    72
    ^ info
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    73
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    74
    "Created: / 27-04-2010 / 13:47:21 / cg"
2631
40ea34fb8e58 changed:
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
    75
    "Modified: / 07-08-2011 / 17:05:02 / cg"
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    76
!
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    77
2367
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    78
invokedViaPerform
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    79
    "true if the method is ever invoked via perform"
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    80
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    81
    |info|
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    82
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    83
    info := self methodInvocationInfo.
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    84
    ^ info notNil and:[info invokedViaPerform]
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    85
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    86
    "Created: / 27-04-2010 / 18:23:10 / cg"
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    87
!
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
    88
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    89
methodInvocationInfo
2978
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
    90
    "return the one and only method-invocatin info"
2631
40ea34fb8e58 changed:
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
    91
40ea34fb8e58 changed:
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
    92
    ^ self 
2978
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
    93
        literalsDetect:[:lit | 
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
    94
                lit isSpecialInstrumentationInfoLiteral
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
    95
                and:[ lit isMethodInvocationInfo]] 
2631
40ea34fb8e58 changed:
Claus Gittinger <cg@exept.de>
parents: 2572
diff changeset
    96
        ifNone:nil
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    97
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
    98
    "Created: / 27-04-2010 / 13:34:01 / cg"
2389
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
    99
!
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   100
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   101
statementInvocationInfo
2978
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
   102
    "return all statement infos (but not block infos)"
2725
86bbe6e76648 comment/format in: #statementInvocationInfo
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   103
2389
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   104
    |info|
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   105
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   106
    info := OrderedCollection new.
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   107
    self literalsDo:[:lit | 
2978
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
   108
        (lit isSpecialInstrumentationInfoLiteral
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
   109
        and:[ lit isStatementExecutionInfo 
726eee43543f class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2977
diff changeset
   110
        and:[ lit isBlockExecutionInfo not]]) ifTrue:[
2389
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   111
            info add:lit
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   112
        ]
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   113
    ].
13ce41b28d4e changed:
Claus Gittinger <cg@exept.de>
parents: 2367
diff changeset
   114
    ^ info
2725
86bbe6e76648 comment/format in: #statementInvocationInfo
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   115
86bbe6e76648 comment/format in: #statementInvocationInfo
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   116
    "Modified (comment): / 30-09-2011 / 12:05:06 / cg"
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   117
! !
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   118
3558
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   119
!InstrumentedMethod methodsFor:'cleanup'!
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   120
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   121
cleanInstrumentationInfoWithChange:doChangeNotifications   
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   122
    ^ self 
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   123
        literalsDo:[:lit | 
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   124
            lit isSpecialInstrumentationInfoLiteral ifTrue:[
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   125
                lit cleanInfoWithChange:doChangeNotifications
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   126
            ]
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   127
        ].
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   128
! !
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   129
2355
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
!InstrumentedMethod methodsFor:'queries'!
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   132
hasBeenCalled
2950
aaed9f9db35c comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   133
    "return true, if I have been called"
aaed9f9db35c comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   134
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   135
    |info|
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   136
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   137
    ^ (info := self methodInvocationInfo) notNil
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   138
    and:[ info hasBeenCalled ]
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   139
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   140
    "Created: / 27-04-2010 / 13:03:33 / cg"
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   141
!
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   142
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   143
haveAllBlocksBeenExecuted
2950
aaed9f9db35c comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   144
    "return true if all of my blocks have been called"
aaed9f9db35c comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2725
diff changeset
   145
2358
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   146
    ^ self blockInvocationInfo conform:[:eachBlockInfo | eachBlockInfo callCount > 0]
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   147
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   148
    "Modified: / 27-04-2010 / 13:44:46 / cg"
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   149
!
Claus Gittinger <cg@exept.de>
parents: 2355
diff changeset
   150
2355
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
isInstrumented
4622
d39fbcb89f9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
   152
    "return true, if this is an instrumented method."
d39fbcb89f9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
   153
2355
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    ^ true
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    "Created: / 27-04-2010 / 12:25:39 / cg"
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
! !
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
!InstrumentedMethod class methodsFor:'documentation'!
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
version_CVS
4622
d39fbcb89f9c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
   162
    ^ '$Header$'
2355
f84f052fd33f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
! !
3558
c6e1036e6597 class: InstrumentedMethod
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
   164