OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of service; | 5 part of service; |
6 | 6 |
7 /// An RpcException represents an exceptional event that happened | 7 /// An RpcException represents an exceptional event that happened |
8 /// while invoking an rpc. | 8 /// while invoking an rpc. |
9 abstract class RpcException implements Exception { | 9 abstract class RpcException implements Exception { |
10 RpcException(this.message); | 10 RpcException(this.message); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 String _id; | 94 String _id; |
95 | 95 |
96 /// The user-level type of this object. | 96 /// The user-level type of this object. |
97 @reflectable String get type => _type; | 97 @reflectable String get type => _type; |
98 String _type; | 98 String _type; |
99 | 99 |
100 /// The vm type of this object. | 100 /// The vm type of this object. |
101 @reflectable String get vmType => _vmType; | 101 @reflectable String get vmType => _vmType; |
102 String _vmType; | 102 String _vmType; |
103 | 103 |
104 static bool _isInstanceType(String type) { | |
105 switch (type) { | |
106 case 'BoundedType': | |
107 case 'Instance': | |
108 case 'List': | |
109 case 'String': | |
110 case 'Type': | |
111 case 'TypeParameter': | |
112 case 'TypeRef': | |
113 case 'bool': | |
114 case 'double': | |
115 case 'int': | |
116 case 'null': | |
117 return true; | |
118 default: | |
119 return false; | |
120 } | |
121 } | |
122 | |
123 static bool _isTypeType(String type) { | |
124 switch (type) { | |
125 case 'BoundedType': | |
126 case 'Type': | |
127 case 'TypeParameter': | |
128 case 'TypeRef': | |
129 return true; | |
130 default: | |
131 return false; | |
132 } | |
133 } | |
134 | |
135 bool get isAbstractType => _isTypeType(type); | |
136 bool get isBool => type == 'bool'; | |
137 bool get isContext => type == 'Context'; | 104 bool get isContext => type == 'Context'; |
138 bool get isDouble => type == 'double'; | |
139 bool get isError => type == 'Error'; | 105 bool get isError => type == 'Error'; |
140 bool get isInstance => _isInstanceType(type); | 106 bool get isInstance => type == 'Instance'; |
141 bool get isInt => type == 'int'; | |
142 bool get isList => type == 'List'; | |
143 bool get isNull => type == 'null'; | |
144 bool get isSentinel => type == 'Sentinel'; | 107 bool get isSentinel => type == 'Sentinel'; |
145 bool get isString => type == 'String'; | |
146 bool get isMessage => type == 'Message'; | 108 bool get isMessage => type == 'Message'; |
147 | 109 |
148 // Kinds of Instance. | 110 // Kinds of Instance. |
149 bool get isMirrorReference => vmType == 'MirrorReference'; | 111 bool get isAbstractType => false; |
150 bool get isWeakProperty => vmType == 'WeakProperty'; | 112 bool get isNull => false; |
| 113 bool get isBool => false; |
| 114 bool get isDouble => false; |
| 115 bool get isString => false; |
| 116 bool get isInt => false; |
| 117 bool get isList => false; |
| 118 bool get isMirrorReference => false; |
| 119 bool get isWeakProperty => false; |
151 bool get isClosure => false; | 120 bool get isClosure => false; |
152 bool get isPlainInstance { | 121 bool get isPlainInstance => false; |
153 return (type == 'Instance' && | |
154 !isMirrorReference && !isWeakProperty && !isClosure); | |
155 } | |
156 | 122 |
157 /// Has this object been fully loaded? | 123 /// Has this object been fully loaded? |
158 bool get loaded => _loaded; | 124 bool get loaded => _loaded; |
159 bool _loaded = false; | 125 bool _loaded = false; |
160 // TODO(turnidge): Make loaded observable and get rid of loading | 126 // TODO(turnidge): Make loaded observable and get rid of loading |
161 // from Isolate. | 127 // from Isolate. |
162 | 128 |
163 /// Is this object cacheable? That is, is it impossible for the [id] | 129 /// Is this object cacheable? That is, is it impossible for the [id] |
164 /// of this object to change? | 130 /// of this object to change? |
165 bool get canCache => false; | 131 bool get canCache => false; |
(...skipping 11 matching lines...) Expand all Loading... |
177 factory ServiceObject._fromMap(ServiceObjectOwner owner, | 143 factory ServiceObject._fromMap(ServiceObjectOwner owner, |
178 ObservableMap map) { | 144 ObservableMap map) { |
179 if (map == null) { | 145 if (map == null) { |
180 return null; | 146 return null; |
181 } | 147 } |
182 if (!_isServiceMap(map)) { | 148 if (!_isServiceMap(map)) { |
183 Logger.root.severe('Malformed service object: $map'); | 149 Logger.root.severe('Malformed service object: $map'); |
184 } | 150 } |
185 assert(_isServiceMap(map)); | 151 assert(_isServiceMap(map)); |
186 var type = _stripRef(map['type']); | 152 var type = _stripRef(map['type']); |
187 var vmType = map['_vmType'] != null ? _stripRef(map['_vmType']) : type; | 153 var vmType = map['_vmType'] != null ? map['_vmType'] : type; |
188 var obj = null; | 154 var obj = null; |
189 assert(type != 'VM'); | 155 assert(type != 'VM'); |
190 switch (type) { | 156 switch (type) { |
191 case 'Breakpoint': | 157 case 'Breakpoint': |
192 obj = new Breakpoint._empty(owner); | 158 obj = new Breakpoint._empty(owner); |
193 break; | 159 break; |
194 case 'Class': | 160 case 'Class': |
195 obj = new Class._empty(owner); | 161 obj = new Class._empty(owner); |
196 break; | 162 break; |
197 case 'Code': | 163 case 'Code': |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 break; | 202 break; |
237 case 'Event': | 203 case 'Event': |
238 obj = new ServiceEvent._empty(owner); | 204 obj = new ServiceEvent._empty(owner); |
239 break; | 205 break; |
240 case 'Script': | 206 case 'Script': |
241 obj = new Script._empty(owner); | 207 obj = new Script._empty(owner); |
242 break; | 208 break; |
243 case 'Socket': | 209 case 'Socket': |
244 obj = new Socket._empty(owner); | 210 obj = new Socket._empty(owner); |
245 break; | 211 break; |
| 212 case 'Instance': |
| 213 case 'Sentinel': // TODO(rmacnak): Separate this out. |
| 214 obj = new Instance._empty(owner); |
| 215 break; |
246 default: | 216 default: |
247 if (_isInstanceType(type) || | |
248 type == 'Sentinel') { // TODO(rmacnak): Separate this out. | |
249 obj = new Instance._empty(owner); | |
250 } | |
251 break; | 217 break; |
252 } | 218 } |
253 if (obj == null) { | 219 if (obj == null) { |
254 obj = new ServiceMap._empty(owner); | 220 obj = new ServiceMap._empty(owner); |
255 } | 221 } |
256 obj.update(map); | 222 obj.update(map); |
257 return obj; | 223 return obj; |
258 } | 224 } |
259 | 225 |
260 /// If [this] was created from a reference, load the full object | 226 /// If [this] was created from a reference, load the full object |
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 } | 1768 } |
1803 | 1769 |
1804 Future<ServiceObject> evaluate(String expression) { | 1770 Future<ServiceObject> evaluate(String expression) { |
1805 return isolate._eval(this, expression); | 1771 return isolate._eval(this, expression); |
1806 } | 1772 } |
1807 | 1773 |
1808 String toString() => 'Class($vmName)'; | 1774 String toString() => 'Class($vmName)'; |
1809 } | 1775 } |
1810 | 1776 |
1811 class Instance extends ServiceObject { | 1777 class Instance extends ServiceObject { |
| 1778 @observable String kind; |
1812 @observable Class clazz; | 1779 @observable Class clazz; |
1813 @observable int size; | 1780 @observable int size; |
1814 @observable int retainedSize; | 1781 @observable int retainedSize; |
1815 @observable String valueAsString; // If primitive. | 1782 @observable String valueAsString; // If primitive. |
1816 @observable bool valueAsStringIsTruncated; | 1783 @observable bool valueAsStringIsTruncated; |
1817 @observable ServiceFunction function; // If a closure. | 1784 @observable ServiceFunction function; // If a closure. |
1818 @observable Context context; // If a closure. | 1785 @observable Context context; // If a closure. |
1819 @observable String name; // If a Type. | 1786 @observable String name; // If a Type. |
1820 @observable int length; // If a List. | 1787 @observable int length; // If a List. |
1821 | 1788 |
1822 @observable var typeClass; | 1789 @observable var typeClass; |
1823 @observable var fields; | 1790 @observable var fields; |
1824 @observable var nativeFields; | 1791 @observable var nativeFields; |
1825 @observable var elements; | 1792 @observable var elements; |
1826 @observable var userName; | |
1827 @observable var referent; // If a MirrorReference. | 1793 @observable var referent; // If a MirrorReference. |
1828 @observable Instance key; // If a WeakProperty. | 1794 @observable Instance key; // If a WeakProperty. |
1829 @observable Instance value; // If a WeakProperty. | 1795 @observable Instance value; // If a WeakProperty. |
1830 | 1796 |
1831 bool get isClosure => function != null; | 1797 bool get isAbstractType { |
| 1798 return (kind == 'Type' || kind == 'TypeRef' || |
| 1799 kind == 'TypeParameter' || kind == 'BoundedType'); |
| 1800 } |
| 1801 bool get isNull => kind == 'Null'; |
| 1802 bool get isBool => kind == 'Bool'; |
| 1803 bool get isDouble => kind == 'Double'; |
| 1804 bool get isString => kind == 'String'; |
| 1805 bool get isInt => kind == 'Int'; |
| 1806 bool get isList => kind == 'List'; |
| 1807 bool get isMirrorReference => kind == 'MirrorReference'; |
| 1808 bool get isWeakProperty => kind == 'WeakProperty'; |
| 1809 bool get isClosure => kind == 'Closure'; |
| 1810 |
| 1811 // TODO(turnidge): Is this properly backwards compatible when new |
| 1812 // instance kinds are added? |
| 1813 bool get isPlainInstance => kind == 'PlainInstance'; |
1832 | 1814 |
1833 Instance._empty(ServiceObjectOwner owner) : super._empty(owner); | 1815 Instance._empty(ServiceObjectOwner owner) : super._empty(owner); |
1834 | 1816 |
1835 void _update(ObservableMap map, bool mapIsRef) { | 1817 void _update(ObservableMap map, bool mapIsRef) { |
1836 // Extract full properties. | 1818 // Extract full properties. |
1837 _upgradeCollection(map, isolate); | 1819 _upgradeCollection(map, isolate); |
1838 | 1820 |
| 1821 kind = map['kind']; |
1839 clazz = map['class']; | 1822 clazz = map['class']; |
1840 size = map['size']; | 1823 size = map['size']; |
1841 valueAsString = map['valueAsString']; | 1824 valueAsString = map['valueAsString']; |
1842 // Coerce absence to false. | 1825 // Coerce absence to false. |
1843 valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true; | 1826 valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true; |
1844 function = map['function']; | 1827 function = map['closureFunction']; |
1845 context = map['context']; | 1828 context = map['closureContext']; |
1846 name = map['name']; | 1829 name = map['name']; |
1847 length = map['length']; | 1830 length = map['length']; |
1848 | 1831 |
1849 if (mapIsRef) { | 1832 if (mapIsRef) { |
1850 return; | 1833 return; |
1851 } | 1834 } |
1852 | 1835 |
1853 nativeFields = map['_nativeFields']; | 1836 nativeFields = map['_nativeFields']; |
1854 fields = map['fields']; | 1837 fields = map['fields']; |
1855 elements = map['elements']; | 1838 elements = map['elements']; |
1856 typeClass = map['type_class']; | 1839 typeClass = map['typeClass']; |
1857 userName = map['user_name']; | 1840 referent = map['mirrorReferent']; |
1858 referent = map['referent']; | 1841 key = map['propertyKey']; |
1859 key = map['key']; | 1842 value = map['propertyValue']; |
1860 value = map['value']; | |
1861 | 1843 |
1862 // We are fully loaded. | 1844 // We are fully loaded. |
1863 _loaded = true; | 1845 _loaded = true; |
1864 } | 1846 } |
1865 | 1847 |
1866 String get shortName { | 1848 String get shortName { |
1867 if (isClosure) { | 1849 if (isClosure) { |
1868 return function.qualifiedName; | 1850 return function.qualifiedName; |
1869 } | 1851 } |
1870 if (valueAsString != null) { | 1852 if (valueAsString != null) { |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3174 var v = list[i]; | 3156 var v = list[i]; |
3175 if ((v is ObservableMap) && _isServiceMap(v)) { | 3157 if ((v is ObservableMap) && _isServiceMap(v)) { |
3176 list[i] = owner.getFromMap(v); | 3158 list[i] = owner.getFromMap(v); |
3177 } else if (v is ObservableList) { | 3159 } else if (v is ObservableList) { |
3178 _upgradeObservableList(v, owner); | 3160 _upgradeObservableList(v, owner); |
3179 } else if (v is ObservableMap) { | 3161 } else if (v is ObservableMap) { |
3180 _upgradeObservableMap(v, owner); | 3162 _upgradeObservableMap(v, owner); |
3181 } | 3163 } |
3182 } | 3164 } |
3183 } | 3165 } |
OLD | NEW |