@@ -64,7 +64,7 @@ impl Interpreter {
64
64
///
65
65
/// Note that the `module` passed in to this function must be the same as
66
66
/// the `module` passed to `interpret` below.
67
- pub fn new ( module : & Module ) -> Interpreter {
67
+ pub fn new ( module : & Module ) -> Result < Interpreter , failure :: Error > {
68
68
let mut ret = Interpreter :: default ( ) ;
69
69
70
70
// The descriptor functions shouldn't really use all that much memory
@@ -102,14 +102,9 @@ impl Interpreter {
102
102
ret. name_map . insert ( export. name . to_string ( ) , id) ;
103
103
}
104
104
105
- for table in module. tables . iter ( ) {
106
- match table. kind {
107
- walrus:: TableKind :: Function ( _) => { }
108
- }
109
- ret. functions = Some ( table. id ( ) ) ;
110
- }
105
+ ret. functions = module. tables . main_function_table ( ) ?;
111
106
112
- return ret;
107
+ return Ok ( ret) ;
113
108
}
114
109
115
110
/// Interprets the execution of the descriptor function `func`.
@@ -204,6 +199,7 @@ impl Interpreter {
204
199
let functions = self . functions . expect ( "function table should be present" ) ;
205
200
let functions = match & module. tables . get ( functions) . kind {
206
201
walrus:: TableKind :: Function ( f) => f,
202
+ _ => unreachable ! ( ) ,
207
203
} ;
208
204
let descriptor_id = functions
209
205
. elements
@@ -348,8 +344,11 @@ impl Frame<'_> {
348
344
349
345
Expr :: WithSideEffects ( e) => {
350
346
log:: debug!( "side effects" ) ;
347
+ for x in e. before . iter ( ) {
348
+ self . eval ( * x) ;
349
+ }
351
350
let ret = self . eval ( e. value ) ;
352
- for x in e. side_effects . iter ( ) {
351
+ for x in e. after . iter ( ) {
353
352
self . eval ( * x) ;
354
353
}
355
354
return ret;
0 commit comments