This is an old revision of the document!
This section contains LARA constructs that are still valid, but for which newer (and recommended) alternatives exist.
(Alternative: Query.search())
Select with full join point chain:
select program.file.function.body.loop end
Select with only last join point. The chain is induced, produces the same result as above:
select loop end
Assign the selected join points to a variable for later use:
LOOPS: select loop end
Assign an alias for specific join points:
select ($p=loop).($c=loop) end
(Alternative: for…of on return of Query.search() - i.e. weaver.Selector instances)
Apply after a select:
select loop end apply println($loop.rank); end
Apply on a previously selected set of join points:
apply to LOOPS println($loop.rank); end
It is possible to perform a natural join on two sets of join points:
LOOP_START: select function.body.loop.($loop_start = first) end FUNCTION_FIRST: select function.body.first end apply to LOOP_START::FUNCTION_FIRST // Init counters at the beginning of the function $first.insert before%{counter_[[$loop.uid]] = 0;}%; // Increment counters when entering the loop $loop_start.insert before%{counter_[[$loop.uid]] = counter_[[$loop.uid]] +1;}%; // ... end
Use of join points with aliases inside the apply statement:
select ($p=loop).($c=loop) end apply $p.exec Interchange($c); end
(Alternative: Query.search() filters)
Using a condition block:
select function end apply // ... end condition $function.name == 'kernel' end
Combining conditions using && (and) and || (or) operators:
select loop end apply $loop.exec Unroll(2); end condition $loop.is_innermost && $loop.type=="for" end
Using “filter” conditions on the join point chain:
select function{name=='kernel'} end apply // ... end // OR select function{'kernel'} end // uses the default attribute of the join point apply // ... end