|
| 1 | +(* Js_of_ocaml library |
| 2 | + * http://www.ocsigen.org/js_of_ocaml/ |
| 3 | + * Copyright (C) 2016 OCamlPro |
| 4 | + * |
| 5 | + * This program is free software; you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Library General Public License as published by |
| 7 | + * the Free Software Foundation, with linking exception; |
| 8 | + * either version 2.1 of the License, or (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU Library General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Library General Public License |
| 16 | + * along with this program; if not, write to the Free Software |
| 17 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | + *) |
| 19 | + |
| 20 | +module type Wrapped = sig |
| 21 | + type toplevel |
| 22 | + |
| 23 | + type 'a result |
| 24 | + |
| 25 | + type output |
| 26 | + |
| 27 | + val check : toplevel -> ?setenv:bool -> string -> unit result |
| 28 | + (** Parse and typecheck a given source code |
| 29 | +
|
| 30 | + @param setenv should the resulting environment replace the current |
| 31 | + environment ? |
| 32 | +
|
| 33 | + @return [Success ()] in case of success and [Error err] |
| 34 | + where [err] contains the error message otherwise. |
| 35 | +
|
| 36 | + *) |
| 37 | + |
| 38 | + val execute : |
| 39 | + toplevel |
| 40 | + -> ?ppf_code:output |
| 41 | + -> ?print_outcome:bool |
| 42 | + -> ppf_answer:output |
| 43 | + -> string |
| 44 | + -> bool result |
| 45 | + (** Execute a given source code. The evaluation stops after the first |
| 46 | + toplevel phrase (as terminated by ";;") that fails to compile or |
| 47 | + for which the evaluation raises an uncaught exception. |
| 48 | +
|
| 49 | + @param ppf_code a formatter were the source code will be printed |
| 50 | + before its execution. The printing might be interleaved |
| 51 | + with call to "pp_answer" when a line finishes by ";;". |
| 52 | +
|
| 53 | + @param ppf_answer a formatter were the compiler outputs will be |
| 54 | + printed. |
| 55 | +
|
| 56 | + @param print_outcome should the toplevel print the computed |
| 57 | + values and their types ? |
| 58 | +
|
| 59 | + @return [Error err] when parsing or typechecking failed, where |
| 60 | + [err] contains the error message. It returns [Success true] |
| 61 | + when the code evaluation finished without uncaught |
| 62 | + exception, and [Success false] otherwise. |
| 63 | + *) |
| 64 | + |
| 65 | + val use_string : |
| 66 | + toplevel |
| 67 | + -> ?filename:string |
| 68 | + -> ?print_outcome:bool |
| 69 | + -> ppf_answer:output |
| 70 | + -> string |
| 71 | + -> bool result |
| 72 | + (** Execute a given source code. The code is parsed and |
| 73 | + typechecked all at once before to start the evalution. |
| 74 | +
|
| 75 | + @param filename a faked filename which will be used in error messages |
| 76 | +
|
| 77 | + @param ppf_answer see {!val:execute}. |
| 78 | +
|
| 79 | + @param print_outcome see {!val:execute}. |
| 80 | +
|
| 81 | + @return as {!val:execute}. |
| 82 | +
|
| 83 | + *) |
| 84 | + |
| 85 | + val use_mod_string : |
| 86 | + toplevel |
| 87 | + -> ?print_outcome:bool |
| 88 | + -> ppf_answer:output |
| 89 | + -> modname:string |
| 90 | + -> ?sig_code:string |
| 91 | + -> string |
| 92 | + -> bool result |
| 93 | + (** Wrap a given source code into a module and bind it with a given name. |
| 94 | +
|
| 95 | + @param print_outcome see {!val:execute}. |
| 96 | +
|
| 97 | + @param ppf_answer see {!val:execute}. |
| 98 | +
|
| 99 | + @param modname the module name, it must start with a capital |
| 100 | + character. |
| 101 | +
|
| 102 | + @param sig_code source code for the module signature. |
| 103 | +
|
| 104 | + @return as {!val:execute}. |
| 105 | +
|
| 106 | + *) |
| 107 | +end |
0 commit comments