File tree Expand file tree Collapse file tree 7 files changed +25
-9
lines changed Expand file tree Collapse file tree 7 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ local: ( local <type>* ) | ( local <name> <type> )
132
132
module: ( module <type>* <func>* <import>* <export>* <table>* <memory>? <start>? )
133
133
type: ( type <name>? ( func <param>* <result>? ) )
134
134
import: ( import <name>? "<module_name>" "<func_name>" (param <type>* ) (result <type>)* )
135
- export: ( export "<char>*" <var> )
135
+ export: ( export "<char>*" <var> ) | ( export "<char>*" memory)
136
136
start: ( start <var> )
137
137
table: ( table <var>* )
138
138
memory: ( memory <int> <int>? <segment>* )
Original file line number Diff line number Diff line change @@ -394,7 +394,9 @@ import :
394
394
395
395
export :
396
396
| LPAR EXPORT TEXT var RPAR
397
- { let at = at () in fun c -> {name = $ 3 ; func = $ 4 c func} @@ at }
397
+ { let at = at () in fun c -> ExportFunc ($ 3 , ($ 4 c func)) @@ at }
398
+ | LPAR EXPORT TEXT MEMORY RPAR
399
+ { let at = at () in fun c -> ExportMemory $ 3 @@ at }
398
400
;
399
401
400
402
module_fields :
Original file line number Diff line number Diff line change @@ -21,8 +21,11 @@ let print_var_sig prefix i t =
21
21
let print_func_sig m prefix i f =
22
22
printf " %s %d : %s\n " prefix i (string_of_func_type (func_type m f))
23
23
24
- let print_export_sig m prefix n f =
25
- printf " %s \" %s\" : %s\n " prefix n (string_of_func_type (func_type m f))
24
+ let print_export_sig m n f =
25
+ printf " export \" %s\" : %s\n " n (string_of_func_type (func_type m f))
26
+
27
+ let print_export_mem n =
28
+ printf " export \" %s\" : memory\n " n
26
29
27
30
let print_table_elem i x =
28
31
printf " table [%d] = func %d\n " i x.it
@@ -36,7 +39,9 @@ let print_func m i f =
36
39
print_func_sig m " func" i f
37
40
38
41
let print_export m i ex =
39
- print_export_sig m " export" ex.it.name (List. nth m.it.funcs ex.it.func.it)
42
+ match ex.it with
43
+ | ExportFunc (n , x ) -> print_export_sig m n (List. nth m.it.funcs x.it)
44
+ | ExportMemory n -> print_export_mem n
40
45
41
46
let print_module m =
42
47
let {funcs; start; exports; table} = m.it in
Original file line number Diff line number Diff line change @@ -289,8 +289,9 @@ let check_elem c x =
289
289
module NameSet = Set. Make (String )
290
290
291
291
let check_export c set ex =
292
- let {name; func = x} = ex.it in
293
- ignore (func c x);
292
+ let name = match ex.it with
293
+ | ExportFunc (n , x ) -> ignore (func c x); n
294
+ | ExportMemory n -> require (c.has_memory) ex.at " no memory to export" ; n in
294
295
require (not (NameSet. mem name set)) ex.at
295
296
" duplicate export name" ;
296
297
NameSet. add name set
Original file line number Diff line number Diff line change @@ -315,7 +315,9 @@ let init_memory {it = {initial; segments; _}} =
315
315
mem
316
316
317
317
let add_export funcs ex =
318
- ExportMap. add ex.it.name (List. nth funcs ex.it.func.it)
318
+ match ex.it with
319
+ | ExportFunc (n , x ) -> ExportMap. add n (List. nth funcs x.it)
320
+ | ExportMemory n -> fun x -> x
319
321
320
322
let init m imports host =
321
323
assert (List. length imports = List. length m.it.Kernel. imports);
Original file line number Diff line number Diff line change @@ -126,7 +126,9 @@ and memory' =
126
126
and segment = Memory .segment Source .phrase
127
127
128
128
type export = export ' Source .phrase
129
- and export' = {name : string ; func : var }
129
+ and export' =
130
+ | ExportFunc of string * var
131
+ | ExportMemory of string
130
132
131
133
type import = import ' Source .phrase
132
134
and import' =
Original file line number Diff line number Diff line change 20
20
)
21
21
22
22
(assert_return (invoke " e" (i32.const 42 )) (i32.const 43 ))
23
+
24
+ (module (memory 0 0 ) (export " a" memory ))
25
+ (module (memory 0 0 ) (export " a" memory ) (export " b" memory ))
26
+ (assert_invalid (module (export " a" memory )) " no memory to export" )
You can’t perform that action at this time.
0 commit comments