Skip to content

Commit

Permalink
Reformat untouched files.
Browse files Browse the repository at this point in the history
R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2990223002 .
  • Loading branch information
johnniwinther committed Aug 4, 2017
1 parent aaf67e5 commit 5fe6282
Show file tree
Hide file tree
Showing 42 changed files with 1,693 additions and 2,604 deletions.
10 changes: 4 additions & 6 deletions pkg/compiler/lib/src/diagnostics/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2102,9 +2102,8 @@ part of lib.foo;
"both '#{canonicalUri1}' and '#{canonicalUri2}'."),

// This is used as an exception.
MessageKind.INVALID_SOURCE_FILE_LOCATION: const MessageTemplate(
MessageKind.INVALID_SOURCE_FILE_LOCATION,
'''
MessageKind.INVALID_SOURCE_FILE_LOCATION:
const MessageTemplate(MessageKind.INVALID_SOURCE_FILE_LOCATION, '''
Invalid offset (#{offset}) in source map.
File: #{fileName}
Length: #{length}'''),
Expand Down Expand Up @@ -3207,9 +3206,8 @@ main() => new A();
MessageKind.COMPILER_CRASHED,
"The compiler crashed when compiling this element."),

MessageKind.PLEASE_REPORT_THE_CRASH: const MessageTemplate(
MessageKind.PLEASE_REPORT_THE_CRASH,
'''
MessageKind.PLEASE_REPORT_THE_CRASH:
const MessageTemplate(MessageKind.PLEASE_REPORT_THE_CRASH, '''
The compiler is broken.
When compiling the above element, the compiler crashed. It is not
Expand Down
167 changes: 77 additions & 90 deletions pkg/compiler/lib/src/js/rewrite_async.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1767,16 +1767,14 @@ class AsyncRewriter extends AsyncRewriterBase {

@override
js.Statement awaitStatement(js.Expression value) {
return js.js.statement(
"""
return js.js.statement("""
return #asyncHelper(#value,
#bodyName);
""",
{
"asyncHelper": asyncAwait,
"value": value,
"bodyName": bodyName,
});
""", {
"asyncHelper": asyncAwait,
"value": value,
"bodyName": bodyName,
});
}

@override
Expand All @@ -1785,8 +1783,7 @@ class AsyncRewriter extends AsyncRewriterBase {
js.Statement rewrittenBody,
js.VariableDeclarationList variableDeclarations,
SourceInformation sourceInformation) {
return js.js(
"""
return js.js("""
function (#parameters) {
#variableDeclarations;
var #bodyName = #wrapBody(function (#errorCode, #result) {
Expand All @@ -1800,24 +1797,23 @@ class AsyncRewriter extends AsyncRewriterBase {
#rewrittenBody;
});
return #asyncStart(#bodyName, #completer);
}""",
{
"parameters": parameters,
"variableDeclarations": variableDeclarations,
"ERROR": js.number(error_codes.ERROR),
"rewrittenBody": rewrittenBody,
"bodyName": bodyName,
"currentError": currentError,
"goto": goto,
"handler": handler,
"errorCode": errorCodeName,
"result": resultName,
"asyncStart": asyncStart,
"asyncRethrow": asyncRethrow,
"hasHandlerLabels": hasHandlerLabels,
"completer": completer,
"wrapBody": wrapBody,
}).withSourceInformation(sourceInformation);
}""", {
"parameters": parameters,
"variableDeclarations": variableDeclarations,
"ERROR": js.number(error_codes.ERROR),
"rewrittenBody": rewrittenBody,
"bodyName": bodyName,
"currentError": currentError,
"goto": goto,
"handler": handler,
"errorCode": errorCodeName,
"result": resultName,
"asyncStart": asyncStart,
"asyncRethrow": asyncRethrow,
"hasHandlerLabels": hasHandlerLabels,
"completer": completer,
"wrapBody": wrapBody,
}).withSourceInformation(sourceInformation);
}
}

Expand Down Expand Up @@ -1886,8 +1882,7 @@ class SyncStarRewriter extends AsyncRewriterBase {
}
js.VariableDeclarationList copyParameters =
new js.VariableDeclarationList(declarations);
return js.js(
"""
return js.js("""
function (#renamedParameters) {
if (#needsThis)
var #self = this;
Expand All @@ -1905,24 +1900,23 @@ class SyncStarRewriter extends AsyncRewriterBase {
};
});
}
""",
{
"renamedParameters": renamedParameters,
"needsThis": analysis.hasThis,
"helperBody": rewrittenBody,
"hasParameters": parameters.isNotEmpty,
"copyParameters": copyParameters,
"varDecl": variableDeclarations,
"errorCode": errorCodeName,
"iterableFactory": iterableFactory,
"body": bodyName,
"self": selfName,
"result": resultName,
"goto": goto,
"handler": handler,
"currentError": currentErrorName,
"ERROR": js.number(error_codes.ERROR),
}).withSourceInformation(sourceInformation);
""", {
"renamedParameters": renamedParameters,
"needsThis": analysis.hasThis,
"helperBody": rewrittenBody,
"hasParameters": parameters.isNotEmpty,
"copyParameters": copyParameters,
"varDecl": variableDeclarations,
"errorCode": errorCodeName,
"iterableFactory": iterableFactory,
"body": bodyName,
"self": selfName,
"result": resultName,
"goto": goto,
"handler": handler,
"currentError": currentErrorName,
"ERROR": js.number(error_codes.ERROR),
}).withSourceInformation(sourceInformation);
}

