In Figure 9, we present an example of an aspect, which
counts all the function calls made with at least two arguments. To do so,
we need to have a pattern to capture all such calls. The
pattern is used to display the number of calls made
at the end of the program.
To demonstrate the application of the aspect from Figure 9, consider a small base program consisting of the simple MATLAB function given in Figure 10.
The function histo takes one input argument n and returns three values m,s,d. Values are returned by declaring variables to be return parameters in the function header, then assigning these variables a value. This function first generates some random-sized vectors, then calls several MATLAB functions to generate a histogram, and finally computes some basic statistics.
Once compiled along with the aspect presented in
Figure 9, pattern call2args finds only three
matching join points (at lines 5, 6 and 9) where the function calls
carry two arguments each. So, corresponding action function calls will
be woven only at those program points. Note that the function calls
with a single input argument (at lines 11, 12 and 13) do not match.
Moreover, the action actexecution is an action,
so it will be woven at the end of the function.
Toheed ASLAM 2010-04-24