From b007bc6f9dcbef41c3710cc8ce63b04504a14244 Mon Sep 17 00:00:00 2001 From: David Li Date: Sun, 26 Nov 2017 19:58:46 -0500 Subject: Rename ir::Binop to ir::BinOp --- src/semantic/analysis.rs | 2 +- src/semantic/ir.rs | 4 ++-- src/semantic/translate.rs | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/semantic') diff --git a/src/semantic/analysis.rs b/src/semantic/analysis.rs index 4c936f3..973e703 100644 --- a/src/semantic/analysis.rs +++ b/src/semantic/analysis.rs @@ -222,7 +222,7 @@ fn trans_exp<'a, 'b, F: frame::Frame>( &Add => { match (left_ty, right_ty) { (Ty::Int, Ty::Int) => { - Ok((tr.make_binop(ir::Binop::Plus, left_exp, right_exp), + Ok((tr.make_binop(ir::BinOp::Plus, left_exp, right_exp), Ty::Int)) } (Ty::String, Ty::String) => { diff --git a/src/semantic/ir.rs b/src/semantic/ir.rs index be358c4..f92cf27 100644 --- a/src/semantic/ir.rs +++ b/src/semantic/ir.rs @@ -1,7 +1,7 @@ use super::temp; #[derive(Debug)] -pub enum Binop { +pub enum BinOp { Plus, } @@ -10,7 +10,7 @@ pub enum Expression { Const(u64), Name(temp::TempLabel), Temp(temp::TempName), - Binop(Binop, Box, Box), + BinOp(BinOp, Box, Box), Memory(Box), Call(Box, Vec), Seq(Vec, Box), diff --git a/src/semantic/translate.rs b/src/semantic/translate.rs index 4a2b6c5..57581a4 100644 --- a/src/semantic/translate.rs +++ b/src/semantic/translate.rs @@ -50,11 +50,12 @@ impl Translate { Expression::Exp(ir::Expression::Const(num)) } - pub fn make_binop(&mut self, op: ir::Binop, + pub fn make_binop(&mut self, op: ir::BinOp, left: Expression, right: Expression) -> Expression { match (left, right) { (Expression::Exp(left), Expression::Exp(right)) => - Expression::Exp(ir::Expression::Binop(op, Box::new(left), Box::new(right))), + Expression::Exp(ir::Expression::BinOp(op, Box::new(left), Box::new(right))), + // TODO: return Result _ => panic!("Can't make binop from Void"), } } -- cgit v1.2.3