summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2017-11-26 19:58:46 -0500
committerDavid Li <li.davidm96@gmail.com>2017-11-26 19:58:46 -0500
commitb007bc6f9dcbef41c3710cc8ce63b04504a14244 (patch)
tree04b6701fe695a59b7ff4622c6f01f49c134c732e
parentc8f4b4d23a55b73cc7d1aa7e4db4a37100c4116d (diff)
Rename ir::Binop to ir::BinOp
-rw-r--r--src/semantic/analysis.rs2
-rw-r--r--src/semantic/ir.rs4
-rw-r--r--src/semantic/translate.rs5
3 files changed, 6 insertions, 5 deletions
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<Expression>, Box<Expression>),
+ BinOp(BinOp, Box<Expression>, Box<Expression>),
Memory(Box<Expression>),
Call(Box<Expression>, Vec<Expression>),
Seq(Vec<Statement>, Box<Expression>),
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<F: frame::Frame> Translate<F> {
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"),
}
}