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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1353243002: Nicer error for JS() form with mismatched arguments. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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 part of ssa; 5 part of ssa;
6 6
7 class SsaFunctionCompiler implements FunctionCompiler { 7 class SsaFunctionCompiler implements FunctionCompiler {
8 final SsaCodeGeneratorTask generator; 8 final SsaCodeGeneratorTask generator;
9 final SsaBuilderTask builder; 9 final SsaBuilderTask builder;
10 final SsaOptimizerTask optimizer; 10 final SsaOptimizerTask optimizer;
(...skipping 4056 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 _) { 4067 _) {
4068 generateCallInvoke(node, localsHandler.readLocal(function), 4068 generateCallInvoke(node, localsHandler.readLocal(function),
4069 sourceInformationBuilder.buildCall(node, node.argumentsNode)); 4069 sourceInformationBuilder.buildCall(node, node.argumentsNode));
4070 } 4070 }
4071 4071
4072 void handleForeignJs(ast.Send node) { 4072 void handleForeignJs(ast.Send node) {
4073 Link<ast.Node> link = node.arguments; 4073 Link<ast.Node> link = node.arguments;
4074 // Don't visit the first argument, which is the type, and the second 4074 // Don't visit the first argument, which is the type, and the second
4075 // argument, which is the foreign code. 4075 // argument, which is the foreign code.
4076 if (link.isEmpty || link.tail.isEmpty) { 4076 if (link.isEmpty || link.tail.isEmpty) {
4077 // We should not get here because the call should be compiled to NSM.
4077 compiler.internalError(node.argumentsNode, 4078 compiler.internalError(node.argumentsNode,
4078 'At least two arguments expected.'); 4079 'At least two arguments expected.');
4079 } 4080 }
4080 native.NativeBehavior nativeBehavior = 4081 native.NativeBehavior nativeBehavior =
4081 compiler.enqueuer.resolution.nativeEnqueuer.getNativeBehaviorOf(node); 4082 compiler.enqueuer.resolution.nativeEnqueuer.getNativeBehaviorOf(node);
4082 4083
4083 List<HInstruction> inputs = <HInstruction>[]; 4084 List<HInstruction> inputs = <HInstruction>[];
4084 addGenericSendArgumentsToList(link.tail.tail, inputs); 4085 addGenericSendArgumentsToList(link.tail.tail, inputs);
4085 4086
4087 if (nativeBehavior.codeTemplate.positionalArgumentCount != inputs.length) {
4088 compiler.reportError(
4089 node, MessageKind.GENERIC,
4090 {'text':
4091 'Mismatch between number of placeholders'
4092 ' and number of arguments.'});
4093 stack.add(graph.addConstantNull(compiler)); // Result expected on stack.
4094 return;
4095 }
4096
4086 TypeMask ssaType = 4097 TypeMask ssaType =
4087 TypeMaskFactory.fromNativeBehavior(nativeBehavior, compiler); 4098 TypeMaskFactory.fromNativeBehavior(nativeBehavior, compiler);
4088 4099
4089 SourceInformation sourceInformation = 4100 SourceInformation sourceInformation =
4090 sourceInformationBuilder.buildCall(node, node.argumentsNode); 4101 sourceInformationBuilder.buildCall(node, node.argumentsNode);
4091 if (nativeBehavior.codeTemplate.isExpression) { 4102 if (nativeBehavior.codeTemplate.isExpression) {
4092 push(new HForeignCode( 4103 push(new HForeignCode(
4093 nativeBehavior.codeTemplate, ssaType, inputs, 4104 nativeBehavior.codeTemplate, ssaType, inputs,
4094 effects: nativeBehavior.sideEffects, 4105 effects: nativeBehavior.sideEffects,
4095 nativeBehavior: nativeBehavior) 4106 nativeBehavior: nativeBehavior)
(...skipping 4878 matching lines...) Expand 10 before | Expand all | Expand 10 after
8974 if (unaliased is TypedefType) throw 'unable to unalias $type'; 8985 if (unaliased is TypedefType) throw 'unable to unalias $type';
8975 unaliased.accept(this, builder); 8986 unaliased.accept(this, builder);
8976 } 8987 }
8977 8988
8978 void visitDynamicType(DynamicType type, SsaBuilder builder) { 8989 void visitDynamicType(DynamicType type, SsaBuilder builder) {
8979 JavaScriptBackend backend = builder.compiler.backend; 8990 JavaScriptBackend backend = builder.compiler.backend;
8980 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 8991 ClassElement cls = backend.findHelper('DynamicRuntimeType');
8981 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 8992 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
8982 } 8993 }
8983 } 8994 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698