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

Unified Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 873223002: dart2js: extract a native-blob handler and make it emitter-independent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename nativeBlob to nativeInfo. 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 | « pkg/compiler/lib/src/js_emitter/native_emitter.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/old_emitter/emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
index ec36db564174355120350633df4da145ced2d238..26da291ce9665084fc62a0bf22ab8f583c7fae2e 100644
--- a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart
@@ -450,10 +450,21 @@ class OldEmitter implements Emitter {
jsAst.Expression finishedClassesAccess =
generateEmbeddedGlobalAccess(embeddedNames.FINISHED_CLASSES);
+
+ jsAst.Expression nativeInfoAccess = js('prototype[$specProperty]', []);
+ jsAst.Expression constructorAccess = js('constructor', []);
+ Function subclassReadGenerator =
+ (jsAst.Expression subclass) => js('allClasses[#]', subclass);
jsAst.Expression interceptorsByTagAccess =
generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTORS_BY_TAG);
jsAst.Expression leafTagsAccess =
generateEmbeddedGlobalAccess(embeddedNames.LEAF_TAGS);
+ jsAst.Statement nativeInfoHandler = nativeEmitter.buildNativeInfoHandler(
+ nativeInfoAccess,
+ constructorAccess,
+ subclassReadGenerator,
+ interceptorsByTagAccess,
+ leafTagsAccess);
return js.statement('''
{
@@ -500,63 +511,14 @@ class OldEmitter implements Emitter {
var constructor = allClasses[cls];
var prototype = inheritFrom(constructor, superConstructor);
- if (#hasNativeClasses) {
- // The property looks like this:
- //
- // HtmlElement: {
- // "%": "HTMLDivElement|HTMLAnchorElement;HTMLElement;FancyButton"
- //
- // The first two semicolon-separated parts contain dispatch tags, the
- // third contains the JavaScript names for classes.
- //
- // The tags indicate that JavaScript objects with the dispatch tags
- // (usually constructor names) HTMLDivElement, HTMLAnchorElement and
- // HTMLElement all map to the Dart native class named HtmlElement.
- // The first set is for effective leaf nodes in the hierarchy, the
- // second set is non-leaf nodes.
- //
- // The third part contains the JavaScript names of Dart classes that
- // extend the native class. Here, FancyButton extends HtmlElement, so
- // the runtime needs to know that window.HTMLElement.prototype is the
- // prototype that needs to be extended in creating the custom element.
- //
- // The information is used to build tables referenced by
- // getNativeInterceptor and custom element support.
- if (Object.prototype.hasOwnProperty.call(prototype, $specProperty)) {
- var nativeSpec = prototype[$specProperty].split(";");
- if (nativeSpec[0]) {
- var tags = nativeSpec[0].split("|");
- for (var i = 0; i < tags.length; i++) {
- #interceptorsByTagAccess[tags[i]] = constructor;
- #leafTagsAccess[tags[i]] = true;
- }
- }
- if (nativeSpec[1]) {
- tags = nativeSpec[1].split("|");
- if (#allowNativesSubclassing) {
- if (nativeSpec[2]) {
- var subclasses = nativeSpec[2].split("|");
- for (var i = 0; i < subclasses.length; i++) {
- var subclass = allClasses[subclasses[i]];
- subclass.#nativeSuperclassTagName = tags[0];
- }
- }
- for (i = 0; i < tags.length; i++) {
- #interceptorsByTagAccess[tags[i]] = constructor;
- #leafTagsAccess[tags[i]] = false;
- }
- }
- }
- }
- }
+ if (#hasNativeClasses)
+ if (Object.prototype.hasOwnProperty.call(prototype, $specProperty))
+ #nativeInfoHandler
}
}''', {'finishedClassesAccess': finishedClassesAccess,
'needsMixinSupport': needsMixinSupport,
'hasNativeClasses': hasNativeClasses,
- 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME,
- 'interceptorsByTagAccess': interceptorsByTagAccess,
- 'leafTagsAccess': leafTagsAccess,
- 'allowNativesSubclassing': true});
+ 'nativeInfoHandler': nativeInfoHandler});
}
void emitFinishIsolateConstructorInvocation(CodeOutput output) {
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/native_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698