⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mirror-delay.js.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
    return this.value_;  }}/** * Mirror object for objects. * @param {object} value The object reflected by this mirror * @constructor * @extends ValueMirror */function ObjectMirror(value, type) {  ValueMirror.call(this, type || OBJECT_TYPE, value);};inherits(ObjectMirror, ValueMirror);ObjectMirror.prototype.className = function() {  return %ClassOf(this.value_);};ObjectMirror.prototype.constructorFunction = function() {  return MakeMirror(%DebugGetProperty(this.value_, 'constructor'));};ObjectMirror.prototype.prototypeObject = function() {  return MakeMirror(%DebugGetProperty(this.value_, 'prototype'));};ObjectMirror.prototype.protoObject = function() {  return MakeMirror(%GetPrototype(this.value_));};ObjectMirror.prototype.hasNamedInterceptor = function() {  // Get information on interceptors for this object.  var x = %DebugInterceptorInfo(this.value_);  return (x & 2) != 0;};ObjectMirror.prototype.hasIndexedInterceptor = function() {  // Get information on interceptors for this object.  var x = %DebugInterceptorInfo(this.value_);  return (x & 1) != 0;};/** * Return the property names for this object. * @param {number} kind Indicate whether named, indexed or both kinds of *     properties are requested * @param {number} limit Limit the number of names returend to the specified       value * @return {Array} Property names for this object */ObjectMirror.prototype.propertyNames = function(kind, limit) {  // Find kind and limit and allocate array for the result  kind = kind || PropertyKind.Named | PropertyKind.Indexed;  var propertyNames;  var elementNames;  var total = 0;  if (kind & PropertyKind.Named) {    propertyNames = %DebugLocalPropertyNames(this.value_);    total += propertyNames.length;  }  if (kind & PropertyKind.Indexed) {    elementNames = %DebugLocalElementNames(this.value_)    total += elementNames.length;  }  limit = Math.min(limit || total, total);  var names = new Array(limit);  var index = 0;    // Copy names for named properties.  if (kind & PropertyKind.Named) {    for (var i = 0; index < limit && i < propertyNames.length; i++) {      names[index++] = propertyNames[i];    }  }    // Copy names for indexed properties.  if (kind & PropertyKind.Indexed) {    for (var i = 0; index < limit && i < elementNames.length; i++) {      names[index++] = elementNames[i];    }  }  return names;};/** * Return the properties for this object as an array of PropertyMirror objects. * @param {number} kind Indicate whether named, indexed or both kinds of *     properties are requested * @param {number} limit Limit the number of properties returend to the       specified value * @return {Array} Property mirrors for this object */ObjectMirror.prototype.properties = function(kind, limit) {  var names = this.propertyNames(kind, limit);  var properties = new Array(names.length);  for (var i = 0; i < names.length; i++) {    properties[i] = this.property(names[i]);  }  return properties;};/** * Return the interceptor property names for this object. * @param {number} kind Indicate whether named, indexed or both kinds of *     interceptor properties are requested * @param {number} limit Limit the number of names returend to the specified       value * @return {Array} interceptor property names for this object */ObjectMirror.prototype.interceptorPropertyNames = function(kind, limit) {  // Find kind.  kind = kind || PropertyKind.Named | PropertyKind.Indexed;  var namedInterceptorNames;  var indexedInterceptorNames;  // Get names for named interceptor properties.  if (this.hasNamedInterceptor() && kind & PropertyKind.Named) {    namedInterceptorNames = %DebugNamedInterceptorPropertyNames(this.value_);  }    // Get names for indexed interceptor properties.  if (this.hasIndexedInterceptor() && kind & PropertyKind.Indexed) {    indexedInterceptorNames = %DebugIndexedInterceptorElementNames(this.value_);  }  // Return either retult or both concattenated.  if (namedInterceptorNames && indexedInterceptorNames) {    return namedInterceptorNames.concat(indexedInterceptorNames);  } else if (namedInterceptorNames) {    return namedInterceptorNames;  } else if (indexedInterceptorNames) {    return indexedInterceptorNames;  } else {    return new Array(0);  }};/** * Return interceptor properties this object. * @param {number} opt_kind Indicate whether named, indexed or both kinds of *     interceptor properties are requested * @param {Array} opt_names Limit the number of properties returned to the       specified value * @return {Array} properties this object as an array of PropertyMirror objects */ObjectMirror.prototype.interceptorProperties = function(opt_kind, opt_names) {  // Find kind.  var kind = opt_kind || PropertyKind.Named | PropertyKind.Indexed;  var namedInterceptorProperties;  var indexedInterceptorProperties;    // Get values for named interceptor properties.  if (kind & PropertyKind.Named) {    var names = opt_names || this.interceptorPropertyNames(PropertyKind.Named);    namedInterceptorProperties = new Array(names.length);    for (i = 0; i < names.length; i++) {      var value = %DebugNamedInterceptorPropertyValue(this.value_, names[i]);      namedInterceptorProperties[i] = new InterceptorPropertyMirror(this, names[i], value);    }  }    // Get values for indexed interceptor properties.  if (kind & PropertyKind.Indexed) {    var names = opt_names || this.interceptorPropertyNames(PropertyKind.Indexed);    indexedInterceptorProperties = new Array(names.length);    for (i = 0; i < names.length; i++) {      // Don't try to get the value if the name is not a number.      if (IS_NUMBER(names[i])) {        var value = %DebugIndexedInterceptorElementValue(this.value_, names[i]);        indexedInterceptorProperties[i] = new InterceptorPropertyMirror(this, names[i], value);      }    }  }  // Return either result or both concattenated.  if (namedInterceptorProperties && indexedInterceptorProperties) {    return namedInterceptorProperties.concat(indexedInterceptorProperties);  } else if (namedInterceptorProperties) {    return namedInterceptorProperties;  } else {    return indexedInterceptorProperties;  }};ObjectMirror.prototype.property = function(name) {  var details = %DebugGetLocalPropertyDetails(this.value_, %ToString(name));  if (details) {    return new PropertyMirror(this, name, details[0], details[1]);  }  // Nothing found.  return new UndefinedMirror();};/** * Try to find a property from its value. * @param {Mirror} value The property value to look for * @return {PropertyMirror} The property with the specified value. If no *     property was found with the specified value UndefinedMirror is returned */ObjectMirror.prototype.lookupProperty = function(value) {  var properties = this.properties();  // Look for property value in properties.  for (var i = 0; i < properties.length; i++) {    // Skip properties which are defined through assessors.    var property = properties[i];    if (property.propertyType() != PropertyType.Callbacks) {      if (%_ObjectEquals(property.value_, value.value_)) {        return property;      }    }  }  // Nothing found.  return new UndefinedMirror();};/** * Returns objects which has direct references to this object * @param {number} opt_max_instances Optional parameter specifying the maximum *     number of instances to return. * @return {Array} The objects which has direct references to this object. */ObjectMirror.prototype.referencedBy = function(opt_max_instances) {  // Find all objects constructed from this function.  var result = %DebugReferencedBy(this.value_, Mirror.prototype, opt_max_instances || 0);  // Make mirrors for all the instances found.  for (var i = 0; i < result.length; i++) {    result[i] = MakeMirror(result[i]);  }  return result;};ObjectMirror.prototype.fillJSONProperties_ = function(content, kind, name, details) {  var propertyNames = this.propertyNames(kind);  var x = new Array(propertyNames.length);  for (var i = 0; i < propertyNames.length; i++) {    x[i] = this.property(propertyNames[i]).toJSONProtocol(details);  }  content.push(MakeJSONPair_(name || 'properties', ArrayToJSONArray_(x)));};ObjectMirror.prototype.fillJSONInterceptorProperties_ = function(content, kind, name, details) {  var propertyNames = this.interceptorPropertyNames(kind);  var x = new Array(propertyNames.length);  for (var i = 0; i < propertyNames.length; i++) {    x[i] = properties[i].toJSONProtocol(details);  }  content.push(MakeJSONPair_(name || 'interceptorProperties', ArrayToJSONArray_(x)));};ObjectMirror.prototype.fillJSON_ = function(content, details, propertiesKind, interceptorPropertiesKind) {  ObjectMirror.super_.fillJSONType_.call(this, content);  content.push(MakeJSONPair_('className', StringToJSON_(this.className())));  if (details) {    content.push(MakeJSONPair_('constructorFunction', this.constructorFunction().toJSONProtocol(false)));    content.push(MakeJSONPair_('protoObject', this.protoObject().toJSONProtocol(false)));    content.push(MakeJSONPair_('prototypeObject', this.prototypeObject().toJSONProtocol(false)));  }  if (details) {    this.fillJSONProperties_(content, propertiesKind)    if (interceptorPropertiesKind) {      this.fillJSONInterceptorProperties_(content, interceptorPropertiesKind)    }  }  if (this.hasNamedInterceptor()) {    content.push(MakeJSONPair_('namedInterceptor', BooleanToJSON_(true)));  }  if (this.hasIndexedInterceptor()) {    content.push(MakeJSONPair_('indexedInterceptor', BooleanToJSON_(true)));  }};ObjectMirror.prototype.toText = function() {  var name;  var ctor = this.constructorFunction();  if (ctor.isUndefined()) {    name = this.className();  } else {    name = ctor.name();    if (!name) {      name = this.className();    }  }  return '#<' + builtins.GetInstanceName(name) + '>';};/** * Mirror object for functions. * @param {function} value The function object reflected by this mirror. * @constructor * @extends ObjectMirror */function FunctionMirror(value) {  ObjectMirror.call(this, value, FUNCTION_TYPE);  this.resolved_ = true;};inherits(FunctionMirror, ObjectMirror);/** * Returns whether the function is resolved. * @return {boolean} True if the function is resolved. Unresolved functions can *     only originate as functions from stack frames */FunctionMirror.prototype.resolved = function() {  return this.resolved_;};/** * Returns the name of the function. * @return {string} Name of the function */FunctionMirror.prototype.name = function() {  return %FunctionGetName(this.value_);};/** * Returns the source code for the function. * @return {string or undefined} The source code for the function. If the *     function is not resolved undefined will be returned. */FunctionMirror.prototype.source = function() {  // Return source if function is resolved. Otherwise just fall through to  // return undefined.  if (this.resolved()) {    // This builtins function is context independant (only uses runtime    // calls and typeof.    return builtins.FunctionSourceString(this.value_);  }};/** * Returns the script object for the function. * @return {ScriptMirror or undefined} Script object for the function or *     undefined if the function has no script */FunctionMirror.prototype.script = function() {  // Return script if function is resolved. Otherwise just fall through  // to return undefined.  if (this.resolved()) {    var script = %FunctionGetScript(this.value_);    if (script) {      return new ScriptMirror(script);    }  }};/** * Returns objects constructed by this function. * @param {number} opt_max_instances Optional parameter specifying the maximum *     number of instances to return. * @return {Array or undefined} The objects constructed by this function. */FunctionMirror.prototype.constructedBy = function(opt_max_instances) {  if (this.resolved()) {    // Find all objects constructed from this function.    var result = %DebugConstructedBy(this.value_, opt_max_instances || 0);        // Make mirrors for all the instances found.    for (var i = 0; i < result.length; i++) {      result[i] = MakeMirror(result[i]);    }        return result;  } else {    return [];  }};FunctionMirror.prototype.fillJSON_ = function(content, details) {  // Fill JSON properties from parent (ObjectMirror).  FunctionMirror.super_.fillJSON_.call(this, content, details);  // Add function specific properties.  content.push(MakeJSONPair_('name', StringToJSON_(this.name())));  content.push(MakeJSONPair_('resolved', BooleanToJSON_(this.resolved())));  if (details && this.resolved()) {    content.push(MakeJSONPair_('source', StringToJSON_(this.source())));  }  if (this.script()) {    content.push(MakeJSONPair_('script', this.script().toJSONProtocol()));  }}FunctionMirror.prototype.toText = function() {  return this.source();}/** * Mirror object for unresolved functions. * @param {string} value The name for the unresolved function reflected by this *     mirror. * @constructor * @extends ObjectMirror */function UnresolvedFunctionMirror(value) {  // Construct this using the ValueMirror as an unresolved function is not a  // real object but just a string.  ValueMirror.call(this, FUNCTION_TYPE, value);  this.propertyCount_ = 0;  this.elementCount_ = 0;  this.resolved_ = false;};inherits(UnresolvedFunctionMirror, FunctionMirror);UnresolvedFunctionMirror.prototype.className = function() {  return 'Function';};UnresolvedFunctionMirror.prototype.constructorFunction = function() {  return new UndefinedMirror();};UnresolvedFunctionMirror.prototype.prototypeObject = function() {  return new UndefinedMirror();};UnresolvedFunctionMirror.prototype.protoObject = function() {  return new UndefinedMirror();};UnresolvedFunctionMirror.prototype.name = function() {  return this.value_;};UnresolvedFunctionMirror.prototype.propertyNames = function(kind, limit) {  return [];}/** * Mirror object for arrays. * @param {Array} value The Array object reflected by this mirror * @constructor * @extends ObjectMirror */function ArrayMirror(value) {  ObjectMirror.call(this, value);};inherits(ArrayMirror, ObjectMirror);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -