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