Index: src/mirror-delay.js |
=================================================================== |
--- src/mirror-delay.js (revision 1024) |
+++ src/mirror-delay.js (working copy) |
@@ -33,6 +33,12 @@ |
Date; |
+/** |
+ * Returns the mirror for a specified value or object. |
+ * |
+ * @param {value or Object} value the value or object to retreive the mirror for |
+ * @returns {Mirror} the mirror reflects the passed value or object |
+ */ |
function MakeMirror(value) { |
if (IS_UNDEFINED(value)) return new UndefinedMirror(); |
if (IS_NULL(value)) return new NullMirror(); |
@@ -106,7 +112,6 @@ |
PropertyType.NullDescriptor = 7; |
- |
// Different attributes for a property. |
PropertyAttribute = {}; |
PropertyAttribute.None = NONE; |
@@ -123,12 +128,12 @@ |
// - NumberMirror |
// - StringMirror |
// - ObjectMirror |
-// - FunctionMirror |
-// - UnresolvedFunctionMirror |
-// - ArrayMirror |
-// - DateMirror |
-// - RegExpMirror |
-// - ErrorMirror |
+// - FunctionMirror |
+// - UnresolvedFunctionMirror |
+// - ArrayMirror |
+// - DateMirror |
+// - RegExpMirror |
+// - ErrorMirror |
// - PropertyMirror |
// - InterceptorPropertyMirror |
// - AccessorMirror |
@@ -296,29 +301,24 @@ |
} |
-Mirror.prototype.fillJSONType_ = function(content) { |
- content.push(MakeJSONPair_('type', StringToJSON_(this.type()))); |
-}; |
+/** |
+ * Check whether the mirror reflects a script. |
+ * @returns {boolean} True if the mirror reflects a script |
+ */ |
+Mirror.prototype.isScript = function() { |
+ return this instanceof ScriptMirror; |
+} |
-Mirror.prototype.fillJSON_ = function(content) { |
- this.fillJSONType_(content); |
-}; |
- |
- |
/** |
- * Serialize object in JSON format. For the basic mirrors this includes only |
- * the type in the following format. |
- * {"type":"<type name>"} |
- * For specialized mirrors inheriting from the base Mirror |
+ * Serialize object in JSON format. The actual serialization is handled by the |
+ * JSONProtocolSerializer. |
* @param {boolean} details Indicate level of details to include |
* @return {string} JSON serialization |
*/ |
-Mirror.prototype.toJSONProtocol = function(details, propertiesKind, interceptorPropertiesKind) { |
- var content = new Array(); |
- this.fillJSON_(content, details, propertiesKind, interceptorPropertiesKind); |
- content.push(MakeJSONPair_('text', StringToJSON_(this.toText()))); |
- return ArrayToJSONObject_(content); |
+Mirror.prototype.toJSONProtocol = function(details) { |
+ var serializer = new JSONProtocolSerializer(details) |
+ return serializer.serialize(this) |
} |
@@ -409,12 +409,6 @@ |
inherits(BooleanMirror, ValueMirror); |
-BooleanMirror.prototype.fillJSON_ = function(content, details) { |
- BooleanMirror.super_.fillJSONType_.call(this, content); |
- content.push(MakeJSONPair_('value', BooleanToJSON_(this.value_))); |
-} |
- |
- |
BooleanMirror.prototype.toText = function() { |
return this.value_ ? 'true' : 'false'; |
} |
@@ -432,12 +426,6 @@ |
inherits(NumberMirror, ValueMirror); |
-NumberMirror.prototype.fillJSON_ = function(content, details) { |
- NumberMirror.super_.fillJSONType_.call(this, content); |
- content.push(MakeJSONPair_('value', NumberToJSON_(this.value_))); |
-} |
- |
- |
NumberMirror.prototype.toText = function() { |
return %NumberToString(this.value_); |
} |
@@ -460,21 +448,6 @@ |
}; |
-StringMirror.prototype.fillJSON_ = function(content, details) { |
- StringMirror.super_.fillJSONType_.call(this, content); |
- content.push(MakeJSONPair_('length', NumberToJSON_(this.length()))); |
- if (this.length() > kMaxProtocolStringLength) { |
- content.push(MakeJSONPair_('fromIndex', NumberToJSON_(0))); |
- content.push(MakeJSONPair_('toIndex', |
- NumberToJSON_(kMaxProtocolStringLength))); |
- var str = this.value_.substring(0, kMaxProtocolStringLength); |
- content.push(MakeJSONPair_('value', StringToJSON_(str))); |
- } else { |
- content.push(MakeJSONPair_('value', StringToJSON_(this.value_))); |
- } |
-} |
- |
- |
StringMirror.prototype.toText = function() { |
if (this.length() > kMaxProtocolStringLength) { |
return this.value_.substring(0, kMaxProtocolStringLength) + |
@@ -738,49 +711,6 @@ |
}; |
-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(); |
@@ -884,21 +814,6 @@ |
}; |
-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(); |
} |
@@ -988,18 +903,6 @@ |
} |
-ArrayMirror.prototype.fillJSON_ = function(content, details) { |
- // Fill JSON as for parent (ObjectMirror) but just with named properties. |
- ArrayMirror.super_.fillJSON_.call(this, content, details, PropertyKind.Named); |
- // Fill indexed properties seperately. |
- if (details) { |
- this.fillJSONProperties_(content, PropertyKind.Indexed, 'indexedProperties') |
- } |
- // Add the array length. |
- content.push(MakeJSONPair_('length', NumberToJSON_(this.length()))); |
-} |
- |
- |
/** |
* Mirror object for dates. |
* @param {Date} value The Date object reflected by this mirror |
@@ -1012,14 +915,6 @@ |
inherits(DateMirror, ObjectMirror); |
-DateMirror.prototype.fillJSON_ = function(content, details) { |
- // Fill JSON properties from parent (ObjectMirror). |
- DateMirror.super_.fillJSON_.call(this, content, details); |
- // Add date specific properties. |
- content.push(MakeJSONPair_('value', DateToJSON_(this.value_))); |
-} |
- |
- |
DateMirror.prototype.toText = function() { |
return DateToISO8601_(this.value_); |
} |
@@ -1073,17 +968,6 @@ |
}; |
-RegExpMirror.prototype.fillJSON_ = function(content, details) { |
- // Fill JSON properties from parent (ObjectMirror). |
- RegExpMirror.super_.fillJSON_.call(this, content, details); |
- // Add regexp specific properties. |
- content.push(MakeJSONPair_('source', StringToJSON_(this.source()))); |
- content.push(MakeJSONPair_('global', BooleanToJSON_(this.global()))); |
- content.push(MakeJSONPair_('ignoreCase', BooleanToJSON_(this.ignoreCase()))); |
- content.push(MakeJSONPair_('multiline', BooleanToJSON_(this.multiline()))); |
-} |
- |
- |
RegExpMirror.prototype.toText = function() { |
// Simpel to text which is used when on specialization in subclass. |
return "/" + this.source() + "/"; |
@@ -1111,14 +995,6 @@ |
}; |
-ErrorMirror.prototype.fillJSON_ = function(content, details) { |
- // Fill JSON properties from parent (ObjectMirror). |
- ErrorMirror.super_.fillJSON_.call(this, content, details); |
- // Add error specific properties. |
- content.push(MakeJSONPair_('message', StringToJSON_(this.message()))); |
-} |
- |
- |
ErrorMirror.prototype.toText = function() { |
// Use the same text representation as in messages.js. |
var text; |
@@ -1206,18 +1082,6 @@ |
} |
-PropertyMirror.prototype.fillJSON_ = function(content, details) { |
- content.push(MakeJSONPair_('name', StringToJSON_(this.name()))); |
- content.push(MakeJSONPair_('value', this.value().toJSONProtocol(details))); |
- if (this.attributes() != PropertyAttribute.None) { |
- content.push(MakeJSONPair_('attributes', NumberToJSON_(this.attributes()))); |
- } |
- if (this.propertyType() != PropertyType.Normal) { |
- content.push(MakeJSONPair_('propertyType', NumberToJSON_(this.propertyType()))); |
- } |
-} |
- |
- |
/** |
* Mirror object for interceptor named properties. |
* @param {ObjectMirror} mirror The mirror object having this property |
@@ -1278,28 +1142,6 @@ |
} |
-/** |
- * Serialize the accessor mirror into JSON format. For accessor it has the |
- * following format. |
- * {"type":"accessor", |
- "native:"<boolean>, |
- "getter":<function mirror JSON serialization>, |
- "setter":<function mirror JSON serialization>} |
- * For specialized mirrors inheriting from the base Mirror |
- * @param {boolean} details Indicate level of details to include |
- * @return {string} JSON serialization |
- */ |
-AccessorMirror.prototype.fillJSON_ = function(content, details) { |
- AccessorMirror.super_.fillJSONType_.call(this, content); |
- if (this.isNative()) { |
- content.push(MakeJSONPair_('native', BooleanToJSON_(true))); |
- } else { |
- content.push(MakeJSONPair_('getter', this.getter().toJSONProtocol(false))); |
- content.push(MakeJSONPair_('setter', this.setter().toJSONProtocol(false))); |
- } |
-} |
- |
- |
const kFrameDetailsFrameIdIndex = 0; |
const kFrameDetailsReceiverIndex = 1; |
const kFrameDetailsFunctionIndex = 2; |
@@ -1558,47 +1400,6 @@ |
}; |
-FrameMirror.prototype.fillJSON_ = function(content, details) { |
- FrameMirror.super_.fillJSONType_.call(this, content); |
- content.push(MakeJSONPair_('index', NumberToJSON_(this.index()))); |
- content.push(MakeJSONPair_('receiver', this.receiver().toJSONProtocol(false))); |
- content.push(MakeJSONPair_('func', this.func().toJSONProtocol(false))); |
- content.push(MakeJSONPair_('constructCall', BooleanToJSON_(this.isConstructCall()))); |
- content.push(MakeJSONPair_('debuggerFrame', BooleanToJSON_(this.isDebuggerFrame()))); |
- var x = new Array(this.argumentCount()); |
- for (var i = 0; i < this.argumentCount(); i++) { |
- arg = new Array(); |
- var argument_name = this.argumentName(i) |
- if (argument_name) { |
- arg.push(MakeJSONPair_('name', StringToJSON_(argument_name))); |
- } |
- arg.push(MakeJSONPair_('value', this.argumentValue(i).toJSONProtocol(false))); |
- x[i] = ArrayToJSONObject_(arg); |
- } |
- content.push(MakeJSONPair_('arguments', ArrayToJSONArray_(x))); |
- var x = new Array(this.localCount()); |
- for (var i = 0; i < this.localCount(); i++) { |
- var name = MakeJSONPair_('name', StringToJSON_(this.localName(i))); |
- var value = MakeJSONPair_('value', this.localValue(i).toJSONProtocol(false)); |
- x[i] = '{' + name + ',' + value + '}'; |
- } |
- content.push(MakeJSONPair_('locals', ArrayToJSONArray_(x))); |
- content.push(MakeJSONPair_('position', NumberToJSON_(this.sourcePosition()))); |
- var line = this.sourceLine(); |
- if (!IS_UNDEFINED(line)) { |
- content.push(MakeJSONPair_('line', NumberToJSON_(line))); |
- } |
- var column = this.sourceColumn(); |
- if (!IS_UNDEFINED(column)) { |
- content.push(MakeJSONPair_('column', NumberToJSON_(column))); |
- } |
- var source_line_text = this.sourceLineText(); |
- if (!IS_UNDEFINED(source_line_text)) { |
- content.push(MakeJSONPair_('sourceLineText', StringToJSON_(source_line_text))); |
- } |
-} |
- |
- |
FrameMirror.prototype.invocationText = function() { |
// Format frame invoaction (receiver, function and arguments). |
var result = ''; |
@@ -1783,18 +1584,6 @@ |
} |
-ScriptMirror.prototype.fillJSON_ = function(content, details) { |
- ScriptMirror.super_.fillJSONType_.call(this, content); |
- if (this.name()) { |
- content.push(MakeJSONPair_('name', StringToJSON_(this.name()))); |
- } |
- content.push(MakeJSONPair_('lineOffset', NumberToJSON_(this.lineOffset()))); |
- content.push(MakeJSONPair_('columnOffset', NumberToJSON_(this.columnOffset()))); |
- content.push(MakeJSONPair_('lineCount', NumberToJSON_(this.lineCount()))); |
- content.push(MakeJSONPair_('scriptType', NumberToJSON_(this.scriptType()))); |
-} |
- |
- |
ScriptMirror.prototype.toText = function() { |
var result = ''; |
result += this.name(); |
@@ -1811,6 +1600,244 @@ |
} |
+function JSONProtocolSerializer(details) { |
+ this.details_ = details; |
+} |
+ |
+ |
+JSONProtocolSerializer.prototype.serialize = function(mirror) { |
+ // Collect the JSON property/value pairs in a array. |
+ var content = new Array(); |
+ |
+ // Always add the type |
+ content.push(MakeJSONPair_('type', StringToJSON_(mirror.type()))); |
+ |
+ switch (mirror.type()) { |
+ case UNDEFINED_TYPE: |
+ case NULL_TYPE: |
+ // Undefined and null are represented just by their type. |
+ break; |
+ |
+ case BOOLEAN_TYPE: |
+ // Boolean values are simply represented by their value. |
+ content.push(MakeJSONPair_('value', BooleanToJSON_(mirror.value()))); |
+ break; |
+ |
+ case NUMBER_TYPE: |
+ // Number values are simply represented by their value. |
+ content.push(MakeJSONPair_('value', NumberToJSON_(mirror.value()))); |
+ break; |
+ |
+ case STRING_TYPE: |
+ // String values might have their value cropped to keep down size. |
+ if (mirror.length() > kMaxProtocolStringLength) { |
+ var str = mirror.value().substring(0, kMaxProtocolStringLength); |
+ content.push(MakeJSONPair_('value', StringToJSON_(str))); |
+ content.push(MakeJSONPair_('fromIndex', NumberToJSON_(0))); |
+ content.push(MakeJSONPair_('toIndex', |
+ NumberToJSON_(kMaxProtocolStringLength))); |
+ } else { |
+ content.push(MakeJSONPair_('value', StringToJSON_(mirror.value()))); |
+ } |
+ content.push(MakeJSONPair_('length', NumberToJSON_(mirror.length()))); |
+ break; |
+ |
+ case OBJECT_TYPE: |
+ case FUNCTION_TYPE: |
+ case ERROR_TYPE: |
+ case REGEXP_TYPE: |
+ // Add object representation. |
+ this.serializeObject_(mirror, content); |
+ break; |
+ |
+ case PROPERTY_TYPE: |
+ // Properties are represented by name, value, attributes and type. |
+ content.push(MakeJSONPair_('name', |
+ StringToJSON_(mirror.name()))); |
+ content.push(MakeJSONPair_('value', |
+ mirror.value().toJSONProtocol(this.details_))); |
+ if (mirror.attributes() != PropertyAttribute.None) { |
+ content.push(MakeJSONPair_('attributes', |
+ NumberToJSON_(mirror.attributes()))); |
+ } |
+ if (mirror.propertyType() != PropertyType.Normal) { |
+ content.push(MakeJSONPair_('propertyType', |
+ NumberToJSON_(mirror.propertyType()))); |
+ } |
+ break; |
+ |
+ case ACCESSOR_TYPE: |
+ // An accessor can either be native or defined through JavaScript. |
+ if (mirror.isNative()) { |
+ content.push(MakeJSONPair_('native', BooleanToJSON_(true))); |
+ } else { |
+ content.push(MakeJSONPair_('getter', |
+ mirror.getter().toJSONProtocol(false))); |
+ content.push(MakeJSONPair_('setter', |
+ mirror.setter().toJSONProtocol(false))); |
+ } |
+ break; |
+ |
+ case FRAME_TYPE: |
+ // Add object representation. |
+ this.serializeFrame_(mirror, content); |
+ break; |
+ |
+ case SCRIPT_TYPE: |
+ // Script is represented by name and source attributes. |
+ if (mirror.name()) { |
+ content.push(MakeJSONPair_('name', StringToJSON_(mirror.name()))); |
+ } |
+ content.push(MakeJSONPair_('lineOffset', |
+ NumberToJSON_(mirror.lineOffset()))); |
+ content.push(MakeJSONPair_('columnOffset', |
+ NumberToJSON_(mirror.columnOffset()))); |
+ content.push(MakeJSONPair_('lineCount', |
+ NumberToJSON_(mirror.lineCount()))); |
+ content.push(MakeJSONPair_('scriptType', |
+ NumberToJSON_(mirror.scriptType()))); |
+ break; |
+ |
+ } |
+ |
+ // Always add the text representation. |
+ content.push(MakeJSONPair_('text', StringToJSON_(mirror.toText()))); |
+ |
+ // Create and return the JSON string. |
+ return ArrayToJSONObject_(content); |
+} |
+ |
+ |
+JSONProtocolSerializer.prototype.serializeObject_ = function(mirror, content) { |
+ content.push(MakeJSONPair_('className', |
+ StringToJSON_(mirror.className()))); |
+ |
+ if (this.details_) { |
+ content.push(MakeJSONPair_('constructorFunction', |
+ mirror.constructorFunction().toJSONProtocol(false))); |
+ content.push(MakeJSONPair_('protoObject', |
+ mirror.protoObject().toJSONProtocol(false))); |
+ content.push(MakeJSONPair_('prototypeObject', |
+ mirror.prototypeObject().toJSONProtocol(false))); |
+ |
+ // Add properties. For arrays don't include indexed proeprties. |
+ var kind = PropertyKind.Named; |
+ if (!mirror.isArray()) { |
+ kind |= PropertyKind.Indexed |
+ } |
+ var propertyNames = mirror.propertyNames(kind); |
+ var x = new Array(propertyNames.length); |
+ for (var i = 0; i < propertyNames.length; i++) { |
+ x[i] = mirror.property(propertyNames[i]).toJSONProtocol(false); |
+ } |
+ content.push(MakeJSONPair_('properties', ArrayToJSONArray_(x))); |
+ |
+ // Add interceptor properties. |
+ propertyNames = mirror.interceptorPropertyNames(); |
+ var x = new Array(propertyNames.length); |
+ for (var i = 0; i < propertyNames.length; i++) { |
+ x[i] = properties[i].toJSONProtocol(details); |
+ } |
+ content.push(MakeJSONPair_('interceptorProperties', ArrayToJSONArray_(x))); |
+ |
+ // For arrays the indexed properties are added separately and the length is |
+ // added as well. |
+ if (mirror.isArray()) { |
+ var propertyNames = mirror.propertyNames(PropertyKind.Indexed); |
+ var x = new Array(propertyNames.length); |
+ for (var i = 0; i < propertyNames.length; i++) { |
+ x[i] = mirror.property(propertyNames[i]).toJSONProtocol(false); |
+ } |
+ content.push(MakeJSONPair_('indexedProperties', ArrayToJSONArray_(x))); |
+ |
+ // Add the array length. |
+ content.push(MakeJSONPair_('length', NumberToJSON_(mirror.length()))); |
+ } |
+ } |
+ |
+ if (mirror.hasNamedInterceptor()) { |
+ content.push(MakeJSONPair_('namedInterceptor', BooleanToJSON_(true))); |
+ } |
+ |
+ if (mirror.hasIndexedInterceptor()) { |
+ content.push(MakeJSONPair_('indexedInterceptor', BooleanToJSON_(true))); |
+ } |
+ |
+ if (mirror.isFunction()) { |
+ // Add function specific properties. |
+ content.push(MakeJSONPair_('name', StringToJSON_(mirror.name()))); |
+ content.push(MakeJSONPair_('resolved', BooleanToJSON_(mirror.resolved()))); |
+ if (this.details_ && mirror.resolved()) { |
+ content.push(MakeJSONPair_('source', StringToJSON_(mirror.source()))); |
+ } |
+ if (mirror.script()) { |
+ content.push(MakeJSONPair_('script', mirror.script().toJSONProtocol())); |
+ } |
+ } else if (mirror.isDate()) { |
+ // Add date specific properties. |
+ content.push(MakeJSONPair_('value', DateToJSON_(mirror.value()))); |
+ } else if (mirror.isRegExp()) { |
+ // Add regexp specific properties. |
+ content.push(MakeJSONPair_('source', StringToJSON_(mirror.source()))); |
+ content.push(MakeJSONPair_('global', BooleanToJSON_(mirror.global()))); |
+ content.push(MakeJSONPair_('ignoreCase', |
+ BooleanToJSON_(mirror.ignoreCase()))); |
+ content.push(MakeJSONPair_('multiline', |
+ BooleanToJSON_(mirror.multiline()))); |
+ } else if (mirror.isError()) { |
+ // Add error specific properties. |
+ content.push(MakeJSONPair_('message', StringToJSON_(mirror.message()))); |
+ } |
+} |
+ |
+ |
+JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { |
+ content.push(MakeJSONPair_('index', NumberToJSON_(mirror.index()))); |
+ content.push(MakeJSONPair_('receiver', |
+ mirror.receiver().toJSONProtocol(false))); |
+ content.push(MakeJSONPair_('func', mirror.func().toJSONProtocol(false))); |
+ content.push(MakeJSONPair_('constructCall', |
+ BooleanToJSON_(mirror.isConstructCall()))); |
+ content.push(MakeJSONPair_('debuggerFrame', |
+ BooleanToJSON_(mirror.isDebuggerFrame()))); |
+ var x = new Array(mirror.argumentCount()); |
+ for (var i = 0; i < mirror.argumentCount(); i++) { |
+ arg = new Array(); |
+ var argument_name = mirror.argumentName(i) |
+ if (argument_name) { |
+ arg.push(MakeJSONPair_('name', StringToJSON_(argument_name))); |
+ } |
+ arg.push(MakeJSONPair_('value', |
+ mirror.argumentValue(i).toJSONProtocol(false))); |
+ x[i] = ArrayToJSONObject_(arg); |
+ } |
+ content.push(MakeJSONPair_('arguments', ArrayToJSONArray_(x))); |
+ var x = new Array(mirror.localCount()); |
+ for (var i = 0; i < mirror.localCount(); i++) { |
+ var name = MakeJSONPair_('name', StringToJSON_(mirror.localName(i))); |
+ var value = MakeJSONPair_('value', |
+ mirror.localValue(i).toJSONProtocol(false)); |
+ x[i] = '{' + name + ',' + value + '}'; |
+ } |
+ content.push(MakeJSONPair_('locals', ArrayToJSONArray_(x))); |
+ content.push(MakeJSONPair_('position', |
+ NumberToJSON_(mirror.sourcePosition()))); |
+ var line = mirror.sourceLine(); |
+ if (!IS_UNDEFINED(line)) { |
+ content.push(MakeJSONPair_('line', NumberToJSON_(line))); |
+ } |
+ var column = mirror.sourceColumn(); |
+ if (!IS_UNDEFINED(column)) { |
+ content.push(MakeJSONPair_('column', NumberToJSON_(column))); |
+ } |
+ var source_line_text = mirror.sourceLineText(); |
+ if (!IS_UNDEFINED(source_line_text)) { |
+ content.push(MakeJSONPair_('sourceLineText', |
+ StringToJSON_(source_line_text))); |
+ } |
+} |
+ |
+ |
function MakeJSONPair_(name, value) { |
return '"' + name + '":' + value; |
} |