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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_emitter/nsm_emitter.dart

Issue 202903006: Make deferred loading work with noSuchMethod. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | tests/language/deferred_no_such_method_lib.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_emitter/nsm_emitter.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/nsm_emitter.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/nsm_emitter.dart
index 29630bb30a3b92f87fe4ebf49bec1b6ed486e634..c298c5709861b6693c6e4c76b2c19688b2435630 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/nsm_emitter.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/nsm_emitter.dart
@@ -281,33 +281,37 @@ class NsmEmitter extends CodeEmitterHelper {
' nameNumber = 0,'
' diffEncodedString = shortNames[0],'
' calculatedShortNames = [0, 1]'), // 0, 1 are args for splice.
- js.if_('objectClassObject instanceof Array',
- js('objectClassObject = objectClassObject[1]')),
- js.for_('var i = 0', 'i < diffEncodedString.length', 'i++', [
- js('var codes = [],'
- ' diff = 0,'
- ' digit = diffEncodedString.charCodeAt(i)'),
- js.if_('digit == ${$PERIOD}', [
- js('nameNumber = 0'),
- js('digit = diffEncodedString.charCodeAt(++i)')
- ]),
- js.while_('digit <= ${$Z}', [
+ // If we are loading a deferred library the object class will not be in
+ // the collectedClasses so objectClassObject is undefined, and we skip
+ // setting up the names.
+ js.if_('objectClassObject', [
+ js.if_('objectClassObject instanceof Array',
+ js('objectClassObject = objectClassObject[1]')),
+ js.for_('var i = 0', 'i < diffEncodedString.length', 'i++', [
+ js('var codes = [],'
+ ' diff = 0,'
+ ' digit = diffEncodedString.charCodeAt(i)'),
+ js.if_('digit == ${$PERIOD}', [
+ js('nameNumber = 0'),
+ js('digit = diffEncodedString.charCodeAt(++i)')
+ ]),
+ js.while_('digit <= ${$Z}', [
+ js('diff *= 26'),
+ js('diff += (digit - ${$A})'),
+ js('digit = diffEncodedString.charCodeAt(++i)')
+ ]),
js('diff *= 26'),
- js('diff += (digit - ${$A})'),
- js('digit = diffEncodedString.charCodeAt(++i)')
- ]),
- js('diff *= 26'),
- js('diff += (digit - ${$a})'),
- js('nameNumber += diff'),
- js.for_('var remaining = nameNumber',
- 'remaining > 0',
- 'remaining = (remaining / 88) | 0', [
- js('codes.unshift(${$HASH} + remaining % 88)')
+ js('diff += (digit - ${$a})'),
+ js('nameNumber += diff'),
+ js.for_('var remaining = nameNumber',
+ 'remaining > 0',
+ 'remaining = (remaining / 88) | 0', [
+ js('codes.unshift(${$HASH} + remaining % 88)')
+ ]),
+ js('calculatedShortNames.push('
+ ' String.fromCharCode.apply(String, codes))')
]),
- js('calculatedShortNames.push('
- ' String.fromCharCode.apply(String, codes))')
- ]),
- js('shortNames.splice.apply(shortNames, calculatedShortNames)')
+ js('shortNames.splice.apply(shortNames, calculatedShortNames)')])
]);
} else {
// No useDiffEncoding version.
@@ -341,23 +345,28 @@ class NsmEmitter extends CodeEmitterHelper {
params.add('sliceOffset');
}
statements.addAll([
- js.for_('var j = 0', 'j < shortNames.length', 'j++', [
- js('var type = 0'),
- js('var short = shortNames[j]'),
- js.if_('short[0] == "${namer.getterPrefix[0]}"', js('type = 1')),
- js.if_('short[0] == "${namer.setterPrefix[0]}"', js('type = 2')),
- // Generate call to:
- // createInvocationMirror(String name, internalName, type, arguments,
- // argumentNames)
- js('$whatToPatch[short] = #(${minify ? "shortNames" : "longNames"}[j], '
- 'short, type$sliceOffset)',
- js.fun(params, [js.return_(js.fun([],
- [js.return_(js(
- 'this.$noSuchMethodName('
- 'this, '
- '$createInvocationMirror('
- 'name, short, type, '
- '$slice(arguments$sliceOffsetParam), []))'))]))]))
+ // If we are loading a deferred library the object class will not be in
+ // the collectedClasses so objectClassObject is undefined, and we skip
+ // setting up the names.
+ js.if_('objectClassObject', [
+ js.for_('var j = 0', 'j < shortNames.length', 'j++', [
+ js('var type = 0'),
+ js('var short = shortNames[j]'),
+ js.if_('short[0] == "${namer.getterPrefix[0]}"', js('type = 1')),
+ js.if_('short[0] == "${namer.setterPrefix[0]}"', js('type = 2')),
+ // Generate call to:
+ // createInvocationMirror(String name, internalName, type, arguments,
+ // argumentNames)
+ js('$whatToPatch[short] = #(${minify ? "shortNames" : "longNames"}[j], '
+ 'short, type$sliceOffset)',
+ js.fun(params, [js.return_(js.fun([],
+ [js.return_(js(
+ 'this.$noSuchMethodName('
+ 'this, '
+ '$createInvocationMirror('
+ 'name, short, type, '
+ '$slice(arguments$sliceOffsetParam), []))'))]))]))
+ ])
])
]);
}
« no previous file with comments | « no previous file | tests/language/deferred_no_such_method_lib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698