OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
6 | 6 |
7 class NativeEmitter { | 7 class NativeEmitter { |
8 | 8 |
9 final Map<Element, ClassBuilder> cachedBuilders; | 9 final Map<Element, ClassBuilder> cachedBuilders; |
10 | 10 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 List<Class> extensions = extensionPoints[cls]; | 188 List<Class> extensions = extensionPoints[cls]; |
189 | 189 |
190 String leafStr = formatTags(leafTags[cls]); | 190 String leafStr = formatTags(leafTags[cls]); |
191 String nonleafStr = formatTags(nonleafTags[cls]); | 191 String nonleafStr = formatTags(nonleafTags[cls]); |
192 | 192 |
193 StringBuffer sb = new StringBuffer(leafStr); | 193 StringBuffer sb = new StringBuffer(leafStr); |
194 if (nonleafStr != '') { | 194 if (nonleafStr != '') { |
195 sb..write(';')..write(nonleafStr); | 195 sb..write(';')..write(nonleafStr); |
196 } | 196 } |
197 if (extensions != null) { | 197 |
198 sb..write(';') | |
199 ..writeAll(extensions.map((Class cls) => cls.name), '|'); | |
200 } | |
201 String encoding = sb.toString(); | 198 String encoding = sb.toString(); |
202 | 199 |
203 if (cls.isNative || encoding != '') { | 200 if (cls.isNative || encoding != '' || extensions != null) { |
| 201 List<jsAst.Literal> parts = <jsAst.Literal>[js.stringPart(encoding)]; |
| 202 if (extensions != null) { |
| 203 parts..add(js.stringPart(';')) |
| 204 ..addAll( |
| 205 js.joinLiterals(extensions.map((Class cls) => cls.name), |
| 206 js.stringPart('|'))); |
| 207 } |
204 assert(cls.nativeInfo == null); | 208 assert(cls.nativeInfo == null); |
205 cls.nativeInfo = encoding; | 209 cls.nativeInfo = js.concatenateStrings(parts, addQuotes: true); |
206 } | 210 } |
207 } | 211 } |
208 generateClassInfo(jsInterceptorClass); | 212 generateClassInfo(jsInterceptorClass); |
209 for (Class cls in classes) { | 213 for (Class cls in classes) { |
210 if (!cls.isNative || neededClasses.contains(cls)) { | 214 if (!cls.isNative || neededClasses.contains(cls)) { |
211 generateClassInfo(cls); | 215 generateClassInfo(cls); |
212 } | 216 } |
213 } | 217 } |
214 } | 218 } |
215 | 219 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 break; | 298 break; |
295 } | 299 } |
296 } | 300 } |
297 } | 301 } |
298 }); | 302 }); |
299 } | 303 } |
300 | 304 |
301 List<jsAst.Statement> generateParameterStubStatements( | 305 List<jsAst.Statement> generateParameterStubStatements( |
302 FunctionElement member, | 306 FunctionElement member, |
303 bool isInterceptedMethod, | 307 bool isInterceptedMethod, |
304 String invocationName, | 308 jsAst.Name invocationName, |
305 List<jsAst.Parameter> stubParameters, | 309 List<jsAst.Parameter> stubParameters, |
306 List<jsAst.Expression> argumentsBuffer, | 310 List<jsAst.Expression> argumentsBuffer, |
307 int indexOfLastOptionalArgumentInParameters) { | 311 int indexOfLastOptionalArgumentInParameters) { |
308 // The target JS function may check arguments.length so we need to | 312 // The target JS function may check arguments.length so we need to |
309 // make sure not to pass any unspecified optional arguments to it. | 313 // make sure not to pass any unspecified optional arguments to it. |
310 // For example, for the following Dart method: | 314 // For example, for the following Dart method: |
311 // foo([x, y, z]); | 315 // foo([x, y, z]); |
312 // The call: | 316 // The call: |
313 // foo(y: 1) | 317 // foo(y: 1) |
314 // must be turned into a JS call to: | 318 // must be turned into a JS call to: |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 453 } |
450 ''', {'info': infoAccess, | 454 ''', {'info': infoAccess, |
451 'constructor': constructorAccess, | 455 'constructor': constructorAccess, |
452 'subclassRead': subclassRead, | 456 'subclassRead': subclassRead, |
453 'interceptorsByTagAccess': interceptorsByTagAccess, | 457 'interceptorsByTagAccess': interceptorsByTagAccess, |
454 'leafTagsAccess': leafTagsAccess, | 458 'leafTagsAccess': leafTagsAccess, |
455 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME, | 459 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME, |
456 'allowNativesSubclassing': true}); | 460 'allowNativesSubclassing': true}); |
457 } | 461 } |
458 } | 462 } |
OLD | NEW |