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

Unified Diff: sdk/lib/html/src/dart2js_Conversions.dart

Issue 11308075: Add custom annotations to some APIs for native tree shaking. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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: sdk/lib/html/src/dart2js_Conversions.dart
diff --git a/sdk/lib/html/src/dart2js_Conversions.dart b/sdk/lib/html/src/dart2js_Conversions.dart
index ab0b85192c5fa75e670876af6c01e424aefd78e2..cc4469970dccdfe87f214d13ca0b68cbad8c4ba5 100644
--- a/sdk/lib/html/src/dart2js_Conversions.dart
+++ b/sdk/lib/html/src/dart2js_Conversions.dart
@@ -99,7 +99,7 @@ _convertDartToNative_ImageData(ImageData imageData) {
Map _convertNativeToDart_Dictionary(object) {
if (object == null) return null;
var dict = {};
- for (final key in JS('List', 'Object.getOwnPropertyNames(#)', object)) {
+ for (final key in JS('=List', 'Object.getOwnPropertyNames(#)', object)) {
dict[key] = JS('var', '#[#]', object, key);
}
return dict;
@@ -276,7 +276,7 @@ _convertDartToNative_PrepareForStructuredClone(value) {
var copy = readSlot(slot);
if (copy != null) {
if (true == copy) { // Cycle, so commit to making a copy.
- copy = JS('List', 'new Array(#)', length);
+ copy = JS('=List', 'new Array(#)', length);
writeSlot(slot, copy);
}
return copy;
@@ -296,7 +296,7 @@ _convertDartToNative_PrepareForStructuredClone(value) {
if (!identical(elementCopy, element)) {
copy = readSlot(slot); // Cyclic reference may have created it.
if (true == copy) {
- copy = JS('List', 'new Array(#)', length);
+ copy = JS('=List', 'new Array(#)', length);
writeSlot(slot, copy);
}
for (int j = 0; j < i; j++) {
@@ -313,7 +313,7 @@ _convertDartToNative_PrepareForStructuredClone(value) {
}
} else {
// Not a JavaScript Array. We are forced to make a copy.
- copy = JS('List', 'new Array(#)', length);
+ copy = JS('=List', 'new Array(#)', length);
writeSlot(slot, copy);
}
@@ -393,7 +393,7 @@ _convertNativeToDart_AcceptStructuredClone(object, {mustCopy = false}) {
copy = {};
writeSlot(slot, copy);
- for (final key in JS('List', 'Object.keys(#)', e)) {
+ for (final key in JS('=List', 'Object.keys(#)', e)) {
copy[key] = walk(JS('var', '#[#]', e, key));
}
return copy;
@@ -407,7 +407,7 @@ _convertNativeToDart_AcceptStructuredClone(object, {mustCopy = false}) {
int length = e.length;
// Since a JavaScript Array is an instance of Dart List, we can modify it
// in-place unless we must copy.
- copy = mustCopy ? JS('List', 'new Array(#)', length) : e;
+ copy = mustCopy ? JS('=List', 'new Array(#)', length) : e;
writeSlot(slot, copy);
for (int i = 0; i < length; i++) {
@@ -433,3 +433,20 @@ bool _isJavaScriptSimpleObject(value) =>
JS('bool', 'Object.getPrototypeOf(#) === Object.prototype', value);
bool _isImmutableJavaScriptArray(value) =>
JS('bool', r'!!(#.immutable$list)', value);
+
+
+
+const String _serializedScriptValue =
+ 'num|String|bool|'
+ '=List|=Object|'
+ 'Blob|File|ArrayBuffer|ArrayBufferView'
+ // TODO(sra): Add Date, RegExp.
+ ;
+const _annotation_Creates_SerializedScriptValue =
+ const Creates(_serializedScriptValue);
+const _annotation_Returns_SerializedScriptValue =
+ const Returns(_serializedScriptValue);
+
+const String _idbKey = '=List|=Object|num|String'; // TODO(sra): Add Date.
+const _annotation_Creates_IDBKey = const Creates(_idbKey);
+const _annotation_Returns_IDBKey = const Returns(_idbKey);
« no previous file with comments | « sdk/lib/html/scripts/systemhtml.py ('k') | sdk/lib/html/templates/html/impl/impl_DocumentFragment.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698