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

Unified Diff: lib/compiler/implementation/ssa/builder.dart

Issue 10870037: Throw a NoSuchMethodException when attempting to call an undefined constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/ssa/builder.dart
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
index fe9cc7da6c39b187cfad1942fe8c654b4680acb5..48184abe255222fc0e86917158a4e08440db244b 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -1871,6 +1871,15 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
push(result);
}
+ void pushInvokeHelper3(Element helper, HInstruction a0, HInstruction a1,
+ HInstruction a2) {
+ HInstruction reference = new HStatic(helper);
+ add(reference);
+ List<HInstruction> inputs = <HInstruction>[reference, a0, a1, a2];
+ HInstruction result = new HInvokeStatic(inputs);
+ push(result);
+ }
+
visitOperatorSend(node) {
assert(node.selector is Operator);
if (!methodInterceptionEnabled) {
@@ -2421,7 +2430,29 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
// TODO(karlklose): generate runtime error or noSuchMethodCall, depending
ngeoffray 2012/08/23 10:25:05 Remove TODO.
karlklose 2012/08/23 11:05:56 Done.
// on whether element is null or it is an erroneous element with a
// particular error message.
- compiler.cancel('Unimplemented unresolved constructor call', node: node);
+ ErroneousElement error = element;
+ Message message = error.errorMessage;
+ if (message.kind === MessageKind.CANNOT_FIND_CONSTRUCTOR) {
+ Element helper =
+ compiler.findHelper(const SourceString('throwNoSuchMethod'));
+ DartString receiverLiteral = new DartString.literal('');
+ HInstruction receiver = graph.addConstantString(receiverLiteral, node);
+ String constructorName = 'constructor ${message.arguments[0]}';
+ DartString nameLiteral = new DartString.literal(constructorName);
+ HInstruction name = graph.addConstantString(nameLiteral, node.send);
+ List<HInstruction> inputs = <HInstruction>[];
+ node.send.arguments.forEach((argumentNode) {
+ visit(argumentNode);
+ HInstruction value = pop();
+ inputs.add(value);
+ });
+ HInstruction arguments = new HLiteralList(inputs);
+ add(arguments);
+ pushInvokeHelper3(helper, receiver, name, arguments);
+ } else {
+ compiler.cancel('Unimplemented unresolved constructor call',
ngeoffray 2012/08/23 10:25:05 Maybe use the message local variable instead to gi
karlklose 2012/08/23 11:05:56 This branch is currently unreachable. I will imple
+ node: node);
+ }
} else if (node.isConst()) {
// TODO(karlklose): add type representation
ConstantHandler handler = compiler.constantHandler;

Powered by Google App Engine
This is Rietveld 408576698