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 #import('dart:uri'); | 6 #import('dart:uri'); |
7 #import('leg.dart'); | 7 #import('leg.dart'); |
8 #import('elements/elements.dart'); | 8 #import('elements/elements.dart'); |
9 #import('scanner/scannerlib.dart'); | 9 #import('scanner/scannerlib.dart'); |
10 #import('ssa/ssa.dart'); | 10 #import('ssa/ssa.dart'); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 compiler.registerStaticUse(compiler.findHelper( | 68 compiler.registerStaticUse(compiler.findHelper( |
69 const SourceString('toStringForNativeObject'))); | 69 const SourceString('toStringForNativeObject'))); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 void maybeEnableNative(Compiler compiler, | 73 void maybeEnableNative(Compiler compiler, |
74 LibraryElement library, | 74 LibraryElement library, |
75 Uri uri) { | 75 Uri uri) { |
76 String libraryName = uri.toString(); | 76 String libraryName = uri.toString(); |
77 if (library.script.name.contains('dart/frog/tests/frog_native') | 77 if (library.script.name.contains('dart/frog/tests/frog_native') |
78 || libraryName == 'dart:dom' | 78 || libraryName == 'dart:dom_deprecated' |
79 || libraryName == 'dart:isolate' | 79 || libraryName == 'dart:isolate' |
80 || libraryName == 'dart:html') { | 80 || libraryName == 'dart:html') { |
81 library.define(new ForeignElement( | 81 library.define(new ForeignElement( |
82 const SourceString('native'), library), compiler); | 82 const SourceString('native'), library), compiler); |
83 library.canUseNative = true; | 83 library.canUseNative = true; |
84 } | 84 } |
85 | 85 |
86 // Additionaly, if this is a test, we allow access to foreign functions. | 86 // Additionaly, if this is a test, we allow access to foreign functions. |
87 if (library.script.name.contains('dart/frog/tests/frog_native')) { | 87 if (library.script.name.contains('dart/frog/tests/frog_native')) { |
88 library.define(compiler.findHelper(const SourceString('JS')), compiler); | 88 library.define(compiler.findHelper(const SourceString('JS')), compiler); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 String parameters) { | 346 String parameters) { |
347 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); | 347 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); |
348 buffer.add("('$methodName')) {\n"); | 348 buffer.add("('$methodName')) {\n"); |
349 buffer.add(" $code"); | 349 buffer.add(" $code"); |
350 buffer.add(" } else {\n"); | 350 buffer.add(" } else {\n"); |
351 buffer.add(" return Object.prototype.$methodName.call(this"); | 351 buffer.add(" return Object.prototype.$methodName.call(this"); |
352 buffer.add(parameters == '' ? '' : ', $parameters'); | 352 buffer.add(parameters == '' ? '' : ', $parameters'); |
353 buffer.add(");\n"); | 353 buffer.add(");\n"); |
354 buffer.add(" }\n"); | 354 buffer.add(" }\n"); |
355 } | 355 } |
OLD | NEW |