Skip to content

Commit 889e292

Browse files
authored
Merge pull request #138 from ocaml-wasm/unimplemented-primitives
Runtime: remove some unimplemented primitives
2 parents 1e2c57d + 13f8c2f commit 889e292

File tree

6 files changed

+22
-588
lines changed

6 files changed

+22
-588
lines changed

runtime/wasm/dynlink.wat

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,4 @@
1616
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717

1818
(module
19-
(import "jslib" "log_str" (func $log_str (param (ref $string))))
20-
21-
(type $string (array (mut i8)))
22-
23-
(data $caml_dynlink_close_lib "caml_dynlink_close_lib")
24-
25-
(func (export "caml_dynlink_close_lib")
26-
(param (ref eq)) (result (ref eq))
27-
;; ZZZ
28-
(call $log_str
29-
(array.new_data $string $caml_dynlink_close_lib
30-
(i32.const 0) (i32.const 22)))
31-
(ref.i31 (i32.const 0)))
32-
33-
(data $caml_dynlink_lookup_symbol "caml_dynlink_lookup_symbol")
34-
35-
(func (export "caml_dynlink_lookup_symbol")
36-
(param (ref eq)) (param (ref eq)) (result (ref eq))
37-
;; ZZZ
38-
(call $log_str
39-
(array.new_data $string $caml_dynlink_lookup_symbol
40-
(i32.const 0) (i32.const 26)))
41-
(ref.i31 (i32.const 0)))
4219
)

runtime/wasm/fs.wat

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
(func $readdir (param anyref) (result (ref extern))))
2626
(import "bindings" "file_exists"
2727
(func $file_exists (param anyref) (result (ref eq))))
28+
(import "bindings" "is_directory"
29+
(func $is_directory (param anyref) (result (ref eq))))
2830
(import "bindings" "rename" (func $rename (param anyref) (param anyref)))
2931
(import "jslib" "wrap" (func $wrap (param anyref) (result (ref eq))))
3032
(import "jslib" "unwrap" (func $unwrap (param (ref eq)) (result anyref)))
@@ -129,10 +131,6 @@
129131

130132
(func (export "caml_read_file_content")
131133
(param (ref eq)) (result (ref eq))
132-
;; ZZZ
133-
(call $log_str
134-
(array.new_data $string $caml_read_file_content
135-
(i32.const 0) (i32.const 22)))
136134
(call $caml_raise_no_such_file (local.get 0))
137135
(ref.i31 (i32.const 0)))
138136

@@ -141,10 +139,15 @@
141139

142140
(data $caml_sys_is_directory "caml_sys_is_directory")
143141

144-
(func (export "caml_sys_is_directory") (param (ref eq)) (result (ref eq))
145-
;; ZZZ
146-
(call $log_str
147-
(array.new_data $string $caml_sys_is_directory
148-
(i32.const 0) (i32.const 21)))
149-
(ref.i31 (i32.const 0)))
142+
(func (export "caml_sys_is_directory")
143+
(param $name (ref eq)) (result (ref eq))
144+
(try
145+
(do
146+
(return
147+
(call $is_directory
148+
(call $unwrap
149+
(call $caml_jsstring_of_string (local.get $name))))))
150+
(catch $javascript_exception
151+
(call $caml_handle_sys_error (pop externref))
152+
(return (ref.i31 (i32.const 0))))))
150153
)

runtime/wasm/int64.wat

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717

1818
(module
19-
(import "jslib" "log_str" (func $log_str (param (ref $string))))
2019
(import "ints" "parse_sign_and_base"
2120
(func $parse_sign_and_base
2221
(param (ref $string)) (result i32 i32 i32 i32)))
@@ -212,14 +211,6 @@
212211

213212
(data $caml_int64_create_lo_mi_hi "caml_int64_create_lo_mi_hi")
214213

215-
(func (export "caml_int64_create_lo_mi_hi")
216-
(param (ref eq) (ref eq) (ref eq)) (result (ref eq))
217-
;; ZZZ does not really make sense
218-
(call $log_str
219-
(array.new_data $string $caml_int64_create_lo_mi_hi
220-
(i32.const 0) (i32.const 26)))
221-
(ref.i31 (i32.const 0)))
222-
223214
(func $format_int64_default (param $d i64) (result (ref eq))
224215
(local $s (ref $string))
225216
(local $negative i32) (local $i i32) (local $n i64)

runtime/wasm/io.wat

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717

1818
(module
19-
(import "jslib" "log_str" (func $log_str (param (ref $string))))
2019
(import "fail" "caml_raise_end_of_file" (func $caml_raise_end_of_file))
2120
(import "jslib" "wrap" (func $wrap (param anyref) (result (ref eq))))
2221
(import "jslib" "unwrap" (func $unwrap (param (ref eq)) (result anyref)))
@@ -828,16 +827,6 @@
828827
(then (call $caml_flush (local.get $ch))))))
829828
(ref.i31 (i32.const 0)))
830829

831-
(data $caml_ml_set_channel_refill "caml_ml_set_channel_refill")
832-
833-
(func (export "caml_ml_set_channel_refill")
834-
(param (ref eq) (ref eq)) (result (ref eq))
835-
;; ZZZ
836-
(call $log_str
837-
(array.new_data $string $caml_ml_set_channel_refill
838-
(i32.const 0) (i32.const 26)))
839-
(ref.i31 (i32.const 0)))
840-
841830
(func (export "caml_ml_channel_size") (param (ref eq)) (result (ref eq))
842831
;; ZZZ check for overflow
843832
(ref.i31

0 commit comments

Comments
 (0)