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:collection' show Queue; | 7 import 'dart:collection' show Queue; |
8 import 'dart:uri'; | 8 import 'dart:uri'; |
9 import 'dart2jslib.dart' hide SourceString; | 9 import 'dart2jslib.dart' hide SourceString; |
10 import 'dart_types.dart'; | 10 import 'dart_types.dart'; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 // all the native classes are included. | 355 // all the native classes are included. |
356 if (unusedClasses.isEmpty && !allUsedBefore) { | 356 if (unusedClasses.isEmpty && !allUsedBefore) { |
357 compiler.log('All native types marked as used due to $cause.'); | 357 compiler.log('All native types marked as used due to $cause.'); |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 enqueueUnusedClassesMatching(bool predicate(classElement), | 361 enqueueUnusedClassesMatching(bool predicate(classElement), |
362 cause, | 362 cause, |
363 [String reason]) { | 363 [String reason]) { |
364 Iterable matches = unusedClasses.where(predicate); | 364 Iterable matches = unusedClasses.where(predicate); |
365 matches.forEach((c) => enqueueClass(c, cause)); | 365 matches.toList().forEach((c) => enqueueClass(c, cause)); |
366 } | 366 } |
367 | 367 |
368 onFirstNativeClass() { | 368 onFirstNativeClass() { |
369 staticUse(name) => world.registerStaticUse(compiler.findHelper(name)); | 369 staticUse(name) => world.registerStaticUse(compiler.findHelper(name)); |
370 | 370 |
371 staticUse(const SourceString('dynamicFunction')); | 371 staticUse(const SourceString('dynamicFunction')); |
372 staticUse(const SourceString('dynamicSetMetadata')); | 372 staticUse(const SourceString('dynamicSetMetadata')); |
373 staticUse(const SourceString('defineProperty')); | 373 staticUse(const SourceString('defineProperty')); |
374 staticUse(const SourceString('toStringForNativeObject')); | 374 staticUse(const SourceString('toStringForNativeObject')); |
375 staticUse(const SourceString('hashCodeForNativeObject')); | 375 staticUse(const SourceString('hashCodeForNativeObject')); |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 } else { | 893 } else { |
894 if (parameters.parameterCount != 0) { | 894 if (parameters.parameterCount != 0) { |
895 compiler.cancel( | 895 compiler.cancel( |
896 'native "..." syntax is restricted to functions with zero parameters', | 896 'native "..." syntax is restricted to functions with zero parameters', |
897 node: nativeBody); | 897 node: nativeBody); |
898 } | 898 } |
899 LiteralString jsCode = nativeBody.asLiteralString(); | 899 LiteralString jsCode = nativeBody.asLiteralString(); |
900 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); | 900 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); |
901 } | 901 } |
902 } | 902 } |
OLD | NEW |