Re-classify MemoryGrow as a Statement
This commit is contained in:
@@ -4,8 +4,8 @@ use std::{
|
||||
};
|
||||
|
||||
use wasm_ast::node::{
|
||||
BinOp, CmpOp, Expression, GetGlobal, GetLocal, GetTemporary, LoadAt, MemoryGrow, MemorySize,
|
||||
Select, UnOp, Value,
|
||||
BinOp, CmpOp, Expression, GetGlobal, GetLocal, GetTemporary, LoadAt, MemorySize, Select, UnOp,
|
||||
Value,
|
||||
};
|
||||
|
||||
use crate::analyzer::operator::bin_symbol_of;
|
||||
@@ -77,14 +77,6 @@ impl Driver for MemorySize {
|
||||
}
|
||||
}
|
||||
|
||||
impl Driver for MemoryGrow {
|
||||
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
write!(w, "rt.allocator.grow(memory_at_{}, ", self.memory)?;
|
||||
self.value.write(mng, w)?;
|
||||
write!(w, ")")
|
||||
}
|
||||
}
|
||||
|
||||
impl_write_number!(write_f32, f32);
|
||||
impl_write_number!(write_f64, f64);
|
||||
|
||||
@@ -146,7 +138,6 @@ impl Driver for Expression {
|
||||
Self::GetGlobal(e) => e.write(mng, w),
|
||||
Self::LoadAt(e) => e.write(mng, w),
|
||||
Self::MemorySize(e) => e.write(mng, w),
|
||||
Self::MemoryGrow(e) => e.write(mng, w),
|
||||
Self::Value(e) => e.write(mng, w),
|
||||
Self::UnOp(e) => e.write(mng, w),
|
||||
Self::BinOp(e) => e.write(mng, w),
|
||||
|
||||
@@ -5,8 +5,8 @@ use std::{
|
||||
|
||||
use parity_wasm::elements::ValueType;
|
||||
use wasm_ast::node::{
|
||||
Backward, Br, BrIf, BrTable, Call, CallIndirect, Forward, FuncData, If, SetGlobal, SetLocal,
|
||||
SetTemporary, Statement, StoreAt, Terminator,
|
||||
Backward, Br, BrIf, BrTable, Call, CallIndirect, Forward, FuncData, If, MemoryGrow, SetGlobal,
|
||||
SetLocal, SetTemporary, Statement, StoreAt, Terminator,
|
||||
};
|
||||
|
||||
use super::manager::{
|
||||
@@ -198,6 +198,17 @@ impl Driver for StoreAt {
|
||||
}
|
||||
}
|
||||
|
||||
impl Driver for MemoryGrow {
|
||||
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
let result = self.result;
|
||||
let memory = self.memory;
|
||||
|
||||
write!(w, "reg_{result} = rt.allocator.grow(memory_at_{memory}, ")?;
|
||||
self.value.write(mng, w)?;
|
||||
write!(w, ")")
|
||||
}
|
||||
}
|
||||
|
||||
impl Driver for Statement {
|
||||
fn write(&self, mng: &mut Manager, w: &mut dyn Write) -> Result<()> {
|
||||
match self {
|
||||
@@ -211,6 +222,7 @@ impl Driver for Statement {
|
||||
Self::SetLocal(s) => s.write(mng, w),
|
||||
Self::SetGlobal(s) => s.write(mng, w),
|
||||
Self::StoreAt(s) => s.write(mng, w),
|
||||
Self::MemoryGrow(s) => s.write(mng, w),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user