Skip to content

Commit 9ff07c7

Browse files
chapter17: fix remaining compilation errors
1 parent b20acbb commit 9ff07c7

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

src/sea_of_nodes/nodes/idealize.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::sea_of_nodes::nodes::node::{
55
Sub, TypedNode,
66
};
77
use crate::sea_of_nodes::nodes::{BoolOp, Node, Nodes, Op};
8-
use crate::sea_of_nodes::types::{Int, Type};
8+
use crate::sea_of_nodes::types::Type;
99

1010
impl Node {
1111
/// do not peephole directly returned values!
@@ -534,15 +534,15 @@ impl Load {
534534
name,
535535
alias,
536536
declared_ty,
537-
[mem.inputs(sea)[1].unwrap(), ptr],
537+
[mem.inputs(sea)[1].unwrap(), ptr, todo!()],
538538
sea,
539539
)
540540
.peephole(sea);
541541
let ld2 = Load::new(
542542
name,
543543
alias,
544544
declared_ty,
545-
[mem.inputs(sea)[2].unwrap(), ptr],
545+
[mem.inputs(sea)[2].unwrap(), ptr, todo!()],
546546
sea,
547547
)
548548
.peephole(sea);
@@ -629,9 +629,7 @@ impl Minus {
629629
impl Div {
630630
fn idealize_div(self, sea: &mut Nodes) -> Option<Node> {
631631
// Div of 1.
632-
if let Some(Type::Int(Int::Constant(1))) =
633-
self.inputs(sea)[2].and_then(|n| n.ty(sea)).as_deref()
634-
{
632+
if Some(*sea.tys.int_one) == self.inputs(sea)[2].and_then(|n| n.ty(sea)) {
635633
return self.inputs(sea)[1];
636634
}
637635
None

src/sea_of_nodes/nodes/peephole.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl<'t> Node {
404404
ts.push(types.ctrl);
405405
ts.push(**ptr);
406406
for (i, f) in fs.iter().enumerate() {
407-
let mem = in_ty(i+2).as_mem();
407+
let mem = in_ty(i + 2).as_mem();
408408
let tfld = in_ty(2 + fs.len() + i).meet(mem.data().t, types);
409409
ts.push(*types.get_mem(f.alias, tfld));
410410
}

src/sea_of_nodes/nodes/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::fmt;
88
//
99

1010
#[derive(Clone, Debug)]
11-
struct Var<'t> {
11+
pub struct Var<'t> {
1212
/// index in containing scope
1313
pub index: usize,
1414
/// Declared name

src/sea_of_nodes/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ impl<'s, 't> Parser<'s, 't> {
241241
/// </pre>
242242
///
243243
/// Does not parse the opening or closing `{}`
244-
fn parse_block(&mut self, inCon: bool) -> PResult<()> {
245-
self.scope.push(inCon, &mut self.nodes);
244+
fn parse_block(&mut self, in_con: bool) -> PResult<()> {
245+
self.scope.push(in_con, &mut self.nodes);
246246
while !self.peek('}') && !self.lexer.is_eof() {
247247
self.parse_statement()?;
248248
}
@@ -303,7 +303,7 @@ impl<'s, 't> Parser<'s, 't> {
303303
self.scope.push(false, &mut self.nodes); // Scope for the index variables
304304
if !self.match_(";") {
305305
// Can be empty init "for(;test;next) body"
306-
self.parse_declaration_statement(); // Non-empty init
306+
self.parse_declaration_statement()?; // Non-empty init
307307
}
308308
let rez = self.parse_looping(true);
309309
self.scope.pop(&mut self.nodes); // Exit index variable scope
@@ -629,7 +629,7 @@ impl<'s, 't> Parser<'s, 't> {
629629
)
630630
.peep(self)
631631
};
632-
r.peephole(&mut self.nodes);
632+
let _ = r.peephole(&mut self.nodes);
633633
Ok(ret)
634634
}
635635

0 commit comments

Comments
 (0)