Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #214 from Chia-Network/20230815-letdata-box
Browse files Browse the repository at this point in the history
Shrink the stack a bit by putting LetData in Box.  Accomodates things…
  • Loading branch information
prozacchiwawa committed Aug 15, 2023
2 parents 2b64a17 + c4840e4 commit ceb24c8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/compiler/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,12 +839,12 @@ pub fn hoist_body_let_binding(
let sub_bindings = letdata.bindings.iter().skip(1).cloned().collect();
Rc::new(BodyForm::Let(
LetFormKind::Sequential,
LetData {
Box::new(LetData {
loc: letdata.loc.clone(),
kw: letdata.kw.clone(),
bindings: sub_bindings,
body: letdata.body.clone(),
},
}),
))
};

Expand All @@ -853,12 +853,12 @@ pub fn hoist_body_let_binding(
args,
Rc::new(BodyForm::Let(
LetFormKind::Parallel,
LetData {
Box::new(LetData {
loc: letdata.loc.clone(),
kw: letdata.kw.clone(),
bindings: vec![letdata.bindings[0].clone()],
body: new_sub_expr,
},
}),
)),
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/comptypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub struct LetData {
#[derive(Clone, Debug, Serialize)]
pub enum BodyForm {
/// A let or let* form (depending on LetFormKind).
Let(LetFormKind, LetData),
Let(LetFormKind, Box<LetData>),
/// An explicitly quoted constant of some kind.
Quoted(SExp),
/// An undiferentiated "value" of some kind in the source language.
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,12 +1025,12 @@ impl<'info> Evaluator {
&updated_bindings,
Rc::new(BodyForm::Let(
LetFormKind::Sequential,
LetData {
Box::new(LetData {
loc: letdata.loc.clone(),
kw: letdata.kw.clone(),
bindings: rest_of_bindings,
body: letdata.body.clone(),
},
}),
)),
only_inline,
)
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,12 @@ pub fn compile_bodyform(
let compiled_body = compile_bodyform(opts, Rc::new(body))?;
Ok(BodyForm::Let(
kind,
LetData {
Box::new(LetData {
loc: l.clone(),
kw: Some(l.clone()),
bindings: let_bindings,
body: Rc::new(compiled_body),
},
}),
))
} else if *atom_name == "quote".as_bytes().to_vec() {
if v.len() != 1 {
Expand Down
12 changes: 6 additions & 6 deletions src/compiler/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ fn rename_in_bodyform(namemap: &HashMap<Vec<u8>, Vec<u8>>, b: Rc<BodyForm>) -> B
let new_body = rename_in_bodyform(namemap, letdata.body.clone());
BodyForm::Let(
kind.clone(),
LetData {
Box::new(LetData {
loc: letdata.loc.clone(),
kw: letdata.kw.clone(),
bindings: new_bindings,
body: Rc::new(new_body),
},
}),
)
}

Expand Down Expand Up @@ -189,12 +189,12 @@ pub fn desugar_sequential_let_bindings(
bindings,
&BodyForm::Let(
LetFormKind::Parallel,
LetData {
Box::new(LetData {
loc: want_binding.loc(),
kw: None,
bindings: vec![want_binding],
body: Rc::new(body.clone()),
},
}),
),
n - 1,
)
Expand Down Expand Up @@ -240,12 +240,12 @@ fn rename_args_bodyform(b: &BodyForm) -> BodyForm {
let locally_renamed_body = rename_in_bodyform(&local_namemap, letdata.body.clone());
BodyForm::Let(
LetFormKind::Parallel,
LetData {
Box::new(LetData {
loc: letdata.loc.clone(),
kw: letdata.kw.clone(),
bindings: new_bindings,
body: Rc::new(locally_renamed_body),
},
}),
)
}

Expand Down

0 comments on commit ceb24c8

Please sign in to comment.