File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
crates/wasmi/src/engine/translator/translator2 Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,12 @@ mod consts;
2
2
3
3
use self :: consts:: ConstRegistry ;
4
4
use super :: { LocalIdx , OperandIdx , Reset } ;
5
- use crate :: { core:: UntypedVal , engine:: TranslationError , ir:: Reg , Error } ;
5
+ use crate :: {
6
+ core:: { UntypedVal , ValType } ,
7
+ engine:: TranslationError ,
8
+ ir:: Reg ,
9
+ Error ,
10
+ } ;
6
11
7
12
#[ cfg( doc) ]
8
13
use super :: Stack ;
@@ -24,6 +29,16 @@ impl Reset for StackLayout {
24
29
}
25
30
26
31
impl StackLayout {
32
+ /// Register `amount` local variables of common type `ty`.
33
+ ///
34
+ /// # Errors
35
+ ///
36
+ /// If too many local variables are being registered.
37
+ pub fn register_locals ( & mut self , amount : u32 , ty : ValType ) -> Result < ( ) , Error > {
38
+ self . len_locals += amount as usize ;
39
+ Ok ( ( ) )
40
+ }
41
+
27
42
/// Returns the [`StackSpace`] of the [`Reg`].
28
43
///
29
44
/// Returns `None` if the [`Reg`] is unknown to the [`Stack`].
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ use self::{
15
15
use crate :: {
16
16
core:: FuelCostsProvider ,
17
17
engine:: { translator:: WasmTranslator , CompiledFuncEntity } ,
18
- module:: { FuncIdx , ModuleHeader } ,
18
+ module:: { FuncIdx , ModuleHeader , WasmiValueType } ,
19
19
Engine ,
20
20
Error ,
21
21
} ;
@@ -79,10 +79,13 @@ impl WasmTranslator<'_> for FuncTranslator {
79
79
80
80
fn translate_locals (
81
81
& mut self ,
82
- _amount : u32 ,
83
- _value_type : wasmparser:: ValType ,
82
+ amount : u32 ,
83
+ value_type : wasmparser:: ValType ,
84
84
) -> Result < ( ) , Error > {
85
- todo ! ( )
85
+ let ty = WasmiValueType :: from ( value_type) . into_inner ( ) ;
86
+ self . stack . register_locals ( amount, ty) ?;
87
+ self . layout . register_locals ( amount, ty) ?;
88
+ Ok ( ( ) )
86
89
}
87
90
88
91
fn finish_translate_locals ( & mut self ) -> Result < ( ) , Error > {
You can’t perform that action at this time.
0 commit comments