| library; |
| // |
| // Problems in library: |
| // |
| // pkg/front_end/testcases/statements.dart:15:5: Error: 'yield' can only be used in 'sync*' or 'async*' methods. |
| // yield x; |
| // ^^^^^ |
| // |
| // pkg/front_end/testcases/statements.dart:16:5: Error: 'yield' can only be used in 'sync*' or 'async*' methods. |
| // yield* x; |
| // ^^^^^ |
| // |
| import self as self; |
| import "dart:core" as core; |
| import "dart:async" as asy; |
| |
| static method foo() → dynamic { |
| try { |
| return; |
| } |
| finally { |
| core::print("Hello from finally block!"); |
| } |
| } |
| static method bar() → dynamic /* originally async */ { |
| final asy::_AsyncAwaitCompleter<dynamic> :async_completer = new asy::_AsyncAwaitCompleter::•<dynamic>(); |
| asy::FutureOr<dynamic> :return_value; |
| dynamic :async_stack_trace; |
| dynamic :async_op_then; |
| dynamic :async_op_error; |
| dynamic :await_jump_var = 0; |
| dynamic :await_ctx_var; |
| dynamic :saved_try_context_var0; |
| dynamic :saved_try_context_var1; |
| dynamic :exception0; |
| dynamic :stack_trace0; |
| function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding |
| try { |
| #L1: |
| { |
| { |
| dynamic :stream = <dynamic>[]; |
| asy::_asyncStarListenHelper(:stream, :async_op); |
| asy::_StreamIterator<dynamic> :for-iterator = new asy::_StreamIterator::•<dynamic>(:stream); |
| const core::bool :product-mode = const core::bool::fromEnvironment("dart.vm.product"); |
| try |
| #L2: |
| while (true) { |
| dynamic #t1 = :product-mode ?{dynamic} null : asy::_asyncStarMoveNextHelper(:stream); |
| [yield] let dynamic #t2 = asy::_awaitHelper(:for-iterator.{asy::_StreamIterator::moveNext}(), :async_op_then, :async_op_error, :async_op) in null; |
| if(:result) { |
| dynamic x = :for-iterator.{asy::_StreamIterator::current}; |
| { |
| yield x; |
| yield* x; |
| } |
| } |
| else |
| break #L2; |
| } |
| finally |
| if(!:for-iterator.{asy::_StreamIterator::_subscription}.{core::Object::==}(null)) { |
| [yield] let dynamic #t3 = asy::_awaitHelper(:for-iterator.{asy::_StreamIterator::cancel}(), :async_op_then, :async_op_error, :async_op) in null; |
| :result; |
| } |
| } |
| } |
| asy::_completeOnAsyncReturn(:async_completer, :return_value); |
| return; |
| } |
| on dynamic catch(dynamic :exception, dynamic :stack_trace) { |
| :async_completer.{asy::Completer::completeError}(:exception, :stack_trace); |
| } |
| :async_stack_trace = asy::_asyncStackTraceHelper(:async_op); |
| :async_op_then = asy::_asyncThenWrapperHelper(:async_op); |
| :async_op_error = asy::_asyncErrorWrapperHelper(:async_op); |
| :async_completer.start(:async_op); |
| return :async_completer.{asy::Completer::future}; |
| } |
| static method main() → dynamic { |
| do { |
| core::print("Hello from do-while!"); |
| } |
| while (false) |
| do { |
| dynamic x = core::print("Hello from do-while!"); |
| } |
| while (false) |
| for (core::String s in <dynamic>["Hello from for-in!"]) { |
| core::print(s); |
| } |
| for (core::String s in <dynamic>["Hello from for-in without block!"]) |
| core::print(s); |
| dynamic s; |
| for (final dynamic #t4 in <dynamic>["Hello from for-in without decl!"]) { |
| s = #t4; |
| core::print(s); |
| } |
| for (final dynamic #t5 in <dynamic>["Hello from for-in without decl and block!"]) { |
| s = #t5; |
| core::print(s); |
| } |
| core::print("Hello from labeled statement!"); |
| try { |
| try { |
| throw "Hello from rethrow!"; |
| } |
| on dynamic catch(final dynamic e) { |
| rethrow; |
| } |
| } |
| on dynamic catch(final dynamic e) { |
| core::print(e); |
| } |
| self::foo(); |
| core::bool done = false; |
| while (!done) { |
| done = true; |
| core::print("Hello from while!"); |
| } |
| ; |
| assert(true); |
| assert(true, "Hello from assert!"); |
| try { |
| assert(false, "Hello from assert!"); |
| } |
| on dynamic catch(final dynamic e) { |
| core::print(e); |
| } |
| #L3: |
| switch(1) { |
| #L4: |
| case #C1: |
| case #C2: |
| { |
| core::print("Hello from switch case!"); |
| break #L3; |
| } |
| #L5: |
| default: |
| { |
| break #L3; |
| } |
| } |
| #L6: |
| switch(4) { |
| #L7: |
| case #C2: |
| { |
| core::print("Hello from case 2!"); |
| break #L6; |
| } |
| #L8: |
| case #C1: |
| { |
| core::print("Hello from case 1!"); |
| continue #L7; |
| } |
| #L9: |
| case #C3: |
| { |
| core::print("Hello from case 0!"); |
| continue #L8; |
| } |
| #L10: |
| case #C4: |
| { |
| core::print("Hello from case 4!"); |
| continue #L11; |
| } |
| #L11: |
| default: |
| { |
| continue #L9; |
| } |
| } |
| #L12: |
| switch(4) { |
| #L13: |
| case #C1: |
| { |
| core::print("Hello from next case 1"); |
| break #L12; |
| } |
| #L14: |
| default: |
| { |
| continue #L13; |
| } |
| } |
| core::int i = 0; |
| #L15: |
| do |
| #L16: |
| { |
| core::print("Hello from do-while!"); |
| if((i = i.+(1)).<(3)) |
| break #L16; |
| break #L15; |
| } |
| while (true) |
| i = 0; |
| #L17: |
| while (true) |
| #L18: |
| { |
| core::print("Hello from while!"); |
| if((i = i.+(1)).<(3)) |
| break #L18; |
| break #L17; |
| } |
| } |