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

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

Issue 11611009: Forbid arguments to functions with 'native' bodies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 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
« no previous file with comments | « no previous file | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 } else { 865 } else {
866 builder.compiler.internalError('unexpected kind: "${element.kind}"', 866 builder.compiler.internalError('unexpected kind: "${element.kind}"',
867 element: element); 867 element: element);
868 } 868 }
869 869
870 DartString jsCode = new DartString.literal(nativeMethodCall); 870 DartString jsCode = new DartString.literal(nativeMethodCall);
871 builder.push( 871 builder.push(
872 new HForeign(jsCode, const LiteralDartString('Object'), inputs)); 872 new HForeign(jsCode, const LiteralDartString('Object'), inputs));
873 builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit); 873 builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit);
874 } else { 874 } else {
875 // This is JS code written in a Dart file with the construct 875 if (parameters.parameterCount != 0) {
876 // native """ ... """;. It does not work well with mangling, 876 compiler.cancel(
877 // but there should currently be no clash between leg mangling 877 'native "..." syntax is restricted to functions with zero parameters',
878 // and the library where this construct is being used. This 878 node: nativeBody);
879 // mangling problem will go away once we switch these libraries 879 }
880 // to use Leg's 'JS' function.
881 parameters.forEachParameter((Element parameter) {
882 DartType type = parameter.computeType(compiler).unalias(compiler);
883 if (type is FunctionType) {
884 // The parameter type is a function type either directly or through
885 // typedef(s).
886 HInstruction jsClosure = convertDartClosure(parameter, type);
887 // Because the JS code references the argument name directly,
888 // we must keep the name and assign the JS closure to it.
889 builder.add(new HForeign(
890 new DartString.literal('${parameter.name.slowToString()} = #'),
891 const LiteralDartString('void'),
892 <HInstruction>[jsClosure]));
893 }
894 });
895 LiteralString jsCode = nativeBody.asLiteralString(); 880 LiteralString jsCode = nativeBody.asLiteralString();
896 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); 881 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[]));
897 } 882 }
898 } 883 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698