+/** @file parse_binop_rhs.cpp
+ *
+ * Code to deal with binary operators. */
+
+/*
+ * GiNaC Copyright (C) 1999-2019 Johannes Gutenberg University Mainz, Germany
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#include "ex.h"
#include "symbol.h"
#include "mul.h"
#include "add.h"
#include "power.h"
#include "operators.h"
-#include <stdexcept>
+#include "parser.h"
+#include "lexer.h"
+#include "debug.h"
+
#include <sstream>
-#include "parser.hpp"
-#include "lexer.hpp"
-#include "debug.hpp"
+#include <stdexcept>
-namespace GiNaC
-{
+namespace GiNaC {
/// Make a sum or a product.
static ex make_binop_expr(const int binop, const exvector& args);
}
}
-extern numeric* _num_1_p;
+extern const numeric* _num_1_p;
static ex make_minus_expr(const exvector& args)
{
exvector rest_args;
rest_args.reserve(args.size() - 1);
std::copy(args.begin() + 1, args.end(), std::back_inserter(rest_args));
- ex rest_base = (new add(rest_args))->setflag(status_flags::dynallocated);
- ex rest = (new mul(rest_base, *_num_1_p))->setflag(status_flags::dynallocated);
- ex ret = (new add(args[0], rest))->setflag(status_flags::dynallocated);
+ ex rest_base = dynallocate<add>(rest_args);
+ ex rest = dynallocate<mul>(rest_base, *_num_1_p);
+ ex ret = dynallocate<add>(args[0], rest);
return ret;
}
exvector rest_args;
rest_args.reserve(args.size() - 1);
std::copy(args.begin() + 1, args.end(), std::back_inserter(rest_args));
- ex rest_base = (new mul(rest_args))->setflag(status_flags::dynallocated);
+ ex rest_base = dynallocate<mul>(rest_args);
ex rest = pow(rest_base, *_num_1_p);
- return (new mul(args[0], rest))->setflag(status_flags::dynallocated);
+ return dynallocate<mul>(args[0], rest);
}
static ex make_binop_expr(const int binop, const exvector& args)
{
switch (binop) {
case '+':
- return (new add(args))->setflag(status_flags::dynallocated);
+ return dynallocate<add>(args);
case '-':
return make_minus_expr(args);
case '*':
- return (new mul(args))->setflag(status_flags::dynallocated);
+ return dynallocate<mul>(args);
case '/':
return make_divide_expr(args);
case '^':
}
} // namespace GiNaC
-