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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 228293008: Redo "Construct literal maps using factory constructor." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add constructors to mock libraries for dart2js tests Created 6 years, 8 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 | sdk/lib/_internal/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
index 64d62e5ddb59080d42670c5b33adced238e82dfa..6f710bd5a95c34a5685b80a2388e79a1aedd3984 100644
--- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
@@ -102,6 +102,8 @@ class JavaScriptBackend extends Backend {
ClassElement mapLiteralClass;
ClassElement constMapLiteralClass;
ClassElement typeVariableClass;
+ Element mapLiteralConstructor;
+ Element mapLiteralConstructorEmpty;
ClassElement noSideEffectsClass;
ClassElement noThrowsClass;
@@ -728,7 +730,6 @@ class JavaScriptBackend extends Backend {
// For map literals, the dependency between the implementation class
// and [Map] is not visible, so we have to add it manually.
rti.registerRtiDependency(mapLiteralClass, cls);
- enqueueInResolution(getMapMaker(), elements);
} else if (cls == compiler.boundClosureClass) {
// TODO(ngeoffray): Move the bound closure class in the
// backend.
@@ -737,6 +738,27 @@ class JavaScriptBackend extends Backend {
enqueue(enqueuer, getNativeInterceptorMethod, elements);
enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies);
enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, elements);
+ } else if (cls == mapLiteralClass) {
+ // For map literals, the dependency between the implementation class
+ // and [Map] is not visible, so we have to add it manually.
+ Element getFactory(String name, int arity) {
+ // The constructor is on the patch class, but dart2js unit tests don't
+ // have a patch class.
+ ClassElement implementation = cls.patch != null ? cls.patch : cls;
+ return implementation.lookupConstructor(
+ new Selector.callConstructor(
+ name, mapLiteralClass.getLibrary(), arity),
+ (element) {
+ compiler.internalError(mapLiteralClass,
+ "Map literal class $mapLiteralClass missing "
+ "'$name' constructor"
+ " ${mapLiteralClass.constructors}");
+ });
+ }
+ mapLiteralConstructor = getFactory('_literal', 1);
+ mapLiteralConstructorEmpty = getFactory('_empty', 0);
+ enqueueInResolution(mapLiteralConstructor, elements);
+ enqueueInResolution(mapLiteralConstructorEmpty, elements);
}
}
if (cls == compiler.closureClass) {
@@ -1448,10 +1470,6 @@ class JavaScriptBackend extends Backend {
return compiler.findHelper('getTraceFromException');
}
- Element getMapMaker() {
- return compiler.findHelper('makeLiteralMap');
- }
-
Element getSetRuntimeTypeInfo() {
return compiler.findHelper('setRuntimeTypeInfo');
}
@@ -1886,4 +1904,3 @@ class Dependency {
const Dependency(this.constant, this.user);
}
-
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698