Skip to content

Commit 3af747e

Browse files
committed
initial impl for translate_end_func
1 parent 029bd41 commit 3af747e

File tree

1 file changed

+13
-1
lines changed
  • crates/wasmi/src/engine/translator/func2

1 file changed

+13
-1
lines changed

crates/wasmi/src/engine/translator/func2/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use self::{
3030
use crate::{
3131
core::{FuelCostsProvider, Typed, TypedVal},
3232
engine::{
33-
translator::{Instr, LabelRef, LabelRegistry, WasmTranslator},
33+
translator::{utils::FuelInfo, Instr, LabelRef, LabelRegistry, WasmTranslator},
3434
BlockType,
3535
CompiledFuncEntity,
3636
TranslationError,
@@ -235,6 +235,11 @@ impl FuncTranslator {
235235
&self.engine
236236
}
237237

238+
/// Returns `true` if fuel metering is enabled.
239+
fn is_fuel_metering_enabled(&self) -> bool {
240+
self.engine.config().get_consume_fuel()
241+
}
242+
238243
/// Translates the end of a Wasm `block` control frame.
239244
fn translate_end_block(&mut self, frame: BlockControlFrame) -> Result<(), Error> {
240245
if self.stack.is_control_empty() {
@@ -245,6 +250,13 @@ impl FuncTranslator {
245250

246251
/// Translates the end of the Wasm function enclosing Wasm `block`.
247252
fn translate_end_func(&mut self, frame: BlockControlFrame) -> Result<(), Error> {
253+
let fuel_info = match (frame.consume_fuel_instr(), &self.fuel_costs) {
254+
(Some(consume_fuel), Some(fuel_costs)) => {
255+
FuelInfo::some(fuel_costs.clone(), consume_fuel)
256+
}
257+
(None, None) => FuelInfo::None,
258+
_ => unreachable!(),
259+
};
248260
todo!()
249261
}
250262

0 commit comments

Comments
 (0)