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

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

Issue 2990223002: Reformat untouched files. (Closed)
Patch Set: Created 3 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
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.native_generator; 5 library dart2js.js_emitter.native_generator;
6 6
7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; 7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames;
8 8
9 import '../js/js.dart' as jsAst; 9 import '../js/js.dart' as jsAst;
10 import '../js/js.dart' show js; 10 import '../js/js.dart' show js;
(...skipping 16 matching lines...) Expand all
27 jsAst.Expression internStringFunction) { 27 jsAst.Expression internStringFunction) {
28 assert(backendUsage.needToInitializeIsolateAffinityTag); 28 assert(backendUsage.needToInitializeIsolateAffinityTag);
29 29
30 jsAst.Expression getIsolateTagAccess = 30 jsAst.Expression getIsolateTagAccess =
31 generateEmbeddedGlobalAccess(embeddedNames.GET_ISOLATE_TAG); 31 generateEmbeddedGlobalAccess(embeddedNames.GET_ISOLATE_TAG);
32 jsAst.Expression isolateTagAccess = 32 jsAst.Expression isolateTagAccess =
33 generateEmbeddedGlobalAccess(embeddedNames.ISOLATE_TAG); 33 generateEmbeddedGlobalAccess(embeddedNames.ISOLATE_TAG);
34 jsAst.Expression dispatchPropertyNameAccess = 34 jsAst.Expression dispatchPropertyNameAccess =
35 generateEmbeddedGlobalAccess(embeddedNames.DISPATCH_PROPERTY_NAME); 35 generateEmbeddedGlobalAccess(embeddedNames.DISPATCH_PROPERTY_NAME);
36 36
37 return js.statement( 37 return js.statement('''
38 '''
39 !function() { 38 !function() {
40 var intern = #internStringFunction; 39 var intern = #internStringFunction;
41 40
42 #getIsolateTag = function(name) { 41 #getIsolateTag = function(name) {
43 return intern("___dart_" + name + #isolateTag); 42 return intern("___dart_" + name + #isolateTag);
44 }; 43 };
45 44
46 // To ensure that different programs loaded into the same context (page) 45 // To ensure that different programs loaded into the same context (page)
47 // use distinct dispatch properies, we place an object on `Object` to 46 // use distinct dispatch properies, we place an object on `Object` to
48 // contain the names already in use. 47 // contain the names already in use.
49 var tableProperty = "___dart_isolate_tags_"; 48 var tableProperty = "___dart_isolate_tags_";
50 var usedProperties = Object[tableProperty] || 49 var usedProperties = Object[tableProperty] ||
51 (Object[tableProperty] = Object.create(null)); 50 (Object[tableProperty] = Object.create(null));
52 51
53 var rootProperty = "_${generateIsolateTagRoot()}"; 52 var rootProperty = "_${generateIsolateTagRoot()}";
54 for (var i = 0; ; i++) { 53 for (var i = 0; ; i++) {
55 var property = intern(rootProperty + "_" + i + "_"); 54 var property = intern(rootProperty + "_" + i + "_");
56 if (!(property in usedProperties)) { 55 if (!(property in usedProperties)) {
57 usedProperties[property] = 1; 56 usedProperties[property] = 1;
58 #isolateTag = property; 57 #isolateTag = property;
59 break; 58 break;
60 } 59 }
61 } 60 }
62 if (#initializeDispatchProperty) { 61 if (#initializeDispatchProperty) {
63 #dispatchPropertyName = #getIsolateTag("dispatch_record"); 62 #dispatchPropertyName = #getIsolateTag("dispatch_record");
64 } 63 }
65 }(); 64 }();
66 ''', 65 ''', {
67 { 66 'initializeDispatchProperty':
68 'initializeDispatchProperty': 67 backendUsage.needToInitializeDispatchProperty,
69 backendUsage.needToInitializeDispatchProperty, 68 'internStringFunction': internStringFunction,
70 'internStringFunction': internStringFunction, 69 'getIsolateTag': getIsolateTagAccess,
71 'getIsolateTag': getIsolateTagAccess, 70 'isolateTag': isolateTagAccess,
72 'isolateTag': isolateTagAccess, 71 'dispatchPropertyName': dispatchPropertyNameAccess
73 'dispatchPropertyName': dispatchPropertyNameAccess 72 });
74 });
75 } 73 }
76 74
77 static String generateIsolateTagRoot() { 75 static String generateIsolateTagRoot() {
78 // TODO(sra): MD5 of contributing source code or URIs? 76 // TODO(sra): MD5 of contributing source code or URIs?
79 return 'ZxYxX'; 77 return 'ZxYxX';
80 } 78 }
81 79
82 /// Encodes the collected native information so that it can be treated by 80 /// Encodes the collected native information so that it can be treated by
83 /// the native info-handler below. 81 /// the native info-handler below.
84 /// 82 ///
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 /// Both variables are passed in (instead of creating the access here) to 146 /// Both variables are passed in (instead of creating the access here) to
149 /// make sure the caller is aware of these globals. 147 /// make sure the caller is aware of these globals.
150 static jsAst.Statement buildNativeInfoHandler( 148 static jsAst.Statement buildNativeInfoHandler(
151 jsAst.Expression infoAccess, 149 jsAst.Expression infoAccess,
152 jsAst.Expression constructorAccess, 150 jsAst.Expression constructorAccess,
153 jsAst.Expression subclassReadGenerator(jsAst.Expression subclass), 151 jsAst.Expression subclassReadGenerator(jsAst.Expression subclass),
154 jsAst.Expression interceptorsByTagAccess, 152 jsAst.Expression interceptorsByTagAccess,
155 jsAst.Expression leafTagsAccess) { 153 jsAst.Expression leafTagsAccess) {
156 jsAst.Expression subclassRead = 154 jsAst.Expression subclassRead =
157 subclassReadGenerator(js('subclasses[i]', [])); 155 subclassReadGenerator(js('subclasses[i]', []));
158 return js.statement( 156 return js.statement('''
159 '''
160 // The native info looks like this: 157 // The native info looks like this:
161 // 158 //
162 // HtmlElement: { 159 // HtmlElement: {
163 // "%": "HTMLDivElement|HTMLAnchorElement;HTMLElement;FancyButton" 160 // "%": "HTMLDivElement|HTMLAnchorElement;HTMLElement;FancyButton"
164 // 161 //
165 // The first two semicolon-separated parts contain dispatch tags, the 162 // The first two semicolon-separated parts contain dispatch tags, the
166 // third contains the JavaScript names for classes. 163 // third contains the JavaScript names for classes.
167 // 164 //
168 // The tags indicate that JavaScript objects with the dispatch tags 165 // The tags indicate that JavaScript objects with the dispatch tags
169 // (usually constructor names) HTMLDivElement, HTMLAnchorElement and 166 // (usually constructor names) HTMLDivElement, HTMLAnchorElement and
(...skipping 27 matching lines...) Expand all
197 subclass.#nativeSuperclassTagName = tags[0]; 194 subclass.#nativeSuperclassTagName = tags[0];
198 } 195 }
199 } 196 }
200 for (i = 0; i < tags.length; i++) { 197 for (i = 0; i < tags.length; i++) {
201 #interceptorsByTagAccess[tags[i]] = #constructor; 198 #interceptorsByTagAccess[tags[i]] = #constructor;
202 #leafTagsAccess[tags[i]] = false; 199 #leafTagsAccess[tags[i]] = false;
203 } 200 }
204 } 201 }
205 } 202 }
206 } 203 }
207 ''', 204 ''', {
208 { 205 'info': infoAccess,
209 'info': infoAccess, 206 'constructor': constructorAccess,
210 'constructor': constructorAccess, 207 'subclassRead': subclassRead,
211 'subclassRead': subclassRead, 208 'interceptorsByTagAccess': interceptorsByTagAccess,
212 'interceptorsByTagAccess': interceptorsByTagAccess, 209 'leafTagsAccess': leafTagsAccess,
213 'leafTagsAccess': leafTagsAccess, 210 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME,
214 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME, 211 'allowNativesSubclassing': true
215 'allowNativesSubclassing': true 212 });
216 });
217 } 213 }
218 } 214 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698