======= Legacy LARA ======= This section contains LARA constructs that are still valid, but for which newer (and recommended) alternatives exist. ==== Select ==== (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 ==== Apply ==== (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 ==== Conditions ==== (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 ==== Automatic import of JS files ==== (Alternative: manually import JS files / use config option) In previous versions, any JS file that appeared in include folders was automatically loaded and executed. During a period this behavior was disabled if the include folder had the name ''src-lara'', and now by default, is completely disabled. JS files in include folders are no longer automatically loaded, they have to be either manually imported (see [[doc:lara:tips#importing_js_files|Importing JS Files]]), or the configuration option "Automatically import JS files in include folders" must be enabled.