[gjs/wip/ptomato/mozjs45prep: 32/36] coverage: Misc Javascript-side API changes



commit 5d708838a20628e7b5cd4edd99a4b5054fa2d250
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 d01b378..0ed3407 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;
@@ -219,7 +219,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 });
@@ -921,19 +921,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;
             }
         }
@@ -945,17 +943,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]