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

Unified Diff: pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart

Issue 2643863005: Use entities in interceptor_stub_generator. (Closed)
Patch Set: Created 3 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 | « pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart ('k') | 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_emitter/interceptor_stub_generator.dart
diff --git a/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart
index 46f3b2cf1b8e6409ae36a424adfe1be8edfb14c2..7c3337eab9e49826aa64c6c16d57cf68b5daa65c 100644
--- a/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/interceptor_stub_generator.dart
@@ -6,8 +6,8 @@ library dart2js.js_emitter.interceptor_stub_generator;
import '../compiler.dart' show Compiler;
import '../constants/values.dart';
-import '../elements/resolution_types.dart' show ResolutionInterfaceType;
-import '../elements/elements.dart' show ClassElement, Element;
+import '../elements/entities.dart';
+import '../elements/types.dart' show InterfaceType;
import '../js/js.dart' as jsAst;
import '../js/js.dart' show js;
import '../js_backend/backend_helpers.dart' show BackendHelpers;
@@ -35,8 +35,8 @@ class InterceptorStubGenerator {
BackendHelpers get helpers => backend.helpers;
- jsAst.Expression generateGetInterceptorMethod(Set<ClassElement> classes) {
- jsAst.Expression interceptorFor(ClassElement cls) {
+ jsAst.Expression generateGetInterceptorMethod(Set<ClassEntity> classes) {
+ jsAst.Expression interceptorFor(ClassEntity cls) {
return backend.emitter.interceptorPrototypeAccess(cls);
}
@@ -44,7 +44,7 @@ class InterceptorStubGenerator {
* Build a JavaScrit AST node for doing a type check on
* [cls]. [cls] must be a non-native interceptor class.
*/
- jsAst.Statement buildInterceptorCheck(ClassElement cls) {
+ jsAst.Statement buildInterceptorCheck(ClassEntity cls) {
jsAst.Expression condition;
assert(backend.isInterceptorClass(cls));
if (cls == helpers.jsBoolClass) {
@@ -79,7 +79,7 @@ class InterceptorStubGenerator {
bool anyNativeClasses =
compiler.enqueuer.codegen.nativeEnqueuer.hasInstantiatedNativeClasses;
- for (ClassElement cls in classes) {
+ for (ClassEntity cls in classes) {
if (cls == helpers.jsArrayClass ||
cls == helpers.jsMutableArrayClass ||
cls == helpers.jsFixedArrayClass ||
@@ -186,7 +186,7 @@ class InterceptorStubGenerator {
.staticFunctionAccess(helpers.getNativeInterceptorMethod)
]));
} else {
- ClassElement jsUnknown = helpers.jsUnknownJavaScriptObjectClass;
+ ClassEntity jsUnknown = helpers.jsUnknownJavaScriptObjectClass;
if (compiler.codegenWorldBuilder.directlyInstantiatedClasses
.contains(jsUnknown)) {
statements.add(js.statement('if (!(receiver instanceof #)) return #;', [
@@ -206,7 +206,7 @@ class InterceptorStubGenerator {
// common case for a one-shot interceptor, or null if there is no
// fast path.
jsAst.Statement _fastPathForOneShotInterceptor(
- Selector selector, Set<ClassElement> classes) {
+ Selector selector, Set<ClassEntity> classes) {
if (selector.isOperator) {
String name = selector.name;
if (name == '==') {
@@ -338,7 +338,7 @@ class InterceptorStubGenerator {
jsAst.Expression generateOneShotInterceptor(jsAst.Name name) {
Selector selector = backend.oneShotInterceptors[name];
- Set<ClassElement> classes = backend.getInterceptedClassesOn(selector.name);
+ Set<ClassEntity> classes = backend.getInterceptedClassesOn(selector.name);
jsAst.Name getInterceptorName = namer.nameForGetInterceptor(classes);
List<String> parameterNames = <String>[];
@@ -380,40 +380,37 @@ class InterceptorStubGenerator {
handler.getConstantsForEmission(emitter.compareConstants);
for (ConstantValue constant in constants) {
if (constant is TypeConstantValue &&
- constant.representedType is ResolutionInterfaceType) {
- ResolutionInterfaceType type = constant.representedType;
- Element element = type.element;
- if (element is ClassElement) {
Siggi Cherem (dart-lang) 2017/01/19 16:48:22 Just to double-check, this `if` was practically in
Johnni Winther 2017/01/20 07:57:04 All [InterfaceType]s point to a [ClassEntity], if
- ClassElement classElement = element;
- if (!analysis.needsClass(classElement)) continue;
-
- elements.add(emitter.constantReference(constant));
- elements.add(backend.emitter.interceptorClassAccess(classElement));
-
- // Create JavaScript Object map for by-name lookup of generative
- // constructors. For example, the class A has three generative
- // constructors
- //
- // class A {
- // A() {}
- // A.foo() {}
- // A.bar() {}
- // }
- //
- // Which are described by the map
- //
- // {"": A.A$, "foo": A.A$foo, "bar": A.A$bar}
- //
- // We expect most of the time the map will be a singleton.
- var properties = [];
- for (Element member in analysis.constructors(classElement)) {
- properties.add(new jsAst.Property(js.string(member.name),
- backend.emitter.staticFunctionAccess(member)));
- }
+ constant.representedType is InterfaceType) {
+ InterfaceType type = constant.representedType;
+ ClassEntity classElement = type.element;
+ if (!analysis.needsClass(classElement)) continue;
+
+ elements.add(emitter.constantReference(constant));
+ elements.add(backend.emitter.interceptorClassAccess(classElement));
- var map = new jsAst.ObjectInitializer(properties);
- elements.add(map);
+ // Create JavaScript Object map for by-name lookup of generative
+ // constructors. For example, the class A has three generative
+ // constructors
+ //
+ // class A {
+ // A() {}
+ // A.foo() {}
+ // A.bar() {}
+ // }
+ //
+ // Which are described by the map
+ //
+ // {"": A.A$, "foo": A.A$foo, "bar": A.A$bar}
+ //
+ // We expect most of the time the map will be a singleton.
+ var properties = [];
+ for (FunctionEntity member in analysis.constructors(classElement)) {
+ properties.add(new jsAst.Property(js.string(member.name),
+ backend.emitter.staticFunctionAccess(member)));
}
+
+ var map = new jsAst.ObjectInitializer(properties);
+ elements.add(map);
}
}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/custom_elements_analysis.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698