Skip to content

Commit

Permalink
Reorganize moc.js endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanasa committed Oct 17, 2022
1 parent 9f1761b commit 7ca05ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/js/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ let js_run list source =
let list = Js.to_array list |> Array.to_list |> List.map Js.to_string in
ignore (Pipeline.run_stdin_from_file list (Js.to_string source))

let js_viper filenames =
let result = Pipeline.viper_files (filenames |> Array.to_list |> List.map Js.to_string) in
js_result result (fun s ->
Js.some (Js.string s)
)

let js_candid source =
js_result (Pipeline.generate_idl [Js.to_string source])
(fun prog ->
Expand Down Expand Up @@ -112,12 +118,6 @@ let js_parse_candid s =
Js.some (js_of_sexpr ast)
)

let js_viper filenames =
let parse_result = Pipeline.viper_files (filenames |> Array.to_list |> List.map Js.to_string) in
js_result parse_result (fun result ->
Js.some (Js.string result)
)

let js_save_file filename content =
let filename = Js.to_string filename in
let content = Js.to_string content in
Expand Down
2 changes: 1 addition & 1 deletion src/js/moc_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ let () =
method gcFlags option = gc_flags option
method run list s = Flags.compiled := false; wrap_output (fun _ -> js_run list s)
method check s = Flags.compiled := false; js_check s
method viper filenames = js_viper filenames
method candid s = Flags.compiled := true; js_candid s
method stableCompatible pre post = js_stable_compatible pre post
method compileWasm mode s = Flags.compiled := true; js_compile_wasm mode s
method parseMotoko s = js_parse_motoko s
method parseCandid s = js_parse_candid s
method viper s = js_viper s
end);

0 comments on commit 7ca05ce

Please sign in to comment.