Remove implicit recursive cloning of AST
This commit is contained in:
parent
59d0abeb41
commit
dc1116c3e5
@ -212,7 +212,9 @@ impl<'a> Builder<'a> {
|
||||
// Pending expressions are put to sleep before entering
|
||||
// a control structure so that they are not lost.
|
||||
fn save_pending(&mut self) {
|
||||
self.pending.push(self.stack.clone());
|
||||
let cloned = self.stack.iter().map(Expression::clone_recall).collect();
|
||||
|
||||
self.pending.push(cloned);
|
||||
}
|
||||
|
||||
fn load_pending(&mut self) {
|
||||
@ -456,7 +458,7 @@ impl<'a> Builder<'a> {
|
||||
Inst::TeeLocal(i) => {
|
||||
self.gen_leak_pending(&mut stat);
|
||||
|
||||
let value = self.stack.last().unwrap().clone();
|
||||
let value = self.stack.last().unwrap().clone_recall();
|
||||
|
||||
stat.push(Statement::SetLocal(SetLocal { var: *i, value }));
|
||||
}
|
||||
|
@ -9,36 +9,30 @@ pub struct Recall {
|
||||
pub var: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Select {
|
||||
pub cond: Box<Expression>,
|
||||
pub a: Box<Expression>,
|
||||
pub b: Box<Expression>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct GetLocal {
|
||||
pub var: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct GetGlobal {
|
||||
pub var: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AnyLoad {
|
||||
pub op: Load,
|
||||
pub offset: u32,
|
||||
pub pointer: Box<Expression>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MemorySize {
|
||||
pub memory: u8,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MemoryGrow {
|
||||
pub memory: u8,
|
||||
pub value: Box<Expression>,
|
||||
@ -52,20 +46,17 @@ pub enum Value {
|
||||
F64(f64),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AnyUnOp {
|
||||
pub op: UnOp,
|
||||
pub rhs: Box<Expression>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AnyBinOp {
|
||||
pub op: BinOp,
|
||||
pub lhs: Box<Expression>,
|
||||
pub rhs: Box<Expression>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Expression {
|
||||
Recall(Recall),
|
||||
Select(Select),
|
||||
@ -86,6 +77,13 @@ impl Expression {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clone_recall(&self) -> Self {
|
||||
match self {
|
||||
Expression::Recall(v) => Expression::Recall(v.clone()),
|
||||
_ => unreachable!("clone_recall called on non-recall"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Memorize {
|
||||
|
Loading…
x
Reference in New Issue
Block a user