Lines Matching defs:Mirror
32 // Mirror cache.
37 * Clear the mirror handle cache.
46 * Returns the mirror for a specified value or object.
48 * @param {value or Object} value the value or object to retreive the mirror for
50 * should not be added to the mirror cache. The default is not transient.
51 * @returns {Mirror} the mirror reflects the passed value or object
54 var mirror;
56 // Look for non transient mirrors in the mirror cache.
59 mirror = mirror_cache_[id];
60 if (mirror.value() === value) {
61 return mirror;
64 if (mirror.isNumber() && isNaN(mirror.value()) &&
66 return mirror;
72 mirror = new UndefinedMirror();
74 mirror = new NullMirror();
76 mirror = new BooleanMirror(value);
78 mirror = new NumberMirror(value);
80 mirror = new StringMirror(value);
82 mirror = new ArrayMirror(value);
84 mirror = new DateMirror(value);
86 mirror = new FunctionMirror(value);
88 mirror = new RegExpMirror(value);
90 mirror = new ErrorMirror(value);
92 mirror = new ScriptMirror(value);
94 mirror = new ObjectMirror(value, OBJECT_TYPE, opt_transient);
97 mirror_cache_[mirror.handle()] = mirror;
98 return mirror;
103 * Returns the mirror for a specified mirror handle.
105 * @param {number} handle the handle to find the mirror for
106 * @returns {Mirror or undefiend} the mirror with the requested handle or
107 * undefined if no mirror with the requested handle was found
115 * Returns the mirror for the undefined value.
117 * @returns {Mirror} the mirror reflects the undefined value
131 * expected during bootstrapping (see mirror.js in r114903).
202 // Mirror hierarchy:
203 // - Mirror
222 * Base class for all mirror objects.
223 * @param {string} type The type of the mirror
226 function Mirror(type) {
231 Mirror.prototype.type = function() {
237 * Check whether the mirror reflects a value.
238 * @returns {boolean} True if the mirror reflects a value.
240 Mirror.prototype.isValue = function() {
246 * Check whether the mirror reflects the undefined value.
247 * @returns {boolean} True if the mirror reflects the undefined value.
249 Mirror.prototype.isUndefined = function() {
255 * Check whether the mirror reflects the null value.
256 * @returns {boolean} True if the mirror reflects the null value
258 Mirror.prototype.isNull = function() {
264 * Check whether the mirror reflects a boolean value.
265 * @returns {boolean} True if the mirror reflects a boolean value
267 Mirror.prototype.isBoolean = function() {
273 * Check whether the mirror reflects a number value.
274 * @returns {boolean} True if the mirror reflects a number value
276 Mirror.prototype.isNumber = function() {
282 * Check whether the mirror reflects a string value.
283 * @returns {boolean} True if the mirror reflects a string value
285 Mirror.prototype.isString = function() {
291 * Check whether the mirror reflects an object.
292 * @returns {boolean} True if the mirror reflects an object
294 Mirror.prototype.isObject = function() {
300 * Check whether the mirror reflects a function.
301 * @returns {boolean} True if the mirror reflects a function
303 Mirror.prototype.isFunction = function() {
309 * Check whether the mirror reflects an unresolved function.
310 * @returns {boolean} True if the mirror reflects an unresolved function
312 Mirror.prototype.isUnresolvedFunction = function() {
318 * Check whether the mirror reflects an array.
319 * @returns {boolean} True if the mirror reflects an array
321 Mirror.prototype.isArray = function() {
327 * Check whether the mirror reflects a date.
328 * @returns {boolean} True if the mirror reflects a date
330 Mirror.prototype.isDate = function() {
336 * Check whether the mirror reflects a regular expression.
337 * @returns {boolean} True if the mirror reflects a regular expression
339 Mirror.prototype.isRegExp = function() {
345 * Check whether the mirror reflects an error.
346 * @returns {boolean} True if the mirror reflects an error
348 Mirror.prototype.isError = function() {
354 * Check whether the mirror reflects a property.
355 * @returns {boolean} True if the mirror reflects a property
357 Mirror.prototype.isProperty = function() {
363 * Check whether the mirror reflects a stack frame.
364 * @returns {boolean} True if the mirror reflects a stack frame
366 Mirror.prototype.isFrame = function() {
372 * Check whether the mirror reflects a script.
373 * @returns {boolean} True if the mirror reflects a script
375 Mirror.prototype.isScript = function() {
381 * Check whether the mirror reflects a context.
382 * @returns {boolean} True if the mirror reflects a context
384 Mirror.prototype.isContext = function() {
390 * Check whether the mirror reflects a scope.
391 * @returns {boolean} True if the mirror reflects a scope
393 Mirror.prototype.isScope = function() {
401 Mirror.prototype.allocateHandle_ = function() {
410 Mirror.prototype.allocateTransientHandle_ = function() {
415 Mirror.prototype.toText = function() {
422 * Base class for all value mirror objects.
423 * @param {string} type The type of the mirror
424 * @param {value} value The value reflected by this mirror
428 * @extends Mirror
431 %_CallFunction(this, type, Mirror);
439 inherits(ValueMirror, Mirror);
442 Mirror.prototype.handle = function() {
449 * @return {boolean} True if the mirror reflects a primitive value
462 * Get the actual value reflected by this mirror.
463 * @return {value} The value reflected by this mirror
471 * Mirror object for Undefined.
487 * Mirror object for null.
503 * Mirror object for boolean values.
504 * @param {boolean} value The boolean value reflected by this mirror
520 * Mirror object for number values.
521 * @param {number} value The number value reflected by this mirror
537 * Mirror object for string values.
538 * @param {string} value The string value reflected by this mirror
566 * Mirror object for objects.
567 * @param {object} value The object reflected by this mirror
718 * @param {Mirror} value The property value to look for
751 Mirror.prototype, opt_max_objects || 0);
778 * Mirror object for functions.
779 * @param {function} value The function object reflected by this mirror.
905 * Mirror object for unresolved functions.
907 * mirror.
958 * Mirror object for arrays.
959 * @param {Array} value The Array object reflected by this mirror
995 * Mirror object for dates.
996 * @param {Date} value The Date object reflected by this mirror
1013 * Mirror object for regular expressions.
1014 * @param {RegExp} value The RegExp object reflected by this mirror
1067 * Mirror object for error objects.
1068 * @param {Error} value The error object reflected by this mirror
1100 * Base mirror object for properties.
1101 * @param {ObjectMirror} mirror The mirror object having this property
1105 * @extends Mirror
1107 function PropertyMirror(mirror, name, details) {
1108 %_CallFunction(this, PROPERTY_TYPE, Mirror);
1109 this.mirror_ = mirror;
1119 inherits(PropertyMirror, Mirror);
1201 * @return {Mirror} FunctionMirror reflecting the getter function or
1215 * @return {Mirror} FunctionMirror reflecting the setter function or
1420 * Mirror object for stack frames.
1425 * @extends Mirror
1428 %_CallFunction(this, FRAME_TYPE, Mirror);
1433 inherits(FrameMirror, Mirror);
1445 // Create a function mirror. NOTE: MakeMirror cannot be used here as the
1760 * Mirror object for scope.
1764 * @extends Mirror
1767 %_CallFunction(this, SCOPE_TYPE, Mirror);
1772 inherits(ScopeMirror, Mirror);
1791 // For local and closure scopes create a transient mirror as these objects are
1801 * Mirror object for script source.
1804 * @extends Mirror
1807 %_CallFunction(this, SCRIPT_TYPE, Mirror);
1812 inherits(ScriptMirror, Mirror);
1922 * Mirror object for context.
1925 * @extends Mirror
1928 %_CallFunction(this, CONTEXT_TYPE, Mirror);
1932 inherits(ContextMirror, Mirror);
1941 * Returns a mirror serializer
1947 * @returns {MirrorSerializer} mirror serializer
1955 * Object for serializing a mirror objects and its direct references.
1956 * @param {boolean} details Indicates whether to include details for the mirror
1971 * @param {Mirror} mirror The mirror to serialize
1974 JSONProtocolSerializer.prototype.serializeReference = function(mirror) {
1975 return this.serialize_(mirror, true, true);
1983 * @param {Mirror} mirror The mirror to serialize
1986 JSONProtocolSerializer.prototype.serializeValue = function(mirror) {
1987 var json = this.serialize_(mirror, false, true);
1995 * @param {Mirror} mirror The mirror to serialize.
2033 JSONProtocolSerializer.prototype.add_ = function(mirror) {
2034 // If this mirror is already in the list just return.
2036 if (this.mirrors_[i] === mirror) {
2041 // Add the mirror to the list of mirrors to be serialized.
2042 this.mirrors_.push(mirror);
2047 * Formats mirror object to protocol reference object with some data that can
2049 * @param {Mirror} mirror Mirror to serialize.
2053 function(mirror) {
2055 o.ref = mirror.handle();
2056 o.type = mirror.type();
2057 switch (mirror.type()) {
2062 o.value = mirror.value();
2065 o.value = mirror.getTruncatedValue(this.maxStringLength_());
2068 o.name = mirror.name();
2069 o.inferredName = mirror.inferredName();
2070 if (mirror.script()) {
2071 o.scriptId = mirror.script().id();
2076 o.value = mirror.toText();
2079 o.className = mirror.className();
2086 JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference,
2088 // If serializing a reference to a mirror just return the reference and add
2089 // the mirror to the referenced mirrors.
2091 (mirror.isValue() || mirror.isScript() || mirror.isContext())) {
2092 if (this.inlineRefs_() && mirror.isValue()) {
2093 return this.serializeReferenceWithDisplayData_(mirror);
2095 this.add_(mirror);
2096 return {'ref' : mirror.handle()};
2103 // Add the mirror handle.
2104 if (mirror.isValue() || mirror.isScript() || mirror.isContext()) {
2105 content.handle = mirror.handle();
2109 content.type = mirror.type();
2111 switch (mirror.type()) {
2119 content.value = mirror.value();
2124 content.value = NumberToJSON_(mirror.value());
2130 mirror.length() > this.maxStringLength_()) {
2131 var str = mirror.getTruncatedValue(this.maxStringLength_());
2136 content.value = mirror.value();
2138 content.length = mirror.length();
2146 this.serializeObject_(mirror, content, details);
2155 this.serializeFrame_(mirror, content);
2160 this.serializeScope_(mirror, content);
2165 if (mirror.name()) {
2166 content.name = mirror.name();
2168 content.id = mirror.id();
2169 content.lineOffset = mirror.lineOffset();
2170 content.columnOffset = mirror.columnOffset();
2171 content.lineCount = mirror.lineCount();
2172 if (mirror.data()) {
2173 content.data = mirror.data();
2176 content.source = mirror.source();
2178 var sourceStart = mirror.source().substring(0, 80);
2181 content.sourceLength = mirror.source().length;
2182 content.scriptType = mirror.scriptType();
2183 content.compilationType = mirror.compilationType();
2186 if (mirror.compilationType() == 1 &&
2187 mirror.evalFromScript()) {
2189 this.serializeReference(mirror.evalFromScript());
2190 var evalFromLocation = mirror.evalFromLocation();
2195 if (mirror.evalFromFunctionName()) {
2196 content.evalFromFunctionName = mirror.evalFromFunctionName();
2199 if (mirror.context()) {
2200 content.context = this.serializeReference(mirror.context());
2205 content.data = mirror.data();
2210 content.text = mirror.toText();
2228 JSONProtocolSerializer.prototype.serializeObject_ = function(mirror, content,
2231 content.className = mirror.className();
2233 this.serializeReference(mirror.constructorFunction());
2234 content.protoObject = this.serializeReference(mirror.protoObject());
2235 content.prototypeObject = this.serializeReference(mirror.prototypeObject());
2238 if (mirror.hasNamedInterceptor()) {
2241 if (mirror.hasIndexedInterceptor()) {
2246 if (mirror.isFunction()) {
2248 content.name = mirror.name();
2249 if (!IS_UNDEFINED(mirror.inferredName())) {
2250 content.inferredName = mirror.inferredName();
2252 content.resolved = mirror.resolved();
2253 if (mirror.resolved()) {
2254 content.source = mirror.source();
2256 if (mirror.script()) {
2257 content.script = this.serializeReference(mirror.script());
2258 content.scriptId = mirror.script().id();
2260 serializeLocationFields(mirror.sourceLocation(), content);
2265 if (mirror.isDate()) {
2267 content.value = mirror.value();
2271 var propertyNames = mirror.propertyNames(PropertyKind.Named);
2272 var propertyIndexes = mirror.propertyNames(PropertyKind.Indexed);
2275 var propertyMirror = mirror.property(propertyNames[i]);
2282 var propertyMirror = mirror.property(propertyIndexes[i]);
2356 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) {
2357 content.index = mirror.index();
2358 content.receiver = this.serializeReference(mirror.receiver());
2359 var func = mirror.func();
2364 content.constructCall = mirror.isConstructCall();
2365 content.atReturn = mirror.isAtReturn();
2366 if (mirror.isAtReturn()) {
2367 content.returnValue = this.serializeReference(mirror.returnValue());
2369 content.debuggerFrame = mirror.isDebuggerFrame();
2370 var x = new Array(mirror.argumentCount());
2371 for (var i = 0; i < mirror.argumentCount(); i++) {
2373 var argument_name = mirror.argumentName(i);
2377 arg.value = this.serializeReference(mirror.argumentValue(i));
2381 var x = new Array(mirror.localCount());
2382 for (var i = 0; i < mirror.localCount(); i++) {
2384 local.name = mirror.localName(i);
2385 local.value = this.serializeReference(mirror.localValue(i));
2389 serializeLocationFields(mirror.sourceLocation(), content);
2390 var source_line_text = mirror.sourceLineText();
2396 for (var i = 0; i < mirror.scopeCount(); i++) {
2397 var scope = mirror.scope(i);
2406 JSONProtocolSerializer.prototype.serializeScope_ = function(mirror, content) {
2407 content.index = mirror.scopeIndex();
2408 content.frameIndex = mirror.frameIndex();
2409 content.type = mirror.scopeType();
2411 this.serializeValue(mirror.scopeObject()) :
2412 this.serializeReference(mirror.scopeObject());