Context Exposure

When it comes to capturing the context of a join point, AspectCobol's [2] design doesn't rely on the use of reflection inside the advice code, as performed in AspectJ [1]. Rather, it suggests that join point reflection on the static shadow should be a part of the pointcut. The extraction of the context-specific information is described as part of the pointcut designator. We extend the idea of binding the results of desired context variables for subsequent use in the action code.

In AspectMatlab, access to the static program context that belongs to the join point is selector based. These selectors are specified along with an action definition, because an action corresponds directly to the static join point shadow. In the example below, the action actcall, which acts before the join points matching the pattern call2args given in Listing 5. It will fetch the name and args of the function call from the join point shadow.


\begin{lstlisting}[language=MATLAB, frame=htbp, caption={Context Exposure}, labe...
...isp(['calling ', name, ' with arguments(', args , ')']);
%
end
\end{lstlisting}

Of course, a selector is only applicable depending upon the join point type. For example, the counter selector is only meaningful when used on a loop join point. The args selector fetches the array indices in case of array patterns, whereas the same selector is used to get the function arguments/parameters in case of function patterns.

A list of context selectors and their meaning with different join points is given in Table III.


Table III: Context Selectors with respect to Join Points
set get call execution loop loopbody loophead
args indices arguments passed loop iteration space
obj variable before set variable function handle - - iterator variable -
newVal new array - - - - - loop range
counter - - - - - current iteration -
name name of the entity matched - - -
pat name of the pattern matched
line line number in the source code
loc enclosing function/script name
file enclosing file name
aobj variable name - - - - - -
ainput - input var name(s) - - -
aoutput - - - output var name(s) - - -
varargout cell array variable used to return data from around action


Toheed ASLAM 2010-04-24