User Tools

Site Tools


doc:lara:tips

Warning: Undefined array key -1 in /home/feupptspecs/public_html/wiki/inc/html.php on line 1458

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:lara:tips [2022/01/15 20:18]
jbispo
doc:lara:tips [2022/01/15 20:20] (current)
jbispo
Line 16: Line 16:
 /* Furthermore, since importing will evaluate all imported LARA and JS scripts in the same context, to help keep things organized, */ /* Furthermore, since importing will evaluate all imported LARA and JS scripts in the same context, to help keep things organized, */
  
-We highly recommend that LARA/JS scripts declare a single global variable or class with the same name as the script (e.g., file Query.js/.lara declares a new class/aspect Query). +We highly recommend that LARA/JS scripts declare a single global variable or class with the same name as the script (e.g., file Query.js/.lara declares a new class/aspect Query).
  
  
-==== Regular Expressions ====+===== Regular Expressions =====
  
 Lara supports JavaScript regular expressions, for instance: Lara supports JavaScript regular expressions, for instance:
Line 54: Line 54:
 </code> </code>
  
-==== Importing LARA Files ====+===== Importing LARA Files =====
  
 LARA supports importing LARA files (with extension .lara) that are present in the include path (flag -i) using the keyword **import**. To import a file, you have to use the path to the file from the include folder, using '.' as separator and omitting the extension of the file. For instance, if you add as include the folder ~/foo and you want to import the file ~/foo/bar/Aspect.lara, you can write the following code: LARA supports importing LARA files (with extension .lara) that are present in the include path (flag -i) using the keyword **import**. To import a file, you have to use the path to the file from the include folder, using '.' as separator and omitting the extension of the file. For instance, if you add as include the folder ~/foo and you want to import the file ~/foo/bar/Aspect.lara, you can write the following code:
Line 66: Line 66:
 Import statements must be the first statements in a LARA file. LARA weavers come bundled with support for a set of imports, which are part of their API (e.g., [[http://specs.fe.up.pt/tools/clava/doc/|Clava API]]). Import statements must be the first statements in a LARA file. LARA weavers come bundled with support for a set of imports, which are part of their API (e.g., [[http://specs.fe.up.pt/tools/clava/doc/|Clava API]]).
  
-==== Importing JS Files ====+===== Importing JS Files =====
  
 JS files that are present in an include path can be imported using the LARA keyword **import**. The same rules of importing of LARA files apply. For instance, if you add as include the folder ~/src-js and you want to import the file ~/src-js/bar/Foo.js, you can write the following code: JS files that are present in an include path can be imported using the LARA keyword **import**. The same rules of importing of LARA files apply. For instance, if you add as include the folder ~/src-js and you want to import the file ~/src-js/bar/Foo.js, you can write the following code:
Line 84: Line 84:
  
 /* Currently the LARA framework supports EcmaScript 2021 for JS files. */ /* Currently the LARA framework supports EcmaScript 2021 for JS files. */
-==== Reading/Writing JSON Files ====+===== Reading/Writing JSON Files =====
  
 LARA supports reading from and writing to JSON objects with the object **Io**: LARA supports reading from and writing to JSON objects with the object **Io**:
Line 99: Line 99:
  
  
-==== Testing the type of a join point ====+===== Testing the type of a join point =====
  
 All join points have the attribute ''.joinPointType'', which you might feel tempted to use to check the type of a join point, for further processing. However, it is highly preferable to use ''.instanceOf(<join_point_name>)'' instead. All join points have the attribute ''.joinPointType'', which you might feel tempted to use to check the type of a join point, for further processing. However, it is highly preferable to use ''.instanceOf(<join_point_name>)'' instead.
  
 This respects the join point hierarchy (e.g., "call" and "expr" can both return true) and is more robust than directly checking the name of the join point, i.e. ''$jp.joinPointType === "call"''. This respects the join point hierarchy (e.g., "call" and "expr" can both return true) and is more robust than directly checking the name of the join point, i.e. ''$jp.joinPointType === "call"''.
doc/lara/tips.1642277939.txt.gz ยท Last modified: 2022/01/15 20:18 by jbispo