1 /*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #include "compiler.hpp"
12 void compiler::operator()(ast::nil) const
17 void compiler::operator()(unsigned int n) const
19 code.push_back(op_int);
23 void compiler::operator()(ast::operation const& x) const
25 boost::apply_visitor(*this, x.operand_);
28 case '+': code.push_back(op_add); break;
29 case '-': code.push_back(op_sub); break;
30 case '*': code.push_back(op_mul); break;
31 case '/': code.push_back(op_div); break;
32 default: BOOST_ASSERT(0); break;
36 void compiler::operator()(ast::signed_ const& x) const
38 boost::apply_visitor(*this, x.operand_);
41 case '-': code.push_back(op_neg); break;
43 default: BOOST_ASSERT(0); break;
47 void compiler::operator()(ast::expression const& x) const
49 boost::apply_visitor(*this, x.first);
50 for (ast::operation const& oper : x.rest)