Skip to content

Commit

Permalink
expose print_char in C
Browse files Browse the repository at this point in the history
  • Loading branch information
zapashcanon committed Mar 3, 2025
1 parent ab65cee commit c9858a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/libc/include/owi.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ __attribute__((import_module("symbolic"), import_name("f32_symbol"))) float
owi_f32(void);
__attribute__((import_module("symbolic"), import_name("f64_symbol"))) double
owi_f64(void);
__attribute__((import_module("symbolic"), import_name("print_char"))) void
owi_print_char(int);
__attribute__((import_module("symbolic"), import_name("bool_symbol")))
#ifdef __cplusplus
bool
Expand Down
7 changes: 6 additions & 1 deletion src/symbolic/symbolic_wasm_ffi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ module M :

let in_replay_mode () = Choice.return @@ Smtml.Expr.value (Smtml.Value.Int 0)

let print_char (_c : Value.int32) = assert false
let print_char (c : Value.int32) =
match Smtml.Expr.view c with
| Val (Num (I32 c)) ->
Fmt.pr "%c@?" (char_of_int (Int32.to_int c));
Choice.return ()
| _ -> assert false
end

type extern_func = Symbolic.Extern_func.extern_func
Expand Down

0 comments on commit c9858a3

Please sign in to comment.