void addErrorExit() {
Expand Down Expand Up @@ -2043,18 +2037,15 @@ class AsyncStarRewriter extends AsyncRewriterBase {
nextWhenCanceled,
new js.ArrayInitializer(enclosingFinallyLabels.map(js.number).toList())
]));
addStatement(js.js.statement(
"""
addStatement(js.js.statement("""
return #asyncStarHelper(#yieldExpression(#expression), #bodyName,
#controller);""",
{
"asyncStarHelper": asyncStarHelper,
"yieldExpression":
node.hasStar ? yieldStarExpression : yieldExpression,
"expression": expression,
"bodyName": bodyName,
"controller": controllerName,
}));
#controller);""", {
"asyncStarHelper": asyncStarHelper,
"yieldExpression": node.hasStar ? yieldStarExpression : yieldExpression,
"expression": expression,
"bodyName": bodyName,
"controller": controllerName,
}));
}

@override
Expand All @@ -2063,8 +2054,7 @@ class AsyncStarRewriter extends AsyncRewriterBase {
js.Statement rewrittenBody,
js.VariableDeclarationList variableDeclarations,
SourceInformation sourceInformation) {
return js.js(
"""
return js.js("""
function (#parameters) {
var #bodyName = #wrapBody(function (#errorCode, #result) {
if (#hasYield) {
Expand All @@ -2087,26 +2077,25 @@ class AsyncStarRewriter extends AsyncRewriterBase {
});
#variableDeclarations;
return #streamOfController(#controller);
}""",
{
"parameters": parameters,
"variableDeclarations": variableDeclarations,
"STREAM_WAS_CANCELED": js.number(error_codes.STREAM_WAS_CANCELED),
"ERROR": js.number(error_codes.ERROR),
"hasYield": analysis.hasYield,
"rewrittenBody": rewrittenBody,
"bodyName": bodyName,
"currentError": currentError,
"goto": goto,
"handler": handler,
"next": next,
"nextWhenCanceled": nextWhenCanceled,
"errorCode": errorCodeName,
"result": resultName,
"streamOfController": streamOfController,
"controller": controllerName,
"wrapBody": wrapBody,
}).withSourceInformation(sourceInformation);
}""", {
"parameters": parameters,
"variableDeclarations": variableDeclarations,
"STREAM_WAS_CANCELED": js.number(error_codes.STREAM_WAS_CANCELED),
"ERROR": js.number(error_codes.ERROR),
"hasYield": analysis.hasYield,
"rewrittenBody": rewrittenBody,
"bodyName": bodyName,
"currentError": currentError,
"goto": goto,
"handler": handler,
"next": next,
"nextWhenCanceled": nextWhenCanceled,
"errorCode": errorCodeName,
"result": resultName,
"streamOfController": streamOfController,
"controller": controllerName,
"wrapBody": wrapBody,
}).withSourceInformation(sourceInformation);
}

@override
Expand Down Expand Up @@ -2155,18 +2144,16 @@ class AsyncStarRewriter extends AsyncRewriterBase {

@override
js.Statement awaitStatement(js.Expression value) {
return js.js.statement(
"""
return js.js.statement("""
return #asyncHelper(#value,
#bodyName,
#controller);
""",
{
"asyncHelper": asyncStarHelper,
"value": value,
"bodyName": bodyName,
"controller": controllerName
});
""", {
"asyncHelper": asyncStarHelper,
"value": value,
"bodyName": bodyName,
"controller": controllerName
});
}
}

Expand Down
55 changes: 23 additions & 32 deletions pkg/compiler/lib/src/js_emitter/class_stub_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,26 +189,23 @@ class ClassStubGenerator {

assert(_interceptorData.isInterceptedName(Identifiers.noSuchMethod_));
bool isIntercepted = _interceptorData.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': _emitter
.staticFunctionAccess(_commonElements.createInvocationMirror),
'methodName':
js.quoteName(enableMinification ? internalName : methodName),
'internalName': js.quoteName(internalName),
'type': js.number(type),
'arguments':
new jsAst.ArrayInitializer(parameterNames.map(js).toList()),
'namedArguments': new jsAst.ArrayInitializer(argNames)
});
#namedArguments))''', {
'receiver': isIntercepted ? r'$receiver' : 'this',
'noSuchMethodName': _namer.noSuchMethodName,
'createInvocationMirror':
_emitter.staticFunctionAccess(_commonElements.createInvocationMirror),
'methodName':
js.quoteName(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) {
Expand Down Expand Up @@ -260,8 +257,7 @@ List<jsAst.Statement> buildTearOffCode(CompilerOptions options, Emitter emitter,
if (!options.useContentSecurityPolicy) {
jsAst.Expression tearOffAccessText =
new jsAst.UnparsedNode(tearOffAccessExpression, options, false);
tearOffGetter = js.statement(
'''
tearOffGetter = js.statement('''
function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
return isIntercepted
? new Function("funcs", "reflectionInfo", "name",
Expand All @@ -278,15 +274,13 @@ 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
Expand All @@ -300,12 +294,10 @@ 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
Expand All @@ -315,8 +307,7 @@ function tearOffGetter(funcs, reflectionInfo, name, isIntercepted) {
return cache;
}
: tearOffGetter(funcs, reflectionInfo, name, isIntercepted);
}''',
{'tearOff': tearOffAccessExpression});
}''', {'tearOff': tearOffAccessExpression});

return <jsAst.Statement>[tearOffGetter, tearOff];
}
Loading

0 comments on commit 5fe6282

Please sign in to comment.