Index: pkg/compiler/lib/src/ssa/codegen.dart |
diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart |
index 0d4b38911d9bf6777dc1306ee7759f5b0aa1d29d..8cb8b3a656c38327c0a2af5a2b4febd1931ff95d 100644 |
--- a/pkg/compiler/lib/src/ssa/codegen.dart |
+++ b/pkg/compiler/lib/src/ssa/codegen.dart |
@@ -52,7 +52,16 @@ class SsaCodeGeneratorTask extends CompilerTask { |
js.Fun buildJavaScriptFunction(FunctionElement element, |
List<js.Parameter> parameters, |
js.Block body) { |
- return attachPosition(new js.Fun(parameters, body), element); |
+ js.AsyncModifier asyncModifier = element.asyncMarker.isAsync |
+ ? (element.asyncMarker.isYielding |
+ ? const js.AsyncModifier.asyncStar() |
+ : const js.AsyncModifier.async()) |
+ : (element.asyncMarker.isYielding |
+ ? const js.AsyncModifier.syncStar() |
+ : const js.AsyncModifier.sync()); |
+ |
+ return attachPosition( |
+ new js.Fun(parameters, body, asyncModifier: asyncModifier), element); |
} |
js.Expression generateCode(CodegenWorkItem work, HGraph graph) { |
@@ -75,10 +84,14 @@ class SsaCodeGeneratorTask extends CompilerTask { |
js.Expression generateMethod(CodegenWorkItem work, HGraph graph) { |
return measure(() { |
+ Element element = work.element; |
+ if (element is FunctionElement && |
+ element.asyncMarker != AsyncMarker.SYNC) { |
+ work.registry.registerAsyncMarker(element); |
+ } |
SsaCodeGenerator codegen = new SsaCodeGenerator(backend, work); |
codegen.visitGraph(graph); |
compiler.tracer.traceGraph("codegen", graph); |
- FunctionElement element = work.element; |
return buildJavaScriptFunction(element, codegen.parameters, codegen.body); |
}); |
} |
@@ -1969,6 +1982,16 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
} |
} |
+ visitAwait(HAwait node) { |
+ use(node.inputs[0]); |
+ push(new js.Await(pop()), node); |
+ } |
+ |
+ visitYield(HYield node) { |
+ use(node.inputs[0]); |
+ pushStatement(new js.Yield(pop(), node.hasStar), node); |
+ } |
+ |
visitRangeConversion(HRangeConversion node) { |
// Range conversion instructions are removed by the value range |
// analyzer. |
@@ -2047,7 +2070,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
if (helperName == 'wrapException') { |
pushStatement(new js.Throw(value)); |
} else { |
- pushStatement(new js.Return(value)); |
+ pushStatement(new js.ExpressionStatement(value)); |
floitsch
2015/02/02 22:00:11
I'm not sure I agree with this.
There is a reason
sigurdm
2015/02/03 16:59:32
Right - we need another solution. Return in a sync
sigurdm
2015/02/04 09:40:42
I will omit the return only when in an async* or s
|
} |
} |