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

Unified Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 879233005: cps-ir: Correctly bailout on unresolved static calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index d97abb45d0812d06cdc18b90137c920ec581bbec..07ec340b7e52201edc6060a94c32c7aa263522bb 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -180,6 +180,8 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
@override
js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) {
+ checkStaticTargetIsValid(node, node.target);
+
if (node.constant != null) return giveup(node);
registry.registerInstantiatedClass(node.target.enclosingClass);
return buildStaticInvoke(node.selector,
@@ -203,8 +205,24 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
visitArguments(node.arguments));
}
+ /// Checks that the target of the static call is not an [ErroneousElement].
+ ///
+ /// This helper should be removed and the code to generate the CPS IR for
+ /// the dart2js backend should construct a call to a helper that throw an
+ /// appropriate error message instead of the static call.
asgerf 2015/02/06 10:12:40 Agreed.
+ ///
+ /// See [SsaBuilder.visitStaticSend] as an example how to do this.
+ void checkStaticTargetIsValid(tree_ir.Node node, Element target) {
+ if (target.isErroneous) {
+ giveup(node, 'cannot generate error handling code'
+ ' for call to unresolved target');
+ }
+ }
+
@override
js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) {
+ checkStaticTargetIsValid(node, node.target);
+
if (node.target is! FunctionElement) {
giveup(node, 'static getters and setters are not supported.');
}
« 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