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

24 points, emmmmm

parent 1851e507
......@@ -373,14 +373,14 @@ void CminusfBuilder::visit(ASTSimpleExpression &node) {
//!TODO: This function is empty now.
// Add some code here.
//
node.additive_expression_l->accept(*this);
if (node.additive_expression_r) {
node.additive_expression_l->accept(*this);
auto lvalue = cur_value;
node.additive_expression_r->accept(*this);
auto rvalue = cur_value;
// type cast
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();
switch (node.op) {
case OP_LE: {
......@@ -426,7 +426,8 @@ void CminusfBuilder::visit(ASTSimpleExpression &node) {
break;
}
}
}
} else
node.additive_expression_l->accept(*this);
}
// Done
......@@ -434,10 +435,10 @@ void CminusfBuilder::visit(ASTAdditiveExpression &node) {
//!TODO: This function is empty now.
// Add some code here.
//
node.term->accept(*this);
if (node.additive_expression) {
auto lvalue = cur_value;
node.additive_expression->accept(*this);
auto lvalue = cur_value;
node.term->accept(*this);
auto rvalue = cur_value;
// type cast
if (not Type::is_eq_type(lvalue->get_type(), rvalue->get_type()))
......@@ -460,21 +461,22 @@ void CminusfBuilder::visit(ASTAdditiveExpression &node) {
break;
}
}
}
} else
node.term->accept(*this);
}
// Done
void CminusfBuilder::visit(ASTTerm &node) {
//!TODO: This function is empty now.
// Add some code here.
node.factor->accept(*this);
if (node.term) {
auto lvalue = cur_value;
node.term->accept(*this);
auto lvalue = cur_value;
node.factor->accept(*this);
auto rvalue = cur_value;
// type cast
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();
// now left and right is the same type
switch (node.op) {
......@@ -493,7 +495,8 @@ void CminusfBuilder::visit(ASTTerm &node) {
break;
}
}
}
} else
node.factor->accept(*this);
}
// 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