OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1708 // the mirror to the referenced mirrors. | 1708 // the mirror to the referenced mirrors. |
1709 if (reference && | 1709 if (reference && |
1710 (mirror.isValue() || mirror.isScript())) { | 1710 (mirror.isValue() || mirror.isScript())) { |
1711 this.add_(mirror); | 1711 this.add_(mirror); |
1712 return '{"ref":' + mirror.handle() + '}'; | 1712 return '{"ref":' + mirror.handle() + '}'; |
1713 } | 1713 } |
1714 | 1714 |
1715 // Collect the JSON property/value pairs in an array. | 1715 // Collect the JSON property/value pairs in an array. |
1716 var content = new Array(); | 1716 var content = new Array(); |
1717 | 1717 |
1718 // Add the handle for value mirrors. | 1718 // Add the mirror handle. |
1719 if (mirror.isValue()) { | 1719 if (mirror.isValue() || mirror.isScript()) { |
1720 content.push(MakeJSONPair_('handle', NumberToJSON_(mirror.handle()))); | 1720 content.push(MakeJSONPair_('handle', NumberToJSON_(mirror.handle()))); |
1721 } | 1721 } |
1722 | 1722 |
1723 // Always add the type. | 1723 // Always add the type. |
1724 content.push(MakeJSONPair_('type', StringToJSON_(mirror.type()))); | 1724 content.push(MakeJSONPair_('type', StringToJSON_(mirror.type()))); |
1725 | 1725 |
1726 switch (mirror.type()) { | 1726 switch (mirror.type()) { |
1727 case UNDEFINED_TYPE: | 1727 case UNDEFINED_TYPE: |
1728 case NULL_TYPE: | 1728 case NULL_TYPE: |
1729 // Undefined and null are represented just by their type. | 1729 // Undefined and null are represented just by their type. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 case PROPERTY_TYPE: | 1764 case PROPERTY_TYPE: |
1765 throw new Error('PropertyMirror cannot be serialized independeltly') | 1765 throw new Error('PropertyMirror cannot be serialized independeltly') |
1766 break; | 1766 break; |
1767 | 1767 |
1768 case FRAME_TYPE: | 1768 case FRAME_TYPE: |
1769 // Add object representation. | 1769 // Add object representation. |
1770 this.serializeFrame_(mirror, content); | 1770 this.serializeFrame_(mirror, content); |
1771 break; | 1771 break; |
1772 | 1772 |
1773 case SCRIPT_TYPE: | 1773 case SCRIPT_TYPE: |
1774 // Script is represented by name and source attributes. | 1774 // Script is represented by id, name and source attributes. |
1775 if (mirror.name()) { | 1775 if (mirror.name()) { |
1776 content.push(MakeJSONPair_('name', StringToJSON_(mirror.name()))); | 1776 content.push(MakeJSONPair_('name', StringToJSON_(mirror.name()))); |
1777 } | 1777 } |
| 1778 content.push(MakeJSONPair_('id', NumberToJSON_(mirror.id()))); |
1778 content.push(MakeJSONPair_('lineOffset', | 1779 content.push(MakeJSONPair_('lineOffset', |
1779 NumberToJSON_(mirror.lineOffset()))); | 1780 NumberToJSON_(mirror.lineOffset()))); |
1780 content.push(MakeJSONPair_('columnOffset', | 1781 content.push(MakeJSONPair_('columnOffset', |
1781 NumberToJSON_(mirror.columnOffset()))); | 1782 NumberToJSON_(mirror.columnOffset()))); |
1782 content.push(MakeJSONPair_('lineCount', | 1783 content.push(MakeJSONPair_('lineCount', |
1783 NumberToJSON_(mirror.lineCount()))); | 1784 NumberToJSON_(mirror.lineCount()))); |
1784 content.push(MakeJSONPair_('scriptType', | 1785 content.push(MakeJSONPair_('scriptType', |
1785 NumberToJSON_(mirror.scriptType()))); | 1786 NumberToJSON_(mirror.scriptType()))); |
1786 break; | 1787 break; |
1787 } | 1788 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1901 builder.add(NumberToJSON_(property_mirror.value().handle())); | 1902 builder.add(NumberToJSON_(property_mirror.value().handle())); |
1902 builder.add('}'); | 1903 builder.add('}'); |
1903 return builder.generate(); | 1904 return builder.generate(); |
1904 } | 1905 } |
1905 | 1906 |
1906 | 1907 |
1907 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { | 1908 JSONProtocolSerializer.prototype.serializeFrame_ = function(mirror, content) { |
1908 content.push(MakeJSONPair_('index', NumberToJSON_(mirror.index()))); | 1909 content.push(MakeJSONPair_('index', NumberToJSON_(mirror.index()))); |
1909 content.push(MakeJSONPair_('receiver', | 1910 content.push(MakeJSONPair_('receiver', |
1910 this.serializeReference(mirror.receiver()))); | 1911 this.serializeReference(mirror.receiver()))); |
1911 content.push(MakeJSONPair_('func', this.serializeReference(mirror.func()))); | 1912 var func = mirror.func(); |
| 1913 content.push(MakeJSONPair_('func', this.serializeReference(func))); |
| 1914 if (func.script()) { |
| 1915 content.push(MakeJSONPair_('script', |
| 1916 this.serializeReference(func.script()))); |
| 1917 } |
1912 content.push(MakeJSONPair_('constructCall', | 1918 content.push(MakeJSONPair_('constructCall', |
1913 BooleanToJSON_(mirror.isConstructCall()))); | 1919 BooleanToJSON_(mirror.isConstructCall()))); |
1914 content.push(MakeJSONPair_('debuggerFrame', | 1920 content.push(MakeJSONPair_('debuggerFrame', |
1915 BooleanToJSON_(mirror.isDebuggerFrame()))); | 1921 BooleanToJSON_(mirror.isDebuggerFrame()))); |
1916 var x = new Array(mirror.argumentCount()); | 1922 var x = new Array(mirror.argumentCount()); |
1917 for (var i = 0; i < mirror.argumentCount(); i++) { | 1923 for (var i = 0; i < mirror.argumentCount(); i++) { |
1918 arg = new Array(); | 1924 arg = new Array(); |
1919 var argument_name = mirror.argumentName(i) | 1925 var argument_name = mirror.argumentName(i) |
1920 if (argument_name) { | 1926 if (argument_name) { |
1921 arg.push(MakeJSONPair_('name', StringToJSON_(argument_name))); | 1927 arg.push(MakeJSONPair_('name', StringToJSON_(argument_name))); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2074 /** | 2080 /** |
2075 * Convert a Date to ISO 8601 format. To avoid depending on the Date object | 2081 * Convert a Date to ISO 8601 format. To avoid depending on the Date object |
2076 * this method calls the functions in date.js directly and not through the | 2082 * this method calls the functions in date.js directly and not through the |
2077 * value. | 2083 * value. |
2078 * @param {Date} value The Date value to format as JSON | 2084 * @param {Date} value The Date value to format as JSON |
2079 * @return {string} JSON formatted Date value | 2085 * @return {string} JSON formatted Date value |
2080 */ | 2086 */ |
2081 function DateToJSON_(value) { | 2087 function DateToJSON_(value) { |
2082 return '"' + DateToISO8601_(value) + '"'; | 2088 return '"' + DateToISO8601_(value) + '"'; |
2083 } | 2089 } |
OLD | NEW |