Commit 5bb2a40e authored by 李晓奇's avatar 李晓奇

24 points, emmmmm

parent 1851e507
...@@ -373,14 +373,14 @@ void CminusfBuilder::visit(ASTSimpleExpression &node) { ...@@ -373,14 +373,14 @@ void CminusfBuilder::visit(ASTSimpleExpression &node) {
//!TODO: This function is empty now. //!TODO: This function is empty now.
// Add some code here. // Add some code here.
// //
node.additive_expression_l->accept(*this);
if (node.additive_expression_r) { if (node.additive_expression_r) {
node.additive_expression_l->accept(*this);
auto lvalue = cur_value; auto lvalue = cur_value;
node.additive_expression_r->accept(*this); node.additive_expression_r->accept(*this);
auto rvalue = cur_value; auto rvalue = cur_value;
// type cast // type cast
if (not Type::is_eq_type(lvalue->get_type(), rvalue->get_type())) if (not Type::is_eq_type(lvalue->get_type(), rvalue->get_type()))
type_cast(lvalue, rvalue, "addop"); type_cast(lvalue, rvalue, "cmp");
bool float_cmp = lvalue->get_type()->is_float_type(); bool float_cmp = lvalue->get_type()->is_float_type();
switch (node.op) { switch (node.op) {
case OP_LE: { case OP_LE: {
...@@ -426,7 +426,8 @@ void CminusfBuilder::visit(ASTSimpleExpression &node) { ...@@ -426,7 +426,8 @@ void CminusfBuilder::visit(ASTSimpleExpression &node) {
break; break;
} }
} }
} } else
node.additive_expression_l->accept(*this);
} }
// Done // Done
...@@ -434,10 +435,10 @@ void CminusfBuilder::visit(ASTAdditiveExpression &node) { ...@@ -434,10 +435,10 @@ void CminusfBuilder::visit(ASTAdditiveExpression &node) {
//!TODO: This function is empty now. //!TODO: This function is empty now.
// Add some code here. // Add some code here.
// //
node.term->accept(*this);
if (node.additive_expression) { if (node.additive_expression) {
auto lvalue = cur_value;
node.additive_expression->accept(*this); node.additive_expression->accept(*this);
auto lvalue = cur_value;
node.term->accept(*this);
auto rvalue = cur_value; auto rvalue = cur_value;
// type cast // type cast
if (not Type::is_eq_type(lvalue->get_type(), rvalue->get_type())) if (not Type::is_eq_type(lvalue->get_type(), rvalue->get_type()))
...@@ -460,21 +461,22 @@ void CminusfBuilder::visit(ASTAdditiveExpression &node) { ...@@ -460,21 +461,22 @@ void CminusfBuilder::visit(ASTAdditiveExpression &node) {
break; break;
} }
} }
} } else
node.term->accept(*this);
} }
// Done // Done
void CminusfBuilder::visit(ASTTerm &node) { void CminusfBuilder::visit(ASTTerm &node) {
//!TODO: This function is empty now. //!TODO: This function is empty now.
// Add some code here. // Add some code here.
node.factor->accept(*this);
if (node.term) { if (node.term) {
auto lvalue = cur_value;
node.term->accept(*this); node.term->accept(*this);
auto lvalue = cur_value;
node.factor->accept(*this);
auto rvalue = cur_value; auto rvalue = cur_value;
// type cast // type cast
if (not Type::is_eq_type(lvalue->get_type(), rvalue->get_type())) if (not Type::is_eq_type(lvalue->get_type(), rvalue->get_type()))
type_cast(lvalue, rvalue, "addop"); type_cast(lvalue, rvalue, "mul");
bool float_type = lvalue->get_type()->is_float_type(); bool float_type = lvalue->get_type()->is_float_type();
// now left and right is the same type // now left and right is the same type
switch (node.op) { switch (node.op) {
...@@ -493,7 +495,8 @@ void CminusfBuilder::visit(ASTTerm &node) { ...@@ -493,7 +495,8 @@ void CminusfBuilder::visit(ASTTerm &node) {
break; break;
} }
} }
} } else
node.factor->accept(*this);
} }
// Done // Done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment