@0ria/constant-folding
Version:
749 lines (192 loc) • 8.12 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Global</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2></h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="constantFolding"><span class="type-signature"></span>constantFolding<span class="signature">(code)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
This function get passed some code and then it forms an AST tree with it.
After it traverses the tree doing constant folding in different nodes in
which it is possible to perform it
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>code</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">The javascript input code</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="constant-folding.js.html">constant-folding.js</a>, <a href="constant-folding.js.html#line71">line 71</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Generated js code from the resultant tree
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="getValues"><span class="type-signature"></span>getValues<span class="signature">(elem)</span><span class="type-signature"> → {*}</span></h4>
<div class="description">
This function gets passed by a Node and depending on its type will perform
different operations.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>elem</code></td>
<td class="type">
<span class="param-type">Obect</span>
</td>
<td class="description last">Single subNode</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="constant-folding.js.html">constant-folding.js</a>, <a href="constant-folding.js.html#line18">line 18</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Return single element from passed Node
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
<h4 class="name" id="transLiteralNode"><span class="type-signature"></span>transLiteralNode<span class="signature">(n)</span><span class="type-signature"></span></h4>
<div class="description">
This Function takes a Node of type BinaryExpression and perform constant Folding on it
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Node with a type of BinaryExpression</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="constant-folding.js.html">constant-folding.js</a>, <a href="constant-folding.js.html#line56">line 56</a>
</li></ul></dd>
</dl>
<h4 class="name" id="transNode"><span class="type-signature"></span>transNode<span class="signature">(n, args)</span><span class="type-signature"></span></h4>
<div class="description">
This function gets passed two arguments and perform a transformation in the node
depending different parameters. Then it creates a new node object that will substitute
the passed one.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Node object in which constant folding will be applied</td>
</tr>
<tr>
<td class="name"><code>args</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last">Possible arguments this node has ex: [a].concat([b]), [b] are the args here</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="constant-folding.js.html">constant-folding.js</a>, <a href="constant-folding.js.html#line35">line 35</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#constantFolding">constantFolding</a></li><li><a href="global.html#getValues">getValues</a></li><li><a href="global.html#transLiteralNode">transLiteralNode</a></li><li><a href="global.html#transNode">transNode</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Thu Mar 10 2022 20:48:02 GMT+0000 (Coordinated Universal Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>