{"id":1953,"date":"2019-04-12T09:53:07","date_gmt":"2019-04-12T13:53:07","guid":{"rendered":"http:\/\/codinggorilla.com\/?p=1953"},"modified":"2019-04-12T09:54:45","modified_gmt":"2019-04-12T13:54:45","slug":"series-on-program-transformation-systems-rose-2000","status":"publish","type":"post","link":"http:\/\/165.227.223.229\/index.php\/2019\/04\/12\/series-on-program-transformation-systems-rose-2000\/","title":{"rendered":"Series on program transformation systems: ROSE (2000)"},"content":{"rendered":"\n<p>This is the next entry in the series on program transformation systems. This article describes <a href=\"http:\/\/rosecompiler.org\/\">ROSE<\/a>, a compiler system for C, C++, Java, Python, PHP source code. It has been in development since 2000 and is actively being developed to this day. ROSE was developed at the <a class=\"\" href=\"https:\/\/www.llnl.gov\/\">Lawrence Livermore National Laboratory<\/a>.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>ROSE can be divided into several parts:<\/p>\n\n\n\n<ol><li>an AST representation, which is defined by SAGE III. Node types in the AST are predefined SAGE III classes, such as <g class=\"gr_ gr_521 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace\" id=\"521\" data-gr-id=\"521\">SgGlobal<\/g>, SgIfStmt, SgWhileStmt, SgVariableDeclaration, etc. (see  <br><a href=\"http:\/\/www.extreme.indiana.edu\/sage\/Doc-sage2\/Sage_Classes.html\">http:\/\/www.extreme.indiana.edu\/sage\/Doc-sage2\/Sage_Classes.html<\/a>). The ASTs generated by a language-specific frontend is converted into this generalized, universal AST representation. Users can create attributes for a node, but generally, one works with these hardwired types.<\/li><li>an AST traversal API. The traversal API provides several types of standard AST traversals: pre-order, post-order, and a &#8220;classic object-oriented visitor&#8221; which visits all nodes of an entire tree in no particular order.<\/li><li>an API for querying AST nodes. The main routine for querying tree nodes is NodeQuery::querySubTree(). Each AST node has a type, which you must then cast to the specific type required in order to use accessor functions for various attributes and children of the node.<\/li><li>an API to rewrite the AST, e.g., LowLevelRewrite::insert().<\/li><\/ol>\n\n\n\n<p>ROSE can be downloaded and run in a number of ways. The easiest method to run ROSE is by using a virtual machine image that LLNL provides. LLNL has a <a href=\"https:\/\/en.wikibooks.org\/wiki\/ROSE_Compiler_Framework\/Virtual_Machine_Image\">disclaimer<\/a> that says folks within LLNL cannot use the virtual machine (&#8220;WARNING: LLNL users may not be able to download &#8230;&#8221;)! Note: unpack the .gz file, then untar. You can use Virtual Box to run the virtual machine by selecting Ubuntu-ROSE-Demo-V3.vmdk. The virtual machine disk is over 20GB, so have plenty of disk space for the files.<\/p>\n\n\n\n<h2>Observations and notes<\/h2>\n\n\n\n<ul><li>ROSE is a low-level interface for performing program transformations on an AST. Each node in the AST is represented with a hard-wired C++ type, which means that it is inflexible.<\/li><li>The &#8220;query language&#8221; which the authors mention is a C++ API that appears to be only a simple &#8220;find nodes of a given type&#8221;. It isn&#8217;t clear how one would create a complex AST structure, which Piggy supports.<\/li><li>Each node must be typecasted to each SAGE III AST node in order to access attributes for that node. I don&#8217;t think one can use a string name to access an attribute on a generic SAGE III AST node. (Piggy does.)<\/li><li>There is no generalized tree query language as in Coccinelle or Piggy.<\/li><li>ROSE is written in 2+million lines of C++ code.<\/li><\/ul>\n\n\n\n<h2>References<\/h2>\n\n\n\n<p>Quinlan, D., 2000. ROSE: Compiler support for object-oriented frameworks. <em>Parallel Processing Letters<\/em>,&nbsp;<em>10<\/em>(02n03), pp.215-226. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the next entry in the series on program transformation systems. This article describes ROSE, a compiler system for C, C++, Java, Python, PHP source code. It has been in development since 2000 and is actively being developed to this day. ROSE was developed at the Lawrence Livermore National Laboratory.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/1953"}],"collection":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/comments?post=1953"}],"version-history":[{"count":0,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/1953\/revisions"}],"wp:attachment":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/media?parent=1953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/categories?post=1953"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/tags?post=1953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}