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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart

Issue 2180533002: Feature-detect browser for assignment to __proto__. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: fix regexp Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library dart2js.js_emitter.full_emitter; 5 library dart2js.js_emitter.full_emitter;
6 6
7 import 'dart:collection' show HashMap; 7 import 'dart:collection' show HashMap;
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; 10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames;
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 if (compiler.options.hasIncrementalSupport) { 1060 if (compiler.options.hasIncrementalSupport) {
1061 supportsDirectProtoAccess = js.statement(r''' 1061 supportsDirectProtoAccess = js.statement(r'''
1062 var supportsDirectProtoAccess = false; 1062 var supportsDirectProtoAccess = false;
1063 '''); 1063 ''');
1064 } else { 1064 } else {
1065 supportsDirectProtoAccess = js.statement(r''' 1065 supportsDirectProtoAccess = js.statement(r'''
1066 var supportsDirectProtoAccess = (function () { 1066 var supportsDirectProtoAccess = (function () {
1067 var cls = function () {}; 1067 var cls = function () {};
1068 cls.prototype = {'p': {}}; 1068 cls.prototype = {'p': {}};
1069 var object = new cls(); 1069 var object = new cls();
1070 return object.__proto__ && 1070 if (!(object.__proto__ && object.__proto__.p === cls.prototype.p))
1071 object.__proto__.p === cls.prototype.p; 1071 return false;
1072 })(); 1072
1073 try {
1074 // Are we running on a platform where the performance is good?
1075 // (i.e. Chrome or d8).
1076
1077 // Chrome userAgent?
1078 if (typeof navigator != "undefined" &&
1079 typeof navigator.userAgent == "string" &&
1080 navigator.userAgent.indexOf("Chrome/") >= 0) return true;
1081
1082 // d8 version() looks like "N.N.N.N", jsshell version() like "N".
1083 if (typeof version == "function" &&
1084 version.length == 0) {
1085 var v = version();
1086 if (/^\d+\.\d+\.\d+\.\d+$/.test(v)) return true;
1087 }
1088 } catch(_) {}
1089
1090 return false;
1091 })();
1073 '''); 1092 ''');
1074 } 1093 }
1075 1094
1076 return supportsDirectProtoAccess; 1095 return supportsDirectProtoAccess;
1077 } 1096 }
1078 1097
1079 jsAst.Expression generateLibraryDescriptor( 1098 jsAst.Expression generateLibraryDescriptor(
1080 LibraryElement library, Fragment fragment) { 1099 LibraryElement library, Fragment fragment) {
1081 var uri = ""; 1100 var uri = "";
1082 if (!compiler.options.enableMinification || backend.mustPreserveUris) { 1101 if (!compiler.options.enableMinification || backend.mustPreserveUris) {
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 if (cachedElements.isEmpty) return; 2150 if (cachedElements.isEmpty) return;
2132 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2151 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2133 if (element.isInstanceMember) { 2152 if (element.isInstanceMember) {
2134 cachedClassBuilders.remove(element.enclosingClass); 2153 cachedClassBuilders.remove(element.enclosingClass);
2135 2154
2136 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2155 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2137 } 2156 }
2138 } 2157 }
2139 } 2158 }
2140 } 2159 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698