diff options
Diffstat (limited to 'c_compiler/src/expression.cpp')
-rw-r--r-- | c_compiler/src/expression.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/c_compiler/src/expression.cpp b/c_compiler/src/expression.cpp index 29bfe0d..8935e37 100644 --- a/c_compiler/src/expression.cpp +++ b/c_compiler/src/expression.cpp @@ -50,6 +50,26 @@ VariableStackBindings AssignmentExpression::printasm(VariableStackBindings bindi } +// Additive Expression definition + +AdditiveExpression::AdditiveExpression(Expression* _lhs, const std::string& _operand, Expression* _rhs) + : OperationExpression(_lhs, _rhs), operand(_operand) +{} + +VariableStackBindings AdditiveExpression::printasm(VariableStackBindings bindings) const +{ + rhs->printasm(bindings); + + std::cout << "\tmove\t$3,$2" << std::endl; + + lhs->printasm(bindings); + + std::cout << "\tadd\t$2,$2,$3" << std::endl; + + return bindings; +} + + // Identifier definition Identifier::Identifier(const std::string& id) |