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

Side by Side Diff: pkg/compiler/lib/src/kernel/element_map.dart

Issue 2904493002: Use KernelToElementMap (more) directly in KernelSsaBuilder (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/no_such_method_resolver.dart » ('j') | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart'; 8 import '../common/names.dart';
9 import '../constants/constructors.dart'; 9 import '../constants/constructors.dart';
10 import '../constants/expressions.dart'; 10 import '../constants/expressions.dart';
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 /// Compute the kind of foreign helper function called by [node], if any. 136 /// Compute the kind of foreign helper function called by [node], if any.
137 ForeignKind getForeignKind(ir.StaticInvocation node); 137 ForeignKind getForeignKind(ir.StaticInvocation node);
138 138
139 /// Computes the [InterfaceType] referenced by a call to the 139 /// Computes the [InterfaceType] referenced by a call to the
140 /// [JS_INTERCEPTOR_CONSTANT] function, if any. 140 /// [JS_INTERCEPTOR_CONSTANT] function, if any.
141 InterfaceType getInterfaceTypeForJsInterceptorCall(ir.StaticInvocation node); 141 InterfaceType getInterfaceTypeForJsInterceptorCall(ir.StaticInvocation node);
142 142
143 /// Computes the [ConstantValue] for the constant [expression]. 143 /// Computes the [ConstantValue] for the constant [expression].
144 ConstantValue getConstantValue(ir.Expression expression); 144 ConstantValue getConstantValue(ir.Expression expression);
145
146 /// Returns the `noSuchMethod` [FunctionEntity] call from a
147 /// `super.noSuchMethod` invocation within [cls].
148 FunctionEntity getSuperNoSuchMethod(ClassEntity cls);
145 } 149 }
146 150
147 /// Kinds of foreign functions. 151 /// Kinds of foreign functions.
148 enum ForeignKind { 152 enum ForeignKind {
149 JS, 153 JS,
150 JS_BUILTIN, 154 JS_BUILTIN,
151 JS_EMBEDDED_GLOBAL, 155 JS_EMBEDDED_GLOBAL,
152 JS_INTERCEPTOR_CONSTANT, 156 JS_INTERCEPTOR_CONSTANT,
153 NONE, 157 NONE,
154 } 158 }
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 /// Computes the native behavior for calling [procedure]. 469 /// Computes the native behavior for calling [procedure].
466 // TODO(johnniwinther): Cache this for later use. 470 // TODO(johnniwinther): Cache this for later use.
467 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure, 471 native.NativeBehavior getNativeBehaviorForMethod(ir.Procedure procedure,
468 {bool isJsInterop}) { 472 {bool isJsInterop}) {
469 DartType type = getFunctionType(procedure.function); 473 DartType type = getFunctionType(procedure.function);
470 List<ConstantValue> metadata = getMetadata(procedure.annotations); 474 List<ConstantValue> metadata = getMetadata(procedure.annotations);
471 return nativeBehaviorBuilder.buildMethodBehavior( 475 return nativeBehaviorBuilder.buildMethodBehavior(
472 type, metadata, typeLookup(resolveAsRaw: false), 476 type, metadata, typeLookup(resolveAsRaw: false),
473 isJsInterop: isJsInterop); 477 isJsInterop: isJsInterop);
474 } 478 }
479
480 @override
481 FunctionEntity getSuperNoSuchMethod(ClassEntity cls) {
482 while (cls != null) {
483 cls = elementEnvironment.getSuperClass(cls);
484 MemberEntity member =
485 elementEnvironment.lookupClassMember(cls, Identifiers.noSuchMethod_);
486 if (member != null) {
487 if (member.isFunction) {
488 FunctionEntity function = member;
489 if (function.parameterStructure.positionalParameters >= 1) {
490 return function;
491 }
492 }
493 // If [member] is not a valid `noSuchMethod` the target is
494 // `Object.superNoSuchMethod`.
495 break;
496 }
497 }
498 FunctionEntity function = elementEnvironment.lookupClassMember(
499 commonElements.objectClass, Identifiers.noSuchMethod_);
500 assert(invariant(cls, function != null,
501 message: "No super noSuchMethod found for class $cls."));
502 return function;
503 }
475 } 504 }
476 505
477 /// Visitor that converts string literals and concatenations of string literals 506 /// Visitor that converts string literals and concatenations of string literals
478 /// into the string value. 507 /// into the string value.
479 class Stringifier extends ir.ExpressionVisitor<String> { 508 class Stringifier extends ir.ExpressionVisitor<String> {
480 @override 509 @override
481 String visitStringLiteral(ir.StringLiteral node) => node.value; 510 String visitStringLiteral(ir.StringLiteral node) => node.value;
482 511
483 @override 512 @override
484 String visitStringConcatenation(ir.StringConcatenation node) { 513 String visitStringConcatenation(ir.StringConcatenation node) {
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 } 871 }
843 if (isRedirecting) { 872 if (isRedirecting) {
844 return new RedirectingGenerativeConstantConstructor( 873 return new RedirectingGenerativeConstantConstructor(
845 defaultValues, superConstructorInvocation); 874 defaultValues, superConstructorInvocation);
846 } else { 875 } else {
847 return new GenerativeConstantConstructor( 876 return new GenerativeConstantConstructor(
848 type, defaultValues, fieldMap, superConstructorInvocation); 877 type, defaultValues, fieldMap, superConstructorInvocation);
849 } 878 }
850 } 879 }
851 } 880 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/no_such_method_resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698