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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1253333002: dart2js cps: Support async/await by rewriting the JavaScript AST. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rewrite to switch. Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 buildBody: subbuild(node.body), 346 buildBody: subbuild(node.body),
347 target: elements.getTargetDefinition(node), 347 target: elements.getTargetDefinition(node),
348 closureScope: getClosureScopeForNode(node)); 348 closureScope: getClosureScopeForNode(node));
349 } 349 }
350 350
351 visitAsyncForIn(ast.AsyncForIn node) { 351 visitAsyncForIn(ast.AsyncForIn node) {
352 // await for is not yet implemented. 352 // await for is not yet implemented.
353 return giveup(node, 'await for'); 353 return giveup(node, 'await for');
354 } 354 }
355 355
356 visitAwait(ast.Await node) {
357 ir.Primitive value = visit(node.expression);
358 return irBuilder.buildAwait(value);
359 }
360
356 visitSyncForIn(ast.SyncForIn node) { 361 visitSyncForIn(ast.SyncForIn node) {
357 // [node.declaredIdentifier] can be either an [ast.VariableDefinitions] 362 // [node.declaredIdentifier] can be either an [ast.VariableDefinitions]
358 // (defining a new local variable) or a send designating some existing 363 // (defining a new local variable) or a send designating some existing
359 // variable. 364 // variable.
360 ast.Node identifier = node.declaredIdentifier; 365 ast.Node identifier = node.declaredIdentifier;
361 ast.VariableDefinitions variableDeclaration = 366 ast.VariableDefinitions variableDeclaration =
362 identifier.asVariableDefinitions(); 367 identifier.asVariableDefinitions();
363 Element variableElement = elements.getForInVariable(node); 368 Element variableElement = elements.getForInVariable(node);
364 Selector selector = elements.getSelector(identifier); 369 Selector selector = elements.getSelector(identifier);
365 370
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 tryNestingStack[i + 1].boxedOnEntry.add(local); 2176 tryNestingStack[i + 1].boxedOnEntry.add(local);
2172 } 2177 }
2173 } 2178 }
2174 } 2179 }
2175 node.visitChildren(this); 2180 node.visitChildren(this);
2176 } 2181 }
2177 2182
2178 visitFunctionExpression(ast.FunctionExpression node) { 2183 visitFunctionExpression(ast.FunctionExpression node) {
2179 FunctionElement oldFunction = currentFunction; 2184 FunctionElement oldFunction = currentFunction;
2180 currentFunction = elements[node]; 2185 currentFunction = elements[node];
2181 if (currentFunction.asyncMarker != AsyncMarker.SYNC) { 2186
2182 giveup(node, "cannot handle async/sync*/async* functions"); 2187 if (currentFunction.asyncMarker != AsyncMarker.SYNC &&
2188 currentFunction.asyncMarker != AsyncMarker.ASYNC) {
2189 giveup(node, "cannot handle sync*/async* functions");
2183 } 2190 }
2191
2184 if (node.initializers != null) { 2192 if (node.initializers != null) {
2185 insideInitializer = true; 2193 insideInitializer = true;
2186 visit(node.initializers); 2194 visit(node.initializers);
2187 insideInitializer = false; 2195 insideInitializer = false;
2188 } 2196 }
2189 visit(node.body); 2197 visit(node.body);
2190 currentFunction = oldFunction; 2198 currentFunction = oldFunction;
2191 } 2199 }
2192 2200
2193 visitTryStatement(ast.TryStatement node) { 2201 visitTryStatement(ast.TryStatement node) {
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3335 if (compiler.backend.isForeign(function)) { 3343 if (compiler.backend.isForeign(function)) {
3336 return handleForeignCode(node, function, argumentList, callStructure); 3344 return handleForeignCode(node, function, argumentList, callStructure);
3337 } else { 3345 } else {
3338 return irBuilder.buildStaticFunctionInvocation(function, callStructure, 3346 return irBuilder.buildStaticFunctionInvocation(function, callStructure,
3339 translateStaticArguments(argumentList, function, callStructure), 3347 translateStaticArguments(argumentList, function, callStructure),
3340 sourceInformation: 3348 sourceInformation:
3341 sourceInformationBuilder.buildCall(node, node.selector)); 3349 sourceInformationBuilder.buildCall(node, node.selector));
3342 } 3350 }
3343 } 3351 }
3344 } 3352 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698