Skip to content

Commit d940656

Browse files
committed
Updated variable names for expr/stmt locations
1 parent b15a1be commit d940656

File tree

3 files changed

+44
-45
lines changed

3 files changed

+44
-45
lines changed

src/diagnostic.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl DiagnosticHandler {
112112
return;
113113
}
114114
let buffer = &mut Buffer::ansi();
115-
if let Some((start, end, fileid)) = tr.get_expr_md(*expr_id) {
115+
if let Some((start, end, fileid)) = tr.get_expr_loc(*expr_id) {
116116
let label = Label {
117117
message: Some(message.to_string()),
118118
range: (start, end),
@@ -142,7 +142,7 @@ impl DiagnosticHandler {
142142
return;
143143
}
144144
let buffer = &mut Buffer::ansi();
145-
if let Some((start, end, fileid)) = tr.get_stmt_md(*stmt_id) {
145+
if let Some((start, end, fileid)) = tr.get_stmt_loc(*stmt_id) {
146146
let label = Label {
147147
message: Some(message.to_string()),
148148
range: (start, end),
@@ -187,8 +187,8 @@ mod tests {
187187
"12345678\nassert_eq!(x, 20);\n".to_string(),
188188
);
189189

190-
tr.add_expr_md(one_expr, 9, 11, file_id);
191-
tr.add_expr_md(zero_expr, 12, 15, file_id);
190+
tr.add_expr_loc(one_expr, 9, 11, file_id);
191+
tr.add_expr_loc(zero_expr, 12, 15, file_id);
192192

193193
handler.emit_diagnostic_expr(&tr, &one_expr, "Random Warning", Level::Warning);
194194
handler.emit_diagnostic_expr(&tr, &zero_expr, "Random Error", Level::Error);
@@ -237,36 +237,36 @@ mod tests {
237237

238238
// 3) create expressions
239239
let ii_expr = calyx_go_done.e(Expr::Sym(ii));
240-
calyx_go_done.add_expr_md(ii_expr, 153, 155, calyx_fileid);
240+
calyx_go_done.add_expr_loc(ii_expr, 153, 155, calyx_fileid);
241241
let dut_oo_expr = calyx_go_done.e(Expr::Sym(dut_oo));
242-
calyx_go_done.add_expr_md(dut_oo_expr, 260, 266, calyx_fileid);
242+
calyx_go_done.add_expr_loc(dut_oo_expr, 260, 266, calyx_fileid);
243243
let one_expr = calyx_go_done.e(Expr::Const(BitVecValue::from_u64(1, 1)));
244-
calyx_go_done.add_expr_md(one_expr, 170, 171, calyx_fileid);
244+
calyx_go_done.add_expr_loc(one_expr, 170, 171, calyx_fileid);
245245
let zero_expr = calyx_go_done.e(Expr::Const(BitVecValue::from_u64(0, 1)));
246-
calyx_go_done.add_expr_md(zero_expr, 232, 233, calyx_fileid);
246+
calyx_go_done.add_expr_loc(zero_expr, 232, 233, calyx_fileid);
247247
let dut_done_expr = calyx_go_done.e(Expr::Sym(dut_done));
248-
calyx_go_done.add_expr_md(dut_done_expr, 184, 192, calyx_fileid);
248+
calyx_go_done.add_expr_loc(dut_done_expr, 184, 192, calyx_fileid);
249249
let cond_expr = calyx_go_done.e(Expr::Equal(dut_done_expr, one_expr));
250-
calyx_go_done.add_expr_md(cond_expr, 183, 198, calyx_fileid);
250+
calyx_go_done.add_expr_loc(cond_expr, 183, 198, calyx_fileid);
251251
let not_expr = calyx_go_done.e(Expr::Not(cond_expr));
252-
calyx_go_done.add_expr_md(not_expr, 182, 198, calyx_fileid);
252+
calyx_go_done.add_expr_loc(not_expr, 182, 198, calyx_fileid);
253253

254254
// 4) create statements
255255
let while_body = vec![calyx_go_done.s(Stmt::Step)];
256256
let wbody = calyx_go_done.s(Stmt::Block(while_body));
257257

258258
let dut_ii_assign = calyx_go_done.s(Stmt::Assign(dut_ii, ii_expr));
259-
calyx_go_done.add_stmt_md(dut_ii_assign, 143, 157, calyx_fileid);
259+
calyx_go_done.add_stmt_loc(dut_ii_assign, 143, 157, calyx_fileid);
260260
let dut_go_assign = calyx_go_done.s(Stmt::Assign(dut_go, one_expr));
261-
calyx_go_done.add_stmt_md(dut_go_assign, 160, 172, calyx_fileid);
261+
calyx_go_done.add_stmt_loc(dut_go_assign, 160, 172, calyx_fileid);
262262
let dut_while = calyx_go_done.s(Stmt::While(not_expr, wbody));
263-
calyx_go_done.add_stmt_md(dut_while, 175, 219, calyx_fileid);
263+
calyx_go_done.add_stmt_loc(dut_while, 175, 219, calyx_fileid);
264264
let dut_go_reassign = calyx_go_done.s(Stmt::Assign(dut_go, zero_expr));
265-
calyx_go_done.add_stmt_md(dut_go_reassign, 222, 234, calyx_fileid);
265+
calyx_go_done.add_stmt_loc(dut_go_reassign, 222, 234, calyx_fileid);
266266
let dut_ii_dontcare = calyx_go_done.s(Stmt::Assign(dut_ii, calyx_go_done.expr_dont_care()));
267-
calyx_go_done.add_stmt_md(dut_ii_dontcare, 238, 250, calyx_fileid);
267+
calyx_go_done.add_stmt_loc(dut_ii_dontcare, 238, 250, calyx_fileid);
268268
let oo_assign = calyx_go_done.s(Stmt::Assign(oo, dut_oo_expr));
269-
calyx_go_done.add_stmt_md(oo_assign, 254, 268, calyx_fileid);
269+
calyx_go_done.add_stmt_loc(oo_assign, 254, 268, calyx_fileid);
270270
let body = vec![
271271
dut_ii_assign,
272272
dut_go_assign,

src/ir.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub struct Transaction {
1919
dont_care_id: ExprId,
2020
stmts: PrimaryMap<StmtId, Stmt>,
2121
skip_id: StmtId,
22-
expr_md: SecondaryMap<ExprId, (usize, usize, usize)>,
23-
stmt_md: SecondaryMap<StmtId, (usize, usize, usize)>,
22+
expr_loc: SecondaryMap<ExprId, (usize, usize, usize)>,
23+
stmt_loc: SecondaryMap<StmtId, (usize, usize, usize)>,
2424
}
2525

2626
impl Transaction {
@@ -29,8 +29,8 @@ impl Transaction {
2929
let dont_care_id = exprs.push(Expr::DontCare);
3030
let mut stmts = PrimaryMap::new();
3131
let skip_id = stmts.push(Stmt::Skip);
32-
let expr_md: SecondaryMap<ExprId, (usize, usize, usize)> = SecondaryMap::new();
33-
let stmt_md: SecondaryMap<StmtId, (usize, usize, usize)> = SecondaryMap::new();
32+
let expr_loc: SecondaryMap<ExprId, (usize, usize, usize)> = SecondaryMap::new();
33+
let stmt_loc: SecondaryMap<StmtId, (usize, usize, usize)> = SecondaryMap::new();
3434
Self {
3535
name,
3636
args: Vec::default(),
@@ -40,8 +40,8 @@ impl Transaction {
4040
dont_care_id,
4141
stmts,
4242
skip_id,
43-
expr_md,
44-
stmt_md,
43+
expr_loc,
44+
stmt_loc,
4545
}
4646
}
4747

@@ -71,20 +71,20 @@ impl Transaction {
7171
self.stmts.keys().collect()
7272
}
7373

74-
pub fn add_expr_md(&mut self, expr_id: ExprId, start: usize, end: usize, fileid: usize) {
75-
self.expr_md[expr_id] = (start, end, fileid);
74+
pub fn add_expr_loc(&mut self, expr_id: ExprId, start: usize, end: usize, fileid: usize) {
75+
self.expr_loc[expr_id] = (start, end, fileid);
7676
}
7777

78-
pub fn get_expr_md(&self, expr_id: ExprId) -> Option<(usize, usize, usize)> {
79-
self.expr_md.get(expr_id).copied()
78+
pub fn get_expr_loc(&self, expr_id: ExprId) -> Option<(usize, usize, usize)> {
79+
self.expr_loc.get(expr_id).copied()
8080
}
8181

82-
pub fn add_stmt_md(&mut self, stmt_id: StmtId, start: usize, end: usize, fileid: usize) {
83-
self.stmt_md[stmt_id] = (start, end, fileid);
82+
pub fn add_stmt_loc(&mut self, stmt_id: StmtId, start: usize, end: usize, fileid: usize) {
83+
self.stmt_loc[stmt_id] = (start, end, fileid);
8484
}
8585

86-
pub fn get_stmt_md(&self, stmt_id: StmtId) -> Option<(usize, usize, usize)> {
87-
self.stmt_md.get(stmt_id).copied()
86+
pub fn get_stmt_loc(&self, stmt_id: StmtId) -> Option<(usize, usize, usize)> {
87+
self.stmt_loc.get(stmt_id).copied()
8888
}
8989
}
9090

@@ -153,7 +153,6 @@ pub enum Type {
153153
impl Type {
154154
pub fn is_equivalent(&self, other: &Type) -> bool {
155155
match (self, other) {
156-
// be strict, don't see this as equivalent
157156
(Type::BitVec(vec1), Type::BitVec(vec2)) => vec1 == vec2,
158157
(Type::Struct(id1), Type::Struct(id2)) => id1 == id2,
159158
// TODO: type inferencing to infer unknown == LHS

src/typecheck.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,36 +181,36 @@ mod tests {
181181

182182
// 3) create expressions
183183
let ii_expr = calyx_go_done.e(Expr::Sym(ii));
184-
calyx_go_done.add_expr_md(ii_expr, 153, 155, calyx_fileid);
184+
calyx_go_done.add_expr_loc(ii_expr, 153, 155, calyx_fileid);
185185
let dut_oo_expr = calyx_go_done.e(Expr::Sym(dut_oo));
186-
calyx_go_done.add_expr_md(dut_oo_expr, 260, 266, calyx_fileid);
186+
calyx_go_done.add_expr_loc(dut_oo_expr, 260, 266, calyx_fileid);
187187
let one_expr = calyx_go_done.e(Expr::Const(BitVecValue::from_u64(1, 1)));
188-
calyx_go_done.add_expr_md(one_expr, 170, 171, calyx_fileid);
188+
calyx_go_done.add_expr_loc(one_expr, 170, 171, calyx_fileid);
189189
let zero_expr = calyx_go_done.e(Expr::Const(BitVecValue::from_u64(0, 1)));
190-
calyx_go_done.add_expr_md(zero_expr, 232, 233, calyx_fileid);
190+
calyx_go_done.add_expr_loc(zero_expr, 232, 233, calyx_fileid);
191191
let dut_done_expr = calyx_go_done.e(Expr::Sym(dut_done));
192-
calyx_go_done.add_expr_md(dut_done_expr, 184, 192, calyx_fileid);
192+
calyx_go_done.add_expr_loc(dut_done_expr, 184, 192, calyx_fileid);
193193
let cond_expr = calyx_go_done.e(Expr::Equal(dut_done_expr, one_expr));
194-
calyx_go_done.add_expr_md(cond_expr, 183, 198, calyx_fileid);
194+
calyx_go_done.add_expr_loc(cond_expr, 183, 198, calyx_fileid);
195195
let not_expr = calyx_go_done.e(Expr::Not(cond_expr));
196-
calyx_go_done.add_expr_md(not_expr, 182, 198, calyx_fileid);
196+
calyx_go_done.add_expr_loc(not_expr, 182, 198, calyx_fileid);
197197

198198
// 4) create statements
199199
let while_body = vec![calyx_go_done.s(Stmt::Step)];
200200
let wbody = calyx_go_done.s(Stmt::Block(while_body));
201201

202202
let dut_ii_assign = calyx_go_done.s(Stmt::Assign(dut_ii, ii_expr));
203-
calyx_go_done.add_stmt_md(dut_ii_assign, 143, 157, calyx_fileid);
203+
calyx_go_done.add_stmt_loc(dut_ii_assign, 143, 157, calyx_fileid);
204204
let dut_go_assign = calyx_go_done.s(Stmt::Assign(dut_go, one_expr));
205-
calyx_go_done.add_stmt_md(dut_go_assign, 160, 172, calyx_fileid);
205+
calyx_go_done.add_stmt_loc(dut_go_assign, 160, 172, calyx_fileid);
206206
let dut_while = calyx_go_done.s(Stmt::While(not_expr, wbody));
207-
calyx_go_done.add_stmt_md(dut_while, 175, 219, calyx_fileid);
207+
calyx_go_done.add_stmt_loc(dut_while, 175, 219, calyx_fileid);
208208
let dut_go_reassign = calyx_go_done.s(Stmt::Assign(dut_go, zero_expr));
209-
calyx_go_done.add_stmt_md(dut_go_reassign, 222, 234, calyx_fileid);
209+
calyx_go_done.add_stmt_loc(dut_go_reassign, 222, 234, calyx_fileid);
210210
let dut_ii_dontcare = calyx_go_done.s(Stmt::Assign(dut_ii, calyx_go_done.expr_dont_care()));
211-
calyx_go_done.add_stmt_md(dut_ii_dontcare, 238, 250, calyx_fileid);
211+
calyx_go_done.add_stmt_loc(dut_ii_dontcare, 238, 250, calyx_fileid);
212212
let oo_assign = calyx_go_done.s(Stmt::Assign(oo, dut_oo_expr));
213-
calyx_go_done.add_stmt_md(oo_assign, 254, 268, calyx_fileid);
213+
calyx_go_done.add_stmt_loc(oo_assign, 254, 268, calyx_fileid);
214214
let body = vec![
215215
dut_ii_assign,
216216
dut_go_assign,

0 commit comments

Comments
 (0)