Index: runtime/bin/vmservice/observatory/lib/src/service/object.dart |
diff --git a/runtime/bin/vmservice/observatory/lib/src/service/object.dart b/runtime/bin/vmservice/observatory/lib/src/service/object.dart |
index bc57bb6647b0587397739c14a0ecced4c2a44ed5..78d29702c4e608a24253bff04931e67260858a78 100644 |
--- a/runtime/bin/vmservice/observatory/lib/src/service/object.dart |
+++ b/runtime/bin/vmservice/observatory/lib/src/service/object.dart |
@@ -34,6 +34,17 @@ abstract class ServiceObject extends Observable { |
@reflectable String get serviceType => _serviceType; |
String _serviceType; |
+ bool get isBool => serviceType == 'Bool'; |
+ bool get isDouble => serviceType == 'Double'; |
+ bool get isError => serviceType == 'Error'; |
+ bool get isInstance => serviceType == 'Instance'; |
+ bool get isInt => serviceType == 'Smi' || serviceType == 'Mint' || serviceType == 'Bigint'; |
+ bool get isList => serviceType == 'GrowableObjectArray' || serviceType == 'Array'; |
+ bool get isNull => serviceType == 'Null'; |
+ bool get isSentinel => serviceType == 'Sentinel'; |
+ bool get isString => serviceType == 'String'; |
+ bool get isType => serviceType == 'Type'; |
+ |
/// The complete service url of this object. |
@reflectable String get link => _owner.relativeLink(_id); |
@@ -88,6 +99,20 @@ abstract class ServiceObject extends Observable { |
case 'Gauge': |
obj = new ServiceMetric._empty(owner); |
break; |
+ case 'Array': |
+ case 'Bigint': |
+ case 'Bool': |
+ case 'Double': |
+ case 'GrowableObjectArray': |
+ case 'Instance': |
+ case 'Mint': |
+ case 'Null': |
+ case 'Sentinel': // TODO(rmacnak): Separate this out. |
+ case 'Smi': |
+ case 'String': |
+ case 'Type': |
+ obj = new Instance._empty(owner); |
+ break; |
case 'Isolate': |
obj = new Isolate._empty(owner.vm); |
break; |
@@ -1159,7 +1184,7 @@ class DartError extends ServiceObject { |
@observable String kind; |
@observable String message; |
- @observable ServiceMap exception; |
+ @observable Instance exception; |
@observable ServiceMap stacktrace; |
void _update(ObservableMap map, bool mapIsRef) { |
@@ -1439,6 +1464,54 @@ class Class extends ServiceObject with Coverage { |
String toString() => 'Class($vmName)'; |
} |
+class Instance extends ServiceObject { |
+ @observable Class clazz; |
+ @observable String valueAsString; |
+ @observable int size; |
+ @observable ServiceFunction closureFunc; // If a closure. |
+ @observable String name; // If a Type. |
+ |
+ @observable var typeClass; |
+ @observable var length; |
+ @observable var fields; |
+ @observable var nativeFields; |
+ @observable var elements; |
+ @observable var userName; |
+ |
+ bool get isClosure => closureFunc != null; |
+ |
+ Instance._empty(ServiceObjectOwner owner) : super._empty(owner); |
+ |
+ void _update(ObservableMap map, bool mapIsRef) { |
+ // Extract full properties. |
+ _upgradeCollection(map, isolate); |
+ |
+ clazz = map['class']; |
+ valueAsString = map['valueAsString']; |
+ size = map['size']; |
+ closureFunc = map['closureFunc']; |
+ name = map['name']; |
+ |
+ if (mapIsRef) { |
+ return; |
+ } |
+ |
+ nativeFields = map['nativeFields']; |
+ fields = map['fields']; |
+ length = map['length']; |
+ elements = map['elements']; |
+ typeClass = map['type_class']; |
+ userName = map['user_name']; |
+ |
+ // We are fully loaded. |
+ _loaded = true; |
+ } |
+ |
+ String get shortName => valueAsString != null ? valueAsString : 'a ${clazz.name}'; |
+ |
+ String toString() => 'Instance($shortName)'; |
+} |
+ |
// TODO(koda): Sync this with VM. |
class FunctionKind { |
final String _strValue; |
@@ -2356,8 +2429,7 @@ class MetricPoller { |
// Convert any ServiceMaps representing a null instance into an actual null. |
_convertNull(obj) { |
- if (obj is ServiceMap && |
- obj.serviceType == 'Null') { |
+ if (obj.isNull) { |
return null; |
} |
return obj; |