[gjs/wip/ptomato/mozjs52: 28/45] coverage: Misc Javascript-side API changes



commit 8be6afa667c587faeec910b29c4bfa14f496eff1
Author: Philip Chimento <philip chimento gmail com>
Date:   Wed Mar 22 15:37:09 2017 +0000

    coverage: Misc Javascript-side API changes
    
    Debugger.Script.getOffsetLine() which we previously used in code coverage
    is gone now, replaced by Debugger.Script.getOffsetLocation() which gives
    more information. We don't currently take advantage of the extra
    information.
    
    ArrowExpression was renamed to ArrowFunctionExpression.

 modules/coverage.js |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/modules/coverage.js b/modules/coverage.js
index 34718cc..7bbde49 100644
--- a/modules/coverage.js
+++ b/modules/coverage.js
@@ -92,7 +92,7 @@ function getSubNodesForNode(node) {
                 subNodes.push(elem);
         });
         break;
-    case 'ArrowExpression':
+    case 'ArrowFunctionExpression':
         Array.prototype.push.apply(subNodes, node.defaults);
         subNodes.push(node.body);
         break;
@@ -222,7 +222,7 @@ function functionsForNode(node) {
     switch (node.type) {
     case 'FunctionDeclaration':
     case 'FunctionExpression':
-    case 'ArrowExpression':
+    case 'ArrowFunctionExpression':
         functionNames.push({ key: _getFunctionKeyFromReflectedFunction(node),
                              line: node.loc.start.line,
                              n_params: node.params.length });
@@ -924,19 +924,17 @@ function CoverageStatistics(prefixes, cache, shouldWarn) {
         /* Log function calls */
         if (frame.callee !== null && frame.callee.callable) {
             let name = frame.callee.name ? frame.callee.name : "(anonymous)";
-            let line = frame.script.getOffsetLine(frame.offset);
+            let {lineNumber} = frame.script.getOffsetLocation(frame.offset);
             let nArgs = frame.callee.parameterNames.length;
 
             try {
                 _incrementFunctionCounters(statistics.functionCounters,
                                            statistics.linesWithKnownFunctions,
-                                           name,
-                                           line,
-                                           nArgs);
+                                           name, lineNumber, nArgs);
             } catch (e) {
                 /* Something bad happened. Log the exception and delete
                  * statistics for this file */
-                _logExceptionAndReset(e, name, line);
+                _logExceptionAndReset(e, name, lineNumber);
                 return undefined;
             }
         }
@@ -948,17 +946,17 @@ function CoverageStatistics(prefixes, cache, shouldWarn) {
         frame.onStep = function() {
             /* Line counts */
             let offset = this.offset;
-            let offsetLine = this.script.getOffsetLine(offset);
+            let {lineNumber} = this.script.getOffsetLocation(offset);
 
             try {
                 _incrementExpressionCounters(statistics.expressionCounters,
                                              frame.script.url,
-                                             offsetLine, shouldWarn);
-                this._branchTracker.incrementBranchCounters(offsetLine);
+                                             lineNumber, shouldWarn);
+                this._branchTracker.incrementBranchCounters(lineNumber);
             } catch (e) {
                 /* Something bad happened. Log the exception and delete
                  * statistics for this file */
-                _logExceptionAndReset(e, frame.callee, offsetLine);
+                _logExceptionAndReset(e, frame.callee, lineNumber);
             }
         };
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]