Skip to content

Commit

Permalink
fix += desugaring to lease lhs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Apr 19, 2022
1 parent 2d5d296 commit 04b7fbf
Show file tree
Hide file tree
Showing 33 changed files with 308 additions and 85 deletions.
8 changes: 6 additions & 2 deletions components/dada-brew/src/brew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,20 @@ impl Cursor {
}

validated::ExprData::Assign(place, value_expr) => {
self.push_breakpoint_start(brewery, origin);
let (place, origins) = self.brew_target_place(brewery, *place);
self.push_breakpoint_starts(brewery, origins.iter().copied(), origin);
self.brew_expr_and_assign_to(brewery, place, *value_expr);
self.push_breakpoint_ends(brewery, None::<bir::Place>, origins, origin)
}

validated::ExprData::AssignFromPlace(target_place, source_place) => {
self.push_breakpoint_start(brewery, origin);
let (target_place, target_origins) = self.brew_target_place(brewery, *target_place);
let (source_place, source_origins) = self.brew_place(brewery, *source_place);
self.push_breakpoint_starts(
brewery,
target_origins.iter().chain(source_origins.iter()).copied(),
origin,
);
self.push_assignment_from_place(brewery, target_place, source_place, origin);
self.push_breakpoint_ends(
brewery,
Expand Down
2 changes: 1 addition & 1 deletion components/dada-brew/src/brewery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use dada_ir::{
pub struct Brewery<'me> {
db: &'me dyn crate::Db,
code: Code,
breakpoints: &'me [syntax::Expr],
pub(crate) breakpoints: &'me [syntax::Expr],
validated_tree_data: &'me validated::TreeData,
validated_origins: &'me validated::Origins,
tables: &'me mut bir::Tables,
Expand Down
5 changes: 5 additions & 0 deletions components/dada-brew/src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ impl Cursor {
/// If `origin` is a breakpoint expression, push a "breakpoint-start"
/// statement onto the current basic block.
pub(crate) fn push_breakpoint_start(&mut self, brewery: &mut Brewery<'_>, origin: ExprOrigin) {
tracing::debug!(
"push_breakpoint_start: origin={:?} breakpoints={:?}",
origin,
brewery.breakpoints
);
if !origin.synthesized && self.end_block.is_some() {
if let Some(breakpoint_index) = brewery.expr_is_breakpoint(origin.syntax_expr) {
let filename = brewery.code().filename(brewery.db());
Expand Down
11 changes: 9 additions & 2 deletions components/dada-execute/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,15 @@ impl Kernel for BufferKernel {
index
);

let (breakpoint_filename, breakpoint_index, heap_at_start) =
self.started_breakpoints.pop().unwrap();
let Some((breakpoint_filename, breakpoint_index, heap_at_start)) =
self.started_breakpoints.pop()
else {
panic!(
"breakpoint {index} for `{}` at `{:?}` not found",
filename.as_str(db),
span.debug(db),
)
};
assert_eq!(filename, breakpoint_filename);
assert_eq!(index, breakpoint_index);
let breakpoint_record = BreakpointRecord {
Expand Down
14 changes: 7 additions & 7 deletions components/dada-ir/src/code/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ id!(pub struct Expr);

impl DebugWithDb<InIrDb<'_, Tree>> for Expr {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Tree>) -> std::fmt::Result {
f.debug_tuple("")
.field(self)
f.debug_tuple(&format!("{self:?}"))
.field(&self.data(db.tables()).debug(db))
.finish()
}
Expand Down Expand Up @@ -265,9 +264,11 @@ pub struct LocalVariableDeclData {

impl DebugWithDb<InIrDb<'_, Tree>> for LocalVariableDeclData {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Tree>) -> std::fmt::Result {
f.debug_tuple("")
.field(&self.name.debug(db.db()))
.field(&self.ty.debug(db.db()))
f.debug_struct("LocalVariableDeclData")
.field("specifier", &self.specifier.specifier(db.db()))
.field("atomic", &self.atomic)
.field("name", &self.name.debug(db.db()))
.field("ty", &self.ty.debug(db.db()))
.finish()
}
}
Expand All @@ -294,8 +295,7 @@ pub struct NamedExprData {

impl DebugWithDb<InIrDb<'_, Tree>> for NamedExprData {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>, db: &InIrDb<'_, Tree>) -> std::fmt::Result {
f.debug_tuple("")
.field(&self.name.word(db.db()).debug(db.db()))
f.debug_tuple(&format!("{:?}", self.name.word(db.db()).debug(db.db())))
.field(&self.expr.debug(db))
.finish()
}
Expand Down
17 changes: 16 additions & 1 deletion components/dada-ir/src/code/validated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ origin_table! {
/// lowering the syntax expressions. We track the expression they came
/// from, but also the fact that they are synthetic. This is needed to
/// help place cursors and so forth.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct ExprOrigin {
pub syntax_expr: syntax::Expr,
pub synthesized: bool,
Expand All @@ -134,6 +134,21 @@ impl ExprOrigin {
}
}

impl std::fmt::Debug for ExprOrigin {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let ExprOrigin {
synthesized,
syntax_expr,
} = *self;

if synthesized {
write!(fmt, "synthesized from {syntax_expr:?}")
} else {
write!(fmt, "from {syntax_expr:?}")
}
}
}

impl From<syntax::Expr> for ExprOrigin {
fn from(e: syntax::Expr) -> Self {
Self::real(e)
Expand Down
7 changes: 7 additions & 0 deletions components/dada-lang/src/test_harness/heap_graph_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ impl super::Options {
));
}

self.check_compiled(
db,
&[filename],
|item| db.debug_bir(item),
&path.join(format!("HeapGraph-{query_index}.bir.ref")),
)?;

match db.function_named(filename, "main") {
Some(function) => {
kernel.interpret_and_buffer(db, function, vec![]).await;
Expand Down
1 change: 1 addition & 0 deletions components/dada-validate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#![feature(trait_upcasting)]
#![feature(try_blocks)]
#![feature(let_else)]
#![allow(incomplete_features)]

mod validate;
Expand Down
Loading

0 comments on commit 04b7fbf

Please sign in to comment.