Home | History | Annotate | Download | only in src

Lines Matching defs:Mirror

9 // Mirror cache.
35 * Returns the mirror for a specified value or object.
37 * @param {value or Object} value the value or object to retreive the mirror for
39 * should not be added to the mirror cache. The default is not transient.
40 * @returns {Mirror} the mirror reflects the passed value or object
43 var mirror;
45 // Look for non transient mirrors in the mirror cache.
48 mirror = mirror_cache_[id];
49 if (mirror.value() === value) {
50 return mirror;
53 if (mirror.isNumber() && isNaN(mirror.value()) &&
55 return mirror;
61 mirror = new UndefinedMirror();
63 mirror = new NullMirror();
65 mirror = new BooleanMirror(value);
67 mirror = new NumberMirror(value);
69 mirror = new StringMirror(value);
71 mirror = new SymbolMirror(value);
73 mirror = new ArrayMirror(value);
75 mirror = new DateMirror(value);
77 mirror = new FunctionMirror(value);
79 mirror = new RegExpMirror(value);
81 mirror = new ErrorMirror(value);
83 mirror = new ScriptMirror(value);
85 mirror = new MapMirror(value);
87 mirror = new SetMirror(value);
89 mirror = new PromiseMirror(value);
91 mirror = new GeneratorMirror(value);
93 mirror = new ObjectMirror(value, OBJECT_TYPE, opt_transient);
96 if (mirror_cache_enabled_) mirror_cache_[mirror.handle()] = mirror;
97 return mirror;
102 * Returns the mirror for a specified mirror handle.
104 * @param {number} handle the handle to find the mirror for
105 * @returns {Mirror or undefiend} the mirror with the requested handle or
106 * undefined if no mirror with the requested handle was found
109 if (!mirror_cache_enabled_) throw new Error("Mirror cache is disabled");
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
228 * Base class for all mirror objects.
229 * @param {string} type The type of the mirror
232 function Mirror(type) {
237 Mirror.prototype.type = function() {
243 * Check whether the mirror reflects a value.
244 * @returns {boolean} True if the mirror reflects a value.
246 Mirror.prototype.isValue = function() {
252 * Check whether the mirror reflects the undefined value.
253 * @returns {boolean} True if the mirror reflects the undefined value.
255 Mirror.prototype.isUndefined = function() {
261 * Check whether the mirror reflects the null value.
262 * @returns {boolean} True if the mirror reflects the null value
264 Mirror.prototype.isNull = function() {
270 * Check whether the mirror reflects a boolean value.
271 * @returns {boolean} True if the mirror reflects a boolean value
273 Mirror.prototype.isBoolean = function() {
279 * Check whether the mirror reflects a number value.
280 * @returns {boolean} True if the mirror reflects a number value
282 Mirror.prototype.isNumber = function() {
288 * Check whether the mirror reflects a string value.
289 * @returns {boolean} True if the mirror reflects a string value
291 Mirror.prototype.isString = function() {
297 * Check whether the mirror reflects a symbol.
298 * @returns {boolean} True if the mirror reflects a symbol
300 Mirror.prototype.isSymbol = function() {
306 * Check whether the mirror reflects an object.
307 * @returns {boolean} True if the mirror reflects an object
309 Mirror.prototype.isObject = function() {
315 * Check whether the mirror reflects a function.
316 * @returns {boolean} True if the mirror reflects a function
318 Mirror.prototype.isFunction = function() {
324 * Check whether the mirror reflects an unresolved function.
325 * @returns {boolean} True if the mirror reflects an unresolved function
327 Mirror.prototype.isUnresolvedFunction = function() {
333 * Check whether the mirror reflects an array.
334 * @returns {boolean} True if the mirror reflects an array
336 Mirror.prototype.isArray = function() {
342 * Check whether the mirror reflects a date.
343 * @returns {boolean} True if the mirror reflects a date
345 Mirror.prototype.isDate = function() {
351 * Check whether the mirror reflects a regular expression.
352 * @returns {boolean} True if the mirror reflects a regular expression
354 Mirror.prototype.isRegExp = function() {
360 * Check whether the mirror reflects an error.
361 * @returns {boolean} True if the mirror reflects an error
363 Mirror.prototype.isError = function() {
369 * Check whether the mirror reflects a promise.
370 * @returns {boolean} True if the mirror reflects a promise
372 Mirror.prototype.isPromise = function() {
378 * Check whether the mirror reflects a generator object.
379 * @returns {boolean} True if the mirror reflects a generator object
381 Mirror.prototype.isGenerator = function() {
387 * Check whether the mirror reflects a property.
388 * @returns {boolean} True if the mirror reflects a property
390 Mirror.prototype.isProperty = function() {
396 * Check whether the mirror reflects an internal property.
397 * @returns {boolean} True if the mirror reflects an internal property
399 Mirror.prototype.isInternalProperty = function() {
405 * Check whether the mirror reflects a stack frame.
406 * @returns {boolean} True if the mirror reflects a stack frame
408 Mirror.prototype.isFrame = function() {
414 * Check whether the mirror reflects a script.
415 * @returns {boolean} True if the mirror reflects a script
417 Mirror.prototype.isScript = function() {
423 * Check whether the mirror reflects a context.
424 * @returns {boolean} True if the mirror reflects a context
426 Mirror.prototype.isContext = function() {
432 * Check whether the mirror reflects a scope.
433 * @returns {boolean} True if the mirror reflects a scope
435 Mirror.prototype.isScope = function() {
441 * Check whether the mirror reflects a map.
442 * @returns {boolean} True if the mirror reflects a map
444 Mirror.prototype.isMap = function() {
450 * Check whether the mirror reflects a set.
451 * @returns {boolean} True if the mirror reflects a set
453 Mirror.prototype.isSet = function() {
461 Mirror.prototype.allocateHandle_ = function() {
470 Mirror.prototype.allocateTransientHandle_ = function() {
475 Mirror.prototype.toText = function() {
482 * Base class for all value mirror objects.
483 * @param {string} type The type of the mirror
484 * @param {value} value The value reflected by this mirror
488 * @extends Mirror
491 %_CallFunction(this, type, Mirror);
499 inherits(ValueMirror, Mirror);
502 Mirror.prototype.handle = function() {
509 * @return {boolean} True if the mirror reflects a primitive value
523 * Get the actual value reflected by this mirror.
524 * @return {value} The value reflected by this mirror
532 * Mirror object for Undefined.
548 * Mirror object for null.
564 * Mirror object for boolean values.
565 * @param {boolean} value The boolean value reflected by this mirror
581 * Mirror object for number values.
582 * @param {number} value The number value reflected by this mirror
598 * Mirror object for string values.
599 * @param {string} value The string value reflected by this mirror
627 * Mirror object for a Symbol
630 * @extends Mirror
649 * Mirror object for objects.
650 * @param {object} value The object reflected by this mirror
823 * @param {Mirror} value The property value to look for
856 Mirror.prototype, opt_max_objects || 0);
922 * Mirror object for functions.
923 * @param {function} value The function object reflected by this mirror.
1073 * Mirror object for unresolved functions.
1075 * mirror.
1126 * Mirror object for arrays.
1127 * @param {Array} value The Array object reflected by this mirror
1163 * Mirror object for dates.
1164 * @param {Date} value The Date object reflected by this mirror
1181 * Mirror object for regular expressions.
1182 * @param {RegExp} value The RegExp object reflected by this mirror
1235 * Mirror object for error objects.
1236 * @param {Error} value The error object reflected by this mirror
1268 * Mirror
1368 * Mirror object for a Generator object.
1371 * @extends Mirror
1428 * Base mirror object for properties.
1429 * @param {ObjectMirror} mirror The mirror object having this property
1433 * @extends Mirror
1435 function PropertyMirror(mirror, name, details) {
1436 %_CallFunction(this, PROPERTY_TYPE, Mirror);
1437 this.mirror_ = mirror;
1448 inherits(PropertyMirror, Mirror);
1530 * @return {Mirror} FunctionMirror reflecting the getter function or
1544 * @return {Mirror} FunctionMirror reflecting the setter function or
1570 * Mirror object for internal properties. Internal property reflects properties
1576 * @extends Mirror
1579 %_CallFunction(this, INTERNAL_PROPERTY_TYPE, Mirror);
1583 inherits(InternalPropertyMirror, Mirror);
1784 * Mirror object for stack frames.
1789 * @extends Mirror
1792 %_CallFunction(this, FRAME_TYPE, Mirror);
1797 inherits(FrameMirror, Mirror);
1818 // Create a function mirror. NOTE: MakeMirror cannot be used here as the
2205 * Mirror object for scope of frame or function. Either frame or function must
2212 * @extends Mirror
2215 %_CallFunction(this, SCOPE_TYPE, Mirror);
2224 inherits(ScopeMirror, Mirror);
2248 // For local and closure scopes create a transient mirror as these objects are
2263 * Mirror object for script source.
2266 * @extends Mirror
2269 %_CallFunction(this, SCRIPT_TYPE, Mirror);
2274 inherits(ScriptMirror, Mirror);
2384 * Mirror object for context.
2387 * @extends Mirror
2390 %_CallFunction(this, CONTEXT_TYPE, Mirror);
2394 inherits(ContextMirror, Mirror);
2403 * Returns a mirror serializer
2409 * @returns {MirrorSerializer} mirror serializer
2417 * Object for serializing a mirror objects and its direct references.
2418 * @param {boolean} details Indicates whether to include details for the mirror
2433 * @param {Mirror} mirror The mirror to serialize
2436 JSONProtocolSerializer.prototype.serializeReference = function(mirror) {
2437 return this.serialize_(mirror, true, true);
2445 * @param {Mirror} mirror The mirror to serialize
2448 JSONProtocolSerializer.prototype.serializeValue = function(mirror) {
2449 var json = this.serialize_(mirror, false, true);
2457 * @param {Mirror} mirror The mirror to serialize.
2495 JSONProtocolSerializer.prototype.add_ = function(mirror) {
2496 // If this mirror is already in the list just return.
2498 if (this.mirrors_[i] === mirror) {
2503 // Add the mirror to the list of mirrors to be serialized.
2504 this.mirrors_.push(mirror);
2509 * Formats mirror object to protocol reference object with some data that can
2511 * @param {Mirror} mirror Mirror to serialize.
2515 function(mirror) {
2517 o.ref = mirror.handle();
2518 o.type = mirror.type();
2519 switch (mirror.type()) {
2524 o.value = mirror.value();
2527 o.value = mirror.getTruncatedValue(this.maxStringLength_());
2530 o.description = mirror.description();
2533 o.name = mirror.name();
2534 o.inferredName = mirror.inferredName();
2535 if (mirror.script()) {
2536 o.scriptId = mirror.script().id();
2541 o.value = mirror.toText();
2544 o.className = mirror.className();
2551 JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference,
2553 // If serializing a reference to a mirror just return the reference and add
2554 // the mirror to the referenced mirrors.
2556 (mirror.isValue() || mirror.isScript() || mirror.isContext())) {
2557 if (this.inlineRefs_() && mirror.isValue()) {
2558 return this.serializeReferenceWithDisplayData_(mirror);
2560 this.add_(mirror);
2561 return {'ref' : mirror.handle()};
2568 // Add the mirror handle.
2569 if (mirror.isValue() || mirror.isScript() || mirror.isContext()) {
2570 content.handle = mirror.handle();
2574 content.type = mirror.type();
2576 switch (mirror.type()) {
2584 content.value = mirror.value();
2589 content.value = NumberToJSON_(mirror.value());
2595 mirror.length() > this.maxStringLength_()) {
2596 var str = mirror.getTruncatedValue(this.maxStringLength_());
2601 content.value = mirror.value();
2603 content.length = mirror.length();
2607 content.description = mirror.description();
2617 this.serializeObject_(mirror, content, details);
2627 this.serializeFrame_(mirror, content);
2632 this.serializeScope_(mirror, content);
2637 if (mirror.name()) {
2638 content.name = mirror.name();
2640 content.id = mirror.id();
2641 content.lineOffset = mirror.lineOffset();
2642 content.columnOffset = mirror.columnOffset();
2643 content.lineCount = mirror.lineCount();
2644 if (mirror.data()) {
2645 content.data = mirror.data();
2648 content.source = mirror.source();
2650 var sourceStart = mirror.source().substring(0, 80);
2653 content.sourceLength = mirror.source().length;
2654 content.scriptType = mirror.scriptType();
2655 content.compilationType = mirror.compilationType();
2658 if (mirror.compilationType() == 1 &&
2659 mirror.evalFromScript()) {
2661 this.serializeReference(mirror.evalFromScript());
2662 var evalFromLocation = mirror.evalFromLocation();
2667 if (mirror.evalFromFunctionName()) {
2668 content.evalFromFunctionName = mirror.evalFromFunctionName();
2671 if (mirror.context()) {
2672 content.context = this.serializeReference(mirror.context());
2677 content.data = mirror.data();
2682 content.text = mirror.toText();
2701 JSONProtocolSerializer.prototype.serializeObject_ = function(mirror, content,
2704 content.className = mirror.className();
2706 this.serializeReference(mirror.constructorFunction());
2707 content.protoObject = this.serializeReference(mirror.protoObject());
2708 content.prototypeObject = this.serializeReference(mirror.prototypeObject());
2711 if (mirror.hasNamedInterceptor()) {
2714 if (mirror.hasIndexedInterceptor()) {
2718 if (mirror.isFunction()) {
2720 content.name = mirror.name();
2721 if (!IS_UNDEFINED(mirror.inferredName())) {
2722 content.inferredName = mirror.inferredName();
2724 content.resolved = mirror.resolved();
2725 if (mirror.resolved()) {
2726 content.source = mirror.source();
2728 if (mirror.script()) {
2729 content.script = this.serializeReference(mirror.script());
2730 content.scriptId = mirror.script().id();
2732 serializeLocationFields(mirror.sourceLocation(), content);
2736 for (var i = 0; i < mirror.scopeCount(); i++) {
2737 var scope = mirror.scope(i);
2745 if (mirror.isGenerator()) {
2749 content.status = mirror.status();
2751 content.func = this.serializeReference(mirror.func())
2752 content.receiver = this.serializeReference(mirror.receiver())
2755 serializeLocationFields(mirror.sourceLocation(), content);
2760 if (mirror.isDate()) {
2762 content.value = mirror.value();
2765 if (mirror.isPromise()) {
2767 content.status = mirror.status();
2768 content.promiseValue = this.serializeReference(mirror.promiseValue());
2772 var propertyNames = mirror.propertyNames(PropertyKind.Named);
2773 var propertyIndexes = mirror.propertyNames(PropertyKind.Indexed);
2776 var propertyMirror = mirror.property(propertyNames[i]);
2783 var propertyMirror = mirror.property(propertyIndexes[i]);
2791 var internalProperties = mirror.internalProperties();
2893 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) {
2894 content.index = mirror.index();
2895 content.receiver = this.serializeReference(mirror.receiver());
2896 var func = mirror.func();
2902 content.constructCall = mirror.isConstructCall();
2903 content.atReturn = mirror.isAtReturn();
2904 if (mirror.isAtReturn()) {
2905 content.returnValue = this.serializeReference(mirror.returnValue());
2907 content.debuggerFrame = mirror.isDebuggerFrame();
2908 var x = new Array(mirror.argumentCount());
2909 for (var i = 0; i < mirror.argumentCount(); i++) {
2911 var argument_name = mirror.argumentName(i);
2915 arg.value = this.serializeReference(mirror.argumentValue(i));
2919 var x = new Array(mirror.localCount());
2920 for (var i = 0; i < mirror.localCount(); i++) {
2922 local.name = mirror.localName(i);
2923 local.value = this.serializeReference(mirror.localValue(i));
2927 serializeLocationFields(mirror.sourceLocation(), content);
2928 var source_line_text = mirror.sourceLineText();
2934 for (var i = 0; i < mirror.scopeCount(); i++) {
2935 var scope = mirror.scope(i);
2944 JSONProtocolSerializer.prototype.serializeScope_ = function(mirror, content) {
2945 content.index = mirror.scopeIndex();
2946 content.frameIndex = mirror.frameIndex();
2947 content.type = mirror.scopeType();
2949 this.serializeValue(mirror.scopeObject()) :
2950 this.serializeReference(mirror.scopeObject());