Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1526)

Unified Diff: runtime/observatory/lib/src/service/object.dart

Issue 1157003003: Add TypedData instance kinds. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/service/object.dart
diff --git a/runtime/observatory/lib/src/service/object.dart b/runtime/observatory/lib/src/service/object.dart
index 75c09182de503bbd483c0b534dea51e712d0472b..6235c473a3d3fe0c8f635f9e6626cc198f0dddf4 100644
--- a/runtime/observatory/lib/src/service/object.dart
+++ b/runtime/observatory/lib/src/service/object.dart
@@ -117,6 +117,7 @@ abstract class ServiceObject extends Observable {
bool get isInt => false;
bool get isList => false;
bool get isMap => false;
+ bool get isTypedData => false;
bool get isMirrorReference => false;
bool get isWeakProperty => false;
bool get isClosure => false;
@@ -1844,6 +1845,67 @@ class Class extends ServiceObject with Coverage {
String toString() => 'Class($vmName)';
}
+const _decodeTable =
Cutch 2015/06/08 23:10:19 Move this to lib/base64.dart
rmacnak 2015/06/09 00:29:47 Done.
+ const [null, null, null, null, null, null, null, null,
+ null, null, null, null, null, null, null, null,
+ null, null, null, null, null, null, null, null,
+ null, null, null, null, null, null, null, null,
+ null, null, null, null, null, null, null, null,
+ null, null, null, 62, null, null, null, 63,
+ 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, null, null, null, 0, null, null,
+ null, 0, 1, 2, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22,
+ 23, 24, 25, null, null, null, null, null,
+ null, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51];
+
+Uint8List _decodeBase64(String s) {
+ if (s.length % 4 != 0) throw "Malformed Base64: $s";
+
+ var odd_bits = 0;
+ if (s[s.length - 1] == '=') {
+ if (s[s.length - 2] == '=') {
+ odd_bits = 2;
+ } else {
+ odd_bits = 1;
+ }
+ }
+
+ var result = new Uint8List(s.length ~/ 4 * 3 - odd_bits);
Cutch 2015/06/08 23:10:19 var decodedByteLength = ((s.length ~/ 4) * 3) - od
rmacnak 2015/06/09 00:29:47 Done.
+ var limit = s.length;
+ if (odd_bits != 0) {
+ limit = limit - 4;
+ }
+
+ var i = 0, j = 0;
+ while (i < limit) {
+ var triple = _decodeTable[s.codeUnitAt(i++)];
+ triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
+ triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
+ triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
+ result[j++] = triple >> 16;
+ result[j++] = (triple >> 8) & 255;
+ result[j++] = triple & 255;
+ }
+
+ if (odd_bits != 0) {
+ var triple = _decodeTable[s.codeUnitAt(i++)];
+ triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
+ triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
+ triple = (triple << 6) | _decodeTable[s.codeUnitAt(i++)];
+ result[j++] = triple >> 16;
+ if (odd_bits == 1) {
+ result[j++] = (triple >> 8) & 255;
+ }
+ }
+
+ return result;
Cutch 2015/06/08 23:10:19 assert(j == decodedByteLength); return result;
rmacnak 2015/06/09 00:29:47 Done.
+}
+
class Instance extends ServiceObject {
@observable String kind;
@observable Class clazz;
@@ -1854,13 +1916,14 @@ class Instance extends ServiceObject {
@observable ServiceFunction function; // If a closure.
@observable Context context; // If a closure.
@observable String name; // If a Type.
- @observable int length; // If a List or Map.
+ @observable int length; // If a List, Map or TypedData.
@observable var typeClass;
@observable var fields;
@observable var nativeFields;
@observable var elements; // If a List.
@observable var associations; // If a Map.
+ @observable var typedElements; // If a TypedData.
@observable var referent; // If a MirrorReference.
@observable Instance key; // If a WeakProperty.
@observable Instance value; // If a WeakProperty.
@@ -1876,6 +1939,22 @@ class Instance extends ServiceObject {
bool get isInt => kind == 'Int';
bool get isList => kind == 'List';
bool get isMap => kind == 'Map';
+ bool get isTypedData {
+ return kind == 'Uint8ClampedList'
+ || kind == 'Uint8List'
+ || kind == 'Uint16List'
+ || kind == 'Uint32List'
+ || kind == 'Uint64List'
+ || kind == 'Int8List'
+ || kind == 'Int16List'
+ || kind == 'Int32List'
+ || kind == 'Int64List'
+ || kind == 'Float32List'
+ || kind == 'Float64List'
+ || kind == 'Int32x4List'
+ || kind == 'Float32x4List'
+ || kind == 'Float64x2List';
+ }
bool get isMirrorReference => kind == 'MirrorReference';
bool get isWeakProperty => kind == 'WeakProperty';
bool get isClosure => kind == 'Closure';
@@ -1909,6 +1988,39 @@ class Instance extends ServiceObject {
fields = map['fields'];
elements = map['elements'];
associations = map['associations'];
+ if (map['bytes'] != null) {
+ var bytes = _decodeBase64(map['bytes']);
+ switch (map['kind']) {
+ case "Uint8ClampedList":
+ typedElements = bytes.buffer.asUint8ClampedList(); break;
+ case "Uint8List":
+ typedElements = bytes.buffer.asUint8List(); break;
+ case "Uint16List":
+ typedElements = bytes.buffer.asUint16List(); break;
+ case "Uint32List":
+ typedElements = bytes.buffer.asUint32List(); break;
+ case "Uint64List":
+ typedElements = bytes.buffer.asUint64List(); break;
+ case "Int8List":
+ typedElements = bytes.buffer.asInt8List(); break;
+ case "Int16List":
+ typedElements = bytes.buffer.asInt16List(); break;
+ case "Int32List":
+ typedElements = bytes.buffer.asInt32List(); break;
+ case "Int64List":
+ typedElements = bytes.buffer.asInt64List(); break;
+ case "Float32List":
+ typedElements = bytes.buffer.asFloat32List(); break;
+ case "Float64List":
+ typedElements = bytes.buffer.asFloat64List(); break;
+ case "Int32x4List":
+ typedElements = bytes.buffer.asInt32x4List(); break;
+ case "Float32x4List":
+ typedElements = bytes.buffer.asFloat32x4List(); break;
+ case "Float64x2List":
+ typedElements = bytes.buffer.asFloat64x2List(); break;
+ }
+ }
typeClass = map['typeClass'];
referent = map['mirrorReferent'];
key = map['propertyKey'];
@@ -2101,7 +2213,7 @@ class Field extends ServiceObject {
@observable String vmName;
@observable bool guardNullable;
- @observable String guardClass;
+ @observable var /* Class | String */ guardClass;
@observable String guardLength;
@observable SourceLocation location;

Powered by Google App Engine
This is Rietveld 408576698