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