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

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

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
Index: pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
diff --git a/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
index c727d56e4923f8f297660d8f8c6a5f92befd881e..447710dca781f2ef0320f282ad342a15fc5cd94f 100644
--- a/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
@@ -11,8 +11,8 @@ class ClassStubGenerator {
ClassStubGenerator(this.compiler, this.namer, this.backend);
- jsAst.Expression generateClassConstructor(ClassElement classElement,
- Iterable<jsAst.Name> fields) {
+ jsAst.Expression generateClassConstructor(
+ ClassElement classElement, Iterable<jsAst.Name> fields) {
// TODO(sra): Implement placeholders in VariableDeclaration position:
//
// String constructorName = namer.getNameOfClass(classElement);
@@ -20,10 +20,11 @@ class ClassStubGenerator {
// [ constructorName, fields,
// fields.map(
// (name) => js('this.# = #', [name, name]))]));
- return js('function(#) { #; this.#();}',
- [fields,
- fields.map((name) => js('this.# = #', [name, name])),
- namer.deferredAction]);
+ return js('function(#) { #; this.#();}', [
+ fields,
+ fields.map((name) => js('this.# = #', [name, name])),
+ namer.deferredAction
+ ]);
}
jsAst.Expression generateGetter(Element member, jsAst.Name fieldName) {
@@ -38,8 +39,8 @@ class ClassStubGenerator {
String receiver = backend.isInterceptorClass(cls) ? 'receiver' : 'this';
List<String> args = backend.isInterceptedMethod(member) ? ['receiver'] : [];
// TODO(floitsch): remove 'return'?
- return js('function(#, v) { return #.# = v; }',
- [args, receiver, fieldName]);
+ return js(
+ 'function(#, v) { return #.# = v; }', [args, receiver, fieldName]);
}
/**
@@ -54,8 +55,7 @@ class ClassStubGenerator {
// If the method is intercepted, the stub gets the
// receiver explicitely and we need to pass it to the getter call.
bool isInterceptedMethod = backend.isInterceptedMethod(member);
- bool isInterceptorClass =
- backend.isInterceptorClass(member.enclosingClass);
+ bool isInterceptorClass = backend.isInterceptorClass(member.enclosingClass);
const String receiverArgumentName = r'$receiver';
@@ -75,7 +75,7 @@ class ClassStubGenerator {
}
Map<jsAst.Name, jsAst.Expression> generatedStubs =
- <jsAst.Name, jsAst.Expression>{};
+ <jsAst.Name, jsAst.Expression>{};
// Two selectors may match but differ only in type. To avoid generating
// identical stubs for each we track untyped selectors which already have
@@ -103,9 +103,8 @@ class ClassStubGenerator {
arguments.add(js('#', name));
}
- jsAst.Fun function = js(
- 'function(#) { return #.#(#); }',
- [ parameters, buildGetter(), closureCallName, arguments]);
+ jsAst.Fun function = js('function(#) { return #.#(#); }',
+ [parameters, buildGetter(), closureCallName, arguments]);
generatedStubs[invocationName] = function;
}
@@ -115,7 +114,6 @@ class ClassStubGenerator {
}
Map<jsAst.Name, Selector> computeSelectorsForNsmHandlers() {
-
Map<jsAst.Name, Selector> jsNames = <jsAst.Name, Selector>{};
// Do not generate no such method handlers if there is no class.
@@ -123,8 +121,8 @@ class ClassStubGenerator {
return jsNames;
}
- void addNoSuchMethodHandlers(String ignore,
- Map<Selector, SelectorConstraints> selectors) {
+ void addNoSuchMethodHandlers(
+ String ignore, Map<Selector, SelectorConstraints> selectors) {
for (Selector selector in selectors.keys) {
SelectorConstraints maskSet = selectors[selector];
if (maskSet.needsNoSuchMethodHandling(selector, compiler.world)) {
@@ -140,47 +138,47 @@ class ClassStubGenerator {
return jsNames;
}
- StubMethod generateStubForNoSuchMethod(jsAst.Name name,
- Selector selector) {
+ StubMethod generateStubForNoSuchMethod(jsAst.Name name, Selector selector) {
// Values match JSInvocationMirror in js-helper library.
int type = selector.invocationMirrorKind;
List<String> parameterNames =
new List.generate(selector.argumentCount, (i) => '\$$i');
- List<jsAst.Expression> argNames =
- selector.callStructure.getOrderedNamedArguments().map((String name) =>
- js.string(name)).toList();
+ List<jsAst.Expression> argNames = selector.callStructure
+ .getOrderedNamedArguments()
+ .map((String name) => js.string(name))
+ .toList();
jsAst.Name methodName = namer.asName(selector.invocationMirrorMemberName);
jsAst.Name internalName = namer.invocationMirrorInternalName(selector);
assert(backend.isInterceptedName(Identifiers.noSuchMethod_));
bool isIntercepted = backend.isInterceptedName(selector.name);
- jsAst.Expression expression =
- js('''this.#noSuchMethodName(#receiver,
+ jsAst.Expression expression = js(
+ '''this.#noSuchMethodName(#receiver,
#createInvocationMirror(#methodName,
#internalName,
#type,
#arguments,
#namedArguments))''',
- {'receiver': isIntercepted ? r'$receiver' : 'this',
- 'noSuchMethodName': namer.noSuchMethodName,
- 'createInvocationMirror':
- backend.emitter.staticFunctionAccess(
- backend.helpers.createInvocationMirror),
- 'methodName':
- js.quoteName(compiler.options.enableMinification
- ? internalName : methodName),
- 'internalName': js.quoteName(internalName),
- 'type': js.number(type),
- 'arguments':
- new jsAst.ArrayInitializer(parameterNames.map(js).toList()),
- 'namedArguments': new jsAst.ArrayInitializer(argNames)});
+ {
+ 'receiver': isIntercepted ? r'$receiver' : 'this',
+ 'noSuchMethodName': namer.noSuchMethodName,
+ 'createInvocationMirror': backend.emitter
+ .staticFunctionAccess(backend.helpers.createInvocationMirror),
+ 'methodName': js.quoteName(
+ compiler.options.enableMinification ? internalName : methodName),
+ 'internalName': js.quoteName(internalName),
+ 'type': js.number(type),
+ 'arguments':
+ new jsAst.ArrayInitializer(parameterNames.map(js).toList()),
+ 'namedArguments': new jsAst.ArrayInitializer(argNames)
+ });
jsAst.Expression function;
if (isIntercepted) {
- function = js(r'function($receiver, #) { return # }',
- [parameterNames, expression]);
+ function = js(
+ r'function($receiver, #) { return # }', [parameterNames, expression]);
} else {
function = js(r'function(#) { return # }', [parameterNames, expression]);
}
@@ -219,8 +217,8 @@ List<jsAst.Statement> buildTearOffCode(JavaScriptBackend backend) {
js.string(namer.globalObjectFor(closureFromTearOff));
} else {
// Default values for mocked-up test libraries.
- tearOffAccessExpression = js(
- r'''function() { throw "Helper 'closureFromTearOff' missing." }''');
+ tearOffAccessExpression =
+ js(r'''function() { throw "Helper 'closureFromTearOff' missing." }''');
tearOffGlobalObjectString = js.string('MissingHelperFunction');
tearOffGlobalObject = js(
r'''(function() { throw "Helper 'closureFromTearOff' missing." })()''');
@@ -230,7 +228,8 @@ List<jsAst.Statement> buildTearOffCode(JavaScriptBackend backend) {
if (!compiler.options.useContentSecurityPolicy) {
jsAst.Expression tearOffAccessText =
new jsAst.UnparsedNode(tearOffAccessExpression, compiler, false);
- tearOffGetter = js.statement('''
+ tearOffGetter = js.statement(
+ '''
function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
return isIntercepted
? new Function("funcs", "reflectionInfo", "name",
@@ -247,11 +246,15 @@ function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
"this, funcs, reflectionInfo, false, [], name);" +
"return new c(this, funcs[0], null, name);" +
"}")(funcs, reflectionInfo, name, #tearOffGlobalObject, null);
-}''', {'tearOffAccessText': tearOffAccessText,
- 'tearOffGlobalObject': tearOffGlobalObject,
- 'tearOffGlobalObjectString': tearOffGlobalObjectString});
+}''',
+ {
+ 'tearOffAccessText': tearOffAccessText,
+ 'tearOffGlobalObject': tearOffGlobalObject,
+ 'tearOffGlobalObjectString': tearOffGlobalObjectString
+ });
} else {
- tearOffGetter = js.statement('''
+ tearOffGetter = js.statement(
+ '''
function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
var cache = null;
return isIntercepted
@@ -265,10 +268,12 @@ function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
this, funcs, reflectionInfo, false, [], name);
return new cache(this, funcs[0], null, name);
};
- }''', [tearOffAccessExpression, tearOffAccessExpression]);
+ }''',
+ [tearOffAccessExpression, tearOffAccessExpression]);
}
- jsAst.Statement tearOff = js.statement('''
+ jsAst.Statement tearOff = js.statement(
+ '''
function tearOff(funcs, reflectionInfo, isStatic, name, isIntercepted) {
var cache;
return isStatic
@@ -278,7 +283,8 @@ function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
return cache;
}
: tearOffGetter(funcs, reflectionInfo, name, isIntercepted);
- }''', {'tearOff': tearOffAccessExpression});
+ }''',
+ {'tearOff': tearOffAccessExpression});
return <jsAst.Statement>[tearOffGetter, tearOff];
}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/type_variable_handler.dart ('k') | pkg/compiler/lib/src/js_emitter/code_emitter_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698