| 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 library native; | 5 library native; |
| 6 | 6 |
| 7 import 'dart:uri'; | 7 import 'dart:uri'; |
| 8 import 'dart2jslib.dart' hide SourceString; | 8 import 'dart2jslib.dart' hide SourceString; |
| 9 import 'elements/elements.dart'; | 9 import 'elements/elements.dart'; |
| 10 import 'js_backend/js_backend.dart'; | 10 import 'js_backend/js_backend.dart'; |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 } | 350 } |
| 351 | 351 |
| 352 void maybeEnableNative(Compiler compiler, | 352 void maybeEnableNative(Compiler compiler, |
| 353 LibraryElement library, | 353 LibraryElement library, |
| 354 Uri uri) { | 354 Uri uri) { |
| 355 String libraryName = uri.toString(); | 355 String libraryName = uri.toString(); |
| 356 if (library.entryCompilationUnit.script.name.contains( | 356 if (library.entryCompilationUnit.script.name.contains( |
| 357 'dart/tests/compiler/dart2js_native') | 357 'dart/tests/compiler/dart2js_native') |
| 358 || libraryName == 'dart:isolate' | 358 || libraryName == 'dart:isolate' |
| 359 || libraryName == 'dart:html' | 359 || libraryName == 'dart:html' |
| 360 || libraryName == 'dart:svg') { | 360 || libraryName == 'dart:svg' |
| 361 || libraryName == 'dart:web_audio') { |
| 361 library.canUseNative = true; | 362 library.canUseNative = true; |
| 362 } | 363 } |
| 363 } | 364 } |
| 364 | 365 |
| 365 /** | 366 /** |
| 366 * A summary of the behavior of a native element. | 367 * A summary of the behavior of a native element. |
| 367 * | 368 * |
| 368 * Native code can return values of one type and cause native subtypes of | 369 * Native code can return values of one type and cause native subtypes of |
| 369 * another type to be instantiated. By default, we compute both from the | 370 * another type to be instantiated. By default, we compute both from the |
| 370 * declared type. | 371 * declared type. |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 String parameters) { | 846 String parameters) { |
| 846 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 847 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
| 847 buffer.add("('$methodName')) {\n"); | 848 buffer.add("('$methodName')) {\n"); |
| 848 buffer.add(" $code"); | 849 buffer.add(" $code"); |
| 849 buffer.add(" } else {\n"); | 850 buffer.add(" } else {\n"); |
| 850 buffer.add(" return Object.prototype.$methodName.call(this"); | 851 buffer.add(" return Object.prototype.$methodName.call(this"); |
| 851 buffer.add(parameters == '' ? '' : ', $parameters'); | 852 buffer.add(parameters == '' ? '' : ', $parameters'); |
| 852 buffer.add(");\n"); | 853 buffer.add(");\n"); |
| 853 buffer.add(" }\n"); | 854 buffer.add(" }\n"); |
| 854 } | 855 } |
| OLD | NEW |