Skip to content

Commit

Permalink
Attempted workaround for links-lang#1136 (links-lang#1138)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescheney authored and Orbion-J committed Jun 30, 2022
1 parent d534c5a commit 948e38e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions core/webif.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,23 @@ struct
have to do something about it in order for attempts to remotely
call primitive functions to work properly. *)

let func =
match fvs with
| `Record [] -> let i_fname = int_of_string fname in
if Lib.is_primitive_var i_fname
then `PrimitiveFunction (Lib.primitive_name i_fname, Some i_fname)
else `FunctionPtr (int_of_string fname, None)
| _ -> `FunctionPtr (int_of_string fname, Some fvs)
let i_fname = int_of_string fname in
let func,args =
match Lib.is_primitive_var i_fname, fvs with
| true, `Record [] -> `PrimitiveFunction (Lib.primitive_name i_fname, Some i_fname), args
| false, `Record [] ->
(* Should ideally handle failure to find function gracefully here. *)
let (_finfo, (_xs, _body), z, _location) =
Tables.find Tables.fun_defs i_fname in
(* This is a workaround for the fact that client-side code passes
the environment back as an ordinary (first) argument, while
the environment is expected as the second argument to the
FunctionPtr constructor. *)
begin match z with
None -> `FunctionPtr (i_fname, None), args
| Some _ -> `FunctionPtr (i_fname, Some (List.hd args)), List.tl args
end
| _ -> `FunctionPtr (i_fname, Some fvs), args
in
RemoteCall (func, valenv, args)

Expand Down

0 comments on commit 948e38e

Please sign in to comment.