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

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

Issue 2857943002: Implement KernelNoSuchMethodResolver. (Closed)
Patch Set: Updated cf. comments Created 3 years, 7 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 | pkg/compiler/lib/src/kernel/element_map.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
diff --git a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
index a401e0585eb1de672ccca32915527e929a9f714e..bfd4df4dd30bf82afc72503e1aad3f2f206649c0 100644
--- a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
+++ b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart
@@ -4,11 +4,9 @@
import '../common.dart';
import '../common_elements.dart' show CommonElements;
-import '../common/names.dart' show Identifiers, Names, Selectors;
-import '../elements/elements.dart';
+import '../common/names.dart' show Identifiers, Selectors;
import '../elements/entities.dart';
import '../types/types.dart';
-import '../tree/tree.dart';
/**
* Categorizes `noSuchMethod` implementations.
@@ -74,6 +72,8 @@ class NoSuchMethodRegistry {
NoSuchMethodRegistry(this._commonElements, this._resolver);
+ NoSuchMethodResolver get internalResolverForTesting => _resolver;
+
bool get hasThrowingNoSuchMethod => throwingImpls.isNotEmpty;
bool get hasComplexNoSuchMethod => otherImpls.isNotEmpty;
@@ -206,85 +206,3 @@ abstract class NoSuchMethodResolver {
/// Returns the `noSuchMethod` that [method] overrides.
FunctionEntity getSuperNoSuchMethod(FunctionEntity method);
}
-
-/// AST-based implementation of [NoSuchMethodResolver].
-class NoSuchMethodResolverImpl implements NoSuchMethodResolver {
- bool hasForwardingSyntax(MethodElement element) {
- // At this point we know that this is signature-compatible with
- // Object.noSuchMethod, but it may have more than one argument as long as
- // it only has one required argument.
- if (!element.hasResolvedAst) {
- // TODO(johnniwinther): Why do we see unresolved elements here?
- return false;
- }
- ResolvedAst resolvedAst = element.resolvedAst;
- if (resolvedAst.kind != ResolvedAstKind.PARSED) {
- return false;
- }
- String param = element.parameters.first.name;
- Statement body = resolvedAst.body;
- Expression expr;
- if (body is Return && body.isArrowBody) {
- expr = body.expression;
- } else if (body is Block &&
- !body.statements.isEmpty &&
- body.statements.nodes.tail.isEmpty) {
- Statement stmt = body.statements.nodes.head;
- if (stmt is Return && stmt.hasExpression) {
- expr = stmt.expression;
- }
- }
- if (expr is Send && expr.isTypeCast) {
- Send sendExpr = expr;
- var typeAnnotation = sendExpr.typeAnnotationFromIsCheckOrCast;
- var typeName = typeAnnotation.asNominalTypeAnnotation()?.typeName;
- if (typeName is Identifier && typeName.source == "dynamic") {
- expr = sendExpr.receiver;
- }
- }
- if (expr is Send &&
- expr.isSuperCall &&
- expr.selector is Identifier &&
- (expr.selector as Identifier).source == Identifiers.noSuchMethod_) {
- var arg = expr.arguments.head;
- if (expr.arguments.tail.isEmpty &&
- arg is Send &&
- arg.argumentsNode == null &&
- arg.receiver == null &&
- arg.selector is Identifier &&
- arg.selector.source == param) {
- return true;
- }
- }
- return false;
- }
-
- bool hasThrowingSyntax(MethodElement element) {
- if (!element.hasResolvedAst) {
- // TODO(johnniwinther): Why do we see unresolved elements here?
- return false;
- }
- ResolvedAst resolvedAst = element.resolvedAst;
- if (resolvedAst.kind != ResolvedAstKind.PARSED) {
- return false;
- }
- Statement body = resolvedAst.body;
- if (body is Return && body.isArrowBody) {
- if (body.expression is Throw) {
- return true;
- }
- } else if (body is Block &&
- !body.statements.isEmpty &&
- body.statements.nodes.tail.isEmpty) {
- if (body.statements.nodes.head is ExpressionStatement) {
- ExpressionStatement stmt = body.statements.nodes.head;
- return stmt.expression is Throw;
- }
- }
- return false;
- }
-
- MethodElement getSuperNoSuchMethod(MethodElement method) {
- return method.enclosingClass.lookupSuperByName(Names.noSuchMethod_);
- }
-}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/element_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698