<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/117516/">https://git.reviewboard.kde.org/r/117516/</a>
     </td>
    </tr>
   </table>
   <br />



 <p>Ship it!</p>



 <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Looks good. By the way, KDevelop requires C++11, so feel free to use e.g. auto as it seems appropriate.

Thanks!</pre>
 <br />









<p>- Sven Brauch</p>


<br />
<p>On April 12th, 2014, 6:36 p.m. UTC, Denis Steckelmacher wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for KDevelop.</div>
<div>By Denis Steckelmacher.</div>


<p style="color: grey;"><i>Updated April 12, 2014, 6:36 p.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kdev-qmljs
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">In Javascript, functions can be declared on their own (using "function foo() {}") or be anonymous and declared in an expression ("var f = function(){}", and also "setTimeout(function() { ... })"). This latter form is very common in Javascript, as callbacks are widely used.

ContextBuilder already supports function expressions (it correctly builds contexts for them and for their arguments). This patch adds support for function expressions in DeclarationBuilder and ExpressionVisitor. DeclarationBuilder builds anonymous declarations for the functions, and ExpressionVisitor uses the fact that anonymous functions open a context of which they are the owner in order to find their type.

When a function is declared, its return type is left to NULL. It is set to void only when DeclarationBuilder ends visiting a function expression or declaration. I do this because the next patch will add support for unsure types, and every return statement will add its type to the return type of the function, so this return type needs to be empty at the beginning of the function. Having all the functions returning "void or int" or "void or string" is useless.

This patch also fixes a small bug in return statements: "return;" was setting the return type of the function to "mixed" instead of "void", because ContextBuilder::findType returns mixed if the node passed as argument is NULL.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This patch adds various tests for function expressions. Here is an example of the expressions recognized:

var f = function() { return 2; };        // function int ()
var g = function(a, b) { return a + b; } // function mixed (mixed, mixed)
var a = (function() { return true; })(); // bool, the function has been called</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>duchain/declarationbuilder.h <span style="color: grey">(8d8f771)</span></li>

 <li>duchain/declarationbuilder.cpp <span style="color: grey">(1d5610e)</span></li>

 <li>duchain/expressionvisitor.h <span style="color: grey">(4e8ac29)</span></li>

 <li>duchain/expressionvisitor.cpp <span style="color: grey">(418f1a9)</span></li>

 <li>tests/files/helloworld.js <span style="color: grey">(df86d4f)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/117516/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>