Compound Patterns

As in other aspect-oriented languages, AspectMatlab also provides a programmer the facility of creating compound patterns. Such user-defined patterns are in fact logical combination of user-defined patterns and primitive patterns given in Table I.

Examples of compound patterns given in Listing 9 display the level of flexibility a programmer can achieve in order to create different logical compounds of primitive patterns. Pattern pCallFoo matched all calls made to function foo, but only the ones from within the loops, either for or while loops. On the other hand, the pattern pGetOrSet will match all array read or write operations, but the ones only within the function bar. pCallExec shows a combination of an already defined pattern pCallFoo with a primitive pattern $execution$.


\begin{lstlisting}[language=MATLAB, frame=htbp, caption={Compound Patterns}, lab...
...function, bar);
pCallExec : pCallFoo \vert execution(foo);
end
\end{lstlisting}

Care should be taken while ANDing patterns of different kinds, because a shadow in the source code has only one specific type. For example, replacing OR with an AND in the pattern pGetOrSet above will result in no match, simply because an array can either be read or written to, not both at the same time.

Toheed ASLAM 2010-04-24