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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void maybeEnableNative(Compiler compiler, | 78 void maybeEnableNative(Compiler compiler, |
79 LibraryElement library, | 79 LibraryElement library, |
80 Uri uri) { | 80 Uri uri) { |
81 String libraryName = uri.toString(); | 81 String libraryName = uri.toString(); |
82 if (library.entryCompilationUnit.script.name.contains( | 82 if (library.entryCompilationUnit.script.name.contains( |
83 'dart/tests/compiler/dart2js_native') | 83 'dart/tests/compiler/dart2js_native') |
84 || libraryName == 'dart:isolate' | 84 || libraryName == 'dart:isolate' |
85 || libraryName == 'dart:html') { | 85 || libraryName == 'dart:html' |
| 86 || libraryName == 'dart:svg') { |
86 library.canUseNative = true; | 87 library.canUseNative = true; |
87 } | 88 } |
88 } | 89 } |
89 | 90 |
90 void checkAllowedLibrary(ElementListener listener, Token token) { | 91 void checkAllowedLibrary(ElementListener listener, Token token) { |
91 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); | 92 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); |
92 if (!currentLibrary.canUseNative) { | 93 if (!currentLibrary.canUseNative) { |
93 listener.recoverableError("Unexpected token", token: token); | 94 listener.recoverableError("Unexpected token", token: token); |
94 } | 95 } |
95 } | 96 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 String parameters) { | 332 String parameters) { |
332 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 333 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
333 buffer.add("('$methodName')) {\n"); | 334 buffer.add("('$methodName')) {\n"); |
334 buffer.add(" $code"); | 335 buffer.add(" $code"); |
335 buffer.add(" } else {\n"); | 336 buffer.add(" } else {\n"); |
336 buffer.add(" return Object.prototype.$methodName.call(this"); | 337 buffer.add(" return Object.prototype.$methodName.call(this"); |
337 buffer.add(parameters == '' ? '' : ', $parameters'); | 338 buffer.add(parameters == '' ? '' : ', $parameters'); |
338 buffer.add(");\n"); | 339 buffer.add(");\n"); |
339 buffer.add(" }\n"); | 340 buffer.add(" }\n"); |
340 } | 341 } |
OLD | NEW |