@@ -23,12 +23,9 @@ module.exports = {
23
23
24
24
var ScopeType = require ( 'vm' ) . runInDebugContext ( 'ScopeType' ) ;
25
25
var assert = require ( 'assert' ) ;
26
- var semver = require ( 'semver' ) ;
27
26
var util = require ( 'util' ) ;
28
27
var lodash = require ( 'lodash' ) ;
29
- var find = lodash . find ;
30
28
var transform = lodash . transform ;
31
- var remove = lodash . remove ;
32
29
var flatten = lodash . flatten ;
33
30
var isEmpty = lodash . isEmpty ;
34
31
@@ -302,23 +299,13 @@ StateResolver.prototype.resolveFrame_ = function(frame, underFrameCap) {
302
299
varTableIndex : ARG_LOCAL_LIMIT_MESSAGE_INDEX
303
300
} ) ;
304
301
} else {
305
- args = this . extractArgumentsList_ ( frame ) ;
302
+ // We will use the values aggregated from the ScopeMirror traversal stored
303
+ // in locals which will include any applicable arguments from the invocation.
304
+ args = [ ] ;
306
305
locals = this . resolveLocalsList_ ( frame , args ) ;
307
306
if ( isEmpty ( locals ) ) {
308
307
locals = [ ] ;
309
308
}
310
- if ( semver . satisfies ( process . version , '<1.6' ) ) {
311
- // If the node version is over 1.6 we do not read the frame arguments since
312
- // the values produced by the frame for the arguments may contain inaccurate
313
- // values. If the version is lower than 1.6, though, the frame's argument
314
- // list can be relied upon to produce accurate values for arguments.
315
- args = ! isEmpty ( args ) ? this . resolveArgumentList_ ( args ) : [ ] ;
316
- } else {
317
- // Otherwise, if the version is 1.6 or higher than we will use the values
318
- // aggregated from the ScopeMirror traversal stored in locals which will
319
- // include any applicable arguments from the invocation.
320
- args = [ ] ;
321
- }
322
309
}
323
310
return {
324
311
function : this . resolveFunctionName_ ( frame . func ( ) ) ,
@@ -355,13 +342,6 @@ StateResolver.prototype.extractArgumentsList_ = function (frame) {
355
342
return args ;
356
343
} ;
357
344
358
- StateResolver . prototype . resolveArgumentList_ = function ( args ) {
359
- var resolveVariable = this . resolveVariable_ . bind ( this ) ;
360
- return args . map ( function ( arg ) {
361
- return resolveVariable ( arg . name , arg . value ) ;
362
- } ) ;
363
- } ;
364
-
365
345
/**
366
346
* Iterates and returns variable information for all scopes (excluding global)
367
347
* in a given frame. FrameMirrors should return their scope object list with
@@ -396,34 +376,7 @@ StateResolver.prototype.resolveLocalsList_ = function (frame, args) {
396
376
scope . details ( ) . object ( ) ,
397
377
function ( locals , value , name ) {
398
378
var trg = makeMirror ( value ) ;
399
- var argMatch = find ( args , { name : name } ) ;
400
- if ( argMatch && ( semver . satisfies ( process . version , '<1.6' ) ) ) {
401
- // If the version is lower than 1.6 we will use the frame's argument
402
- // list to source argument values, yet the ScopeMirror traversal for
403
- // these Node versions will also return the arguments. Therefore, on
404
- // these versions, compare the value sourced as the argument from
405
- // the FrameMirror to the argument found in the ScopeMirror locals
406
- // list with the same name and attempt to determine whether or not
407
- // they have the same value. If each of these items has the same
408
- // name and value we may assume that the ScopeMirror variable
409
- // representation is merely a duplicate of the FrameMirror's
410
- // variable representation. Otherwise, the variable may have been
411
- // redeclared or reassigned in the function and is therefore a local
412
- // triggering removal from the arguments list and insertion into the
413
- // locals list.
414
- if ( argMatch . value . value ( ) === trg . value ( ) ) {
415
- // Argument ref is the same ref as the local ref - this is an
416
- // argument do not push this into the locals list
417
- return locals ;
418
- }
419
- // There is another local/scope var with the same name and it is not
420
- // the argument so this will take precedence. Remove the same-named
421
- // entry from the arguments list and push the local value onto the
422
- // locals list.
423
- remove ( args , { name : name } ) ;
424
- usedNames [ name ] = true ;
425
- locals . push ( self . resolveVariable_ ( name , trg ) ) ;
426
- } else if ( ! usedNames [ name ] ) {
379
+ if ( ! usedNames [ name ] ) {
427
380
// It's a valid variable that belongs in the locals list and wasn't
428
381
// discovered at a lower-scope
429
382
usedNames [ name ] = true ;
@@ -507,55 +460,9 @@ StateResolver.prototype.storeObjectToVariableTable_ = function(obj) {
507
460
508
461
/**
509
462
* Responsible for recursively resolving the properties on a
510
- * provided object mirror. Due to a bug in early node versions,
511
- * we maintain two implementations using the fast approach
512
- * for supported node versions.
513
- *
514
- * See https://github.com/iojs/io.js/issues/1190.
463
+ * provided object mirror.
515
464
*/
516
465
StateResolver . prototype . resolveMirror_ = function ( mirror ) {
517
- if ( semver . satisfies ( process . version , '<1.6' ) ) {
518
- return this . resolveMirrorSlow_ ( mirror ) ;
519
- } else {
520
- return this . resolveMirrorFast_ ( mirror ) ;
521
- }
522
- } ;
523
-
524
- // A slower implementation of resolveMirror_ which is safe for all node versions
525
- StateResolver . prototype . resolveMirrorSlow_ = function ( mirror ) {
526
- // Instead, let's use Object.keys. This will only get the enumerable
527
- // properties. The other alternative would be Object.getOwnPropertyNames, but
528
- // I'm going with the former as that's what util.inspect does.
529
- var that = this ;
530
-
531
- var keys = Object . keys ( mirror . value ( ) ) ;
532
- var maxProps = that . config_ . capture . maxProperties ;
533
- var truncate = maxProps && keys . length > maxProps ;
534
- if ( truncate ) {
535
- keys = keys . slice ( 0 , maxProps ) ;
536
- }
537
- var members = keys . map ( function ( prop ) {
538
- return that . resolveMirrorProperty_ ( mirror . property ( prop ) ) ;
539
- } ) ;
540
- if ( truncate ) {
541
- members . push ( { name : 'Only first `config.capture.maxProperties=' +
542
- this . config_ . capture . maxProperties +
543
- '` properties were captured' } ) ;
544
- }
545
-
546
- var mirrorVal = mirror . value ( ) ;
547
- var len = mirrorVal && mirrorVal . length ;
548
- return {
549
- value : mirror . toText ( ) +
550
- ( ( typeof len === 'undefined' ) ? '' : ' of length ' + len ) ,
551
- members : members
552
- } ;
553
- } ;
554
-
555
- // A faster implementation of resolveMirror_ which segfaults in node <1.6
556
- //
557
- // See https://github.com/iojs/io.js/issues/1190.
558
- StateResolver . prototype . resolveMirrorFast_ = function ( mirror ) {
559
466
var properties = mirror . properties ( ) ;
560
467
var maxProps = this . config_ . capture . maxProperties ;
561
468
var truncate = maxProps && properties . length > maxProps ;
0 commit comments