Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: lib/compiler/implementation/native_handler.dart

Issue 10250002: test rename overhaul: step 5 - frog and leg tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const SourceString('defineProperty'))); 67 const SourceString('defineProperty')));
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/native/src') 77 if (library.script.name.contains('dart/frog/tests/frog_native')
78 || libraryName == 'dart:dom' 78 || libraryName == 'dart:dom'
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/native/src')) { 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);
89 } 89 }
90 } 90 }
91 91
92 void checkAllowedLibrary(ElementListener listener, Token token) { 92 void checkAllowedLibrary(ElementListener listener, Token token) {
93 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary(); 93 LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary();
94 if (!currentLibrary.canUseNative) { 94 if (!currentLibrary.canUseNative) {
95 listener.recoverableError("Unexpected token", token: token); 95 listener.recoverableError("Unexpected token", token: token);
96 } 96 }
97 } 97 }
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 String parameters) { 347 String parameters) {
348 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty"); 348 buffer.add(" if (Object.getPrototypeOf(this).hasOwnProperty");
349 buffer.add("('$methodName')) {\n"); 349 buffer.add("('$methodName')) {\n");
350 buffer.add(" $code"); 350 buffer.add(" $code");
351 buffer.add(" } else {\n"); 351 buffer.add(" } else {\n");
352 buffer.add(" return Object.prototype.$methodName.call(this"); 352 buffer.add(" return Object.prototype.$methodName.call(this");
353 buffer.add(parameters == '' ? '' : ', $parameters'); 353 buffer.add(parameters == '' ? '' : ', $parameters');
354 buffer.add(");\n"); 354 buffer.add(");\n");
355 buffer.add(" }\n"); 355 buffer.add(" }\n");
356 } 356 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698