Generate the state machine, and wire the closure to call it
[hiphop-php.git] / hphp / hack / src / parser / coroutine / coroutine_state_machine_generator.ml
blob7b4637c9d602af7552bafb8b609c807a1204c5dc
1 (**
2 * Copyright (c) 2016, Facebook, Inc.
3 * All rights reserved.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
8 *)
10 module CoroutineSyntax = Coroutine_syntax
11 module EditableSyntax = Full_fidelity_editable_syntax
13 open EditableSyntax
14 open CoroutineSyntax
16 let generate_coroutine_state_machine_body =
17 [ throw_unimplemented_syntax "Coroutines are not yet implemented." ]
19 (**
20 * If the provided methodish declaration is for a coroutine, rewrites the
21 * declaration header and the function body into a desugared coroutine
22 * implementation.
24 let generate_coroutine_state_machine
25 classish_name
26 function_name
27 { methodish_function_decl_header; _; }
28 { function_type; _; } =
29 make_methodish_declaration_syntax
30 (make_function_decl_header_syntax
31 (make_state_machine_method_name function_name)
33 make_closure_parameter_syntax classish_name function_name;
34 coroutine_data_parameter_syntax;
35 nullable_exception_parameter_syntax;
37 (make_coroutine_result_type_syntax function_type))
38 (generate_coroutine_state_machine_body)