From c4840e44302b0121b61d1587bed8d47fd60f7c55 Mon Sep 17 00:00:00 2001 From: arty Date: Tue, 15 Aug 2023 13:50:55 -0700 Subject: [PATCH] Shrink the stack a bit by putting LetData in Box. Accomodates things needed by the assign and lambda prs. --- src/compiler/codegen.rs | 8 ++++---- src/compiler/comptypes.rs | 2 +- src/compiler/evaluate.rs | 4 ++-- src/compiler/frontend.rs | 4 ++-- src/compiler/rename.rs | 12 ++++++------ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/compiler/codegen.rs b/src/compiler/codegen.rs index 9044f1031..a290b1558 100644 --- a/src/compiler/codegen.rs +++ b/src/compiler/codegen.rs @@ -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(), - }, + }), )) }; @@ -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, - }, + }), )), ) } diff --git a/src/compiler/comptypes.rs b/src/compiler/comptypes.rs index f38ff8321..9f715270d 100644 --- a/src/compiler/comptypes.rs +++ b/src/compiler/comptypes.rs @@ -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), /// An explicitly quoted constant of some kind. Quoted(SExp), /// An undiferentiated "value" of some kind in the source language. diff --git a/src/compiler/evaluate.rs b/src/compiler/evaluate.rs index 2eec38783..6f2800068 100644 --- a/src/compiler/evaluate.rs +++ b/src/compiler/evaluate.rs @@ -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, ) diff --git a/src/compiler/frontend.rs b/src/compiler/frontend.rs index 8452a7deb..efbbadc7d 100644 --- a/src/compiler/frontend.rs +++ b/src/compiler/frontend.rs @@ -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 { diff --git a/src/compiler/rename.rs b/src/compiler/rename.rs index 759e32f40..2c075cce8 100644 --- a/src/compiler/rename.rs +++ b/src/compiler/rename.rs @@ -136,12 +136,12 @@ fn rename_in_bodyform(namemap: &HashMap, Vec>, b: Rc) -> 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), - }, + }), ) } @@ -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, ) @@ -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), - }, + }), ) }