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

Unified 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 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/native_handler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/native_handler.dart b/sdk/lib/_internal/compiler/implementation/native_handler.dart
index 7acaecddbee5ff54b3436102f025149d7bf5c834..4367c6d9dde631fe6498a6a9ea1f6481774e3f33 100644
--- a/sdk/lib/_internal/compiler/implementation/native_handler.dart
+++ b/sdk/lib/_internal/compiler/implementation/native_handler.dart
@@ -872,26 +872,11 @@ void handleSsaNative(SsaBuilder builder, Expression nativeBody) {
new HForeign(jsCode, const LiteralDartString('Object'), inputs));
builder.close(new HReturn(builder.pop())).addSuccessor(builder.graph.exit);
} else {
- // This is JS code written in a Dart file with the construct
- // native """ ... """;. It does not work well with mangling,
- // but there should currently be no clash between leg mangling
- // and the library where this construct is being used. This
- // mangling problem will go away once we switch these libraries
- // to use Leg's 'JS' function.
- parameters.forEachParameter((Element parameter) {
- DartType type = parameter.computeType(compiler).unalias(compiler);
- if (type is FunctionType) {
- // The parameter type is a function type either directly or through
- // typedef(s).
- HInstruction jsClosure = convertDartClosure(parameter, type);
- // Because the JS code references the argument name directly,
- // we must keep the name and assign the JS closure to it.
- builder.add(new HForeign(
- new DartString.literal('${parameter.name.slowToString()} = #'),
- const LiteralDartString('void'),
- <HInstruction>[jsClosure]));
- }
- });
+ if (parameters.parameterCount != 0) {
+ compiler.cancel(
+ 'native "..." syntax is restricted to functions with zero parameters',
+ node: nativeBody);
+ }
LiteralString jsCode = nativeBody.asLiteralString();
builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[]));
}
« 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