@@ -26,6 +26,10 @@ var semver = require('semver');
2626
2727var StatusMessage = require ( './apiclasses.js' ) . StatusMessage ;
2828
29+ var BUFFER_FULL_MESSAGE_INDEX = 0 ;
30+ var NATIVE_PROPERTY_MESSAGE_INDEX = 1 ;
31+ var GETTER_MESSAGE_INDEX = 2 ;
32+
2933// TODO: document this file
3034
3135// returns an object with three fields: stacksframes,
@@ -79,13 +83,17 @@ function StateResolver(execState, expressions, config) {
7983 this . evaluatedExpressions_ = [ ] ;
8084 this . totalSize_ = 0 ;
8185
82- // The 0-th object in the variable table is a sentinel 'buffer full' error
83- // message value
84- this . rawVariableTable_ = [ null ] ;
85- this . resolvedVariableTable_ = [
86+ this . rawVariableTable_ = [ null , null , null ] ;
87+ this . resolvedVariableTable_ = [ ] ;
88+ this . resolvedVariableTable_ [ BUFFER_FULL_MESSAGE_INDEX ] =
89+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
90+ 'Max data size reached' , true ) } ;
91+ this . resolvedVariableTable_ [ NATIVE_PROPERTY_MESSAGE_INDEX ] =
92+ { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
93+ 'Native properties are not available' , true ) } ;
94+ this . resolvedVariableTable_ [ GETTER_MESSAGE_INDEX ] =
8695 { status : new StatusMessage ( StatusMessage . VARIABLE_VALUE ,
87- 'Buffer full' , true ) }
88- ] ;
96+ 'Properties with getters are not available' , true ) } ;
8997}
9098
9199
@@ -114,7 +122,7 @@ StateResolver.prototype.capture = function() {
114122 }
115123
116124 // Now resolve the variables
117- var index = 1 ; // skip the sentinel value
125+ var index = 3 ; // skip the sentinel values
118126 while ( index < that . rawVariableTable_ . length && // NOTE: length changes in loop
119127 that . totalSize_ < that . config_ . capture . maxDataSize ) {
120128 assert ( ! that . resolvedVariableTable_ [ index ] ) ; // shouldn't have it resolved yet
@@ -145,7 +153,7 @@ StateResolver.prototype.trimVariableTable_ = function(fromIndex, frames) {
145153 variables . forEach ( function ( variable ) {
146154 if ( variable . varTableIndex && variable . varTableIndex >= fromIndex ) {
147155 // make it point to the sentinel 'buffer full' value
148- variable . varTableIndex = 0 ;
156+ variable . varTableIndex = BUFFER_FULL_MESSAGE_INDEX ;
149157 }
150158 if ( variable . members ) {
151159 processBufferFull ( variable . members ) ;
@@ -365,7 +373,7 @@ StateResolver.prototype.resolveMirrorSlow_ = function(mirror) {
365373 keys = keys . slice ( 0 , that . config_ . capture . maxProperties ) ;
366374 }
367375 var members = keys . map ( function ( prop ) {
368- return that . resolveVariable_ ( prop , mirror . property ( prop ) . value ( ) ) ;
376+ return that . resolveMirrorProperty_ ( mirror . property ( prop ) ) ;
369377 } ) ;
370378
371379 return {
@@ -386,11 +394,23 @@ StateResolver.prototype.resolveMirrorFast_ = function(mirror) {
386394 } ;
387395} ;
388396StateResolver . prototype . getMirrorProperties_ = function ( mirror ) {
389- var numProperties = this . config_ . capture . maxProperties || 1000 ;
397+ var numProperties = this . config_ . capture . maxProperties ;
390398 var namedProperties = mirror . properties ( 1 , numProperties ) ;
391399 var indexedProperties = mirror . properties ( 2 , numProperties ) ;
392400 return namedProperties . concat ( indexedProperties ) ;
393401} ;
394402StateResolver . prototype . resolveMirrorProperty_ = function ( property ) {
403+ if ( property . isNative ( ) ) {
404+ return {
405+ name : property . name ( ) ,
406+ varTableIndex : NATIVE_PROPERTY_MESSAGE_INDEX
407+ } ;
408+ }
409+ if ( property . hasGetter ( ) ) {
410+ return {
411+ name : property . name ( ) ,
412+ varTableIndex : GETTER_MESSAGE_INDEX
413+ } ;
414+ }
395415 return this . resolveVariable_ ( property . name ( ) , property . value ( ) ) ;
396416} ;
0 commit comments