summaryrefslogtreecommitdiff
path: root/valexpr.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-26 05:06:06 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-26 05:06:06 -0400
commit162d982b0cf1a5ac2e67012a3b8eadae3c1ac59f (patch)
tree1d29680db03ab4f8a82f77630a6e1a9fc10571bb /valexpr.cc
parent961b30926b3b9f2b3e9c1a99df3f25fea6b13118 (diff)
downloadfork-ledger-162d982b0cf1a5ac2e67012a3b8eadae3c1ac59f.tar.gz
fork-ledger-162d982b0cf1a5ac2e67012a3b8eadae3c1ac59f.tar.bz2
fork-ledger-162d982b0cf1a5ac2e67012a3b8eadae3c1ac59f.zip
The --verify option is now working properly again. Use "--verify --verbose"
if you wish to see memory usage statistics along with a top-level trace.
Diffstat (limited to 'valexpr.cc')
-rw-r--r--valexpr.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/valexpr.cc b/valexpr.cc
index e4f0e430..6aa8986d 100644
--- a/valexpr.cc
+++ b/valexpr.cc
@@ -36,9 +36,6 @@
namespace ledger {
-value_expr amount_expr;
-value_expr total_expr;
-
namespace expr {
std::auto_ptr<symbol_scope_t> global_scope;
@@ -307,14 +304,14 @@ void op_t::compute(value_t& result, const details_t& details,
break;
case VALUE_EXPR:
- if (amount_expr.get())
- amount_expr->compute(result, details, context);
+ if (value_expr::amount_expr.get())
+ value_expr::amount_expr->compute(result, details, context);
else
result = 0L;
break;
case TOTAL_EXPR:
- if (total_expr.get())
- total_expr->compute(result, details, context);
+ if (value_expr::total_expr.get())
+ value_expr::total_expr->compute(result, details, context);
else
result = 0L;
break;
@@ -1080,8 +1077,20 @@ value_t op_t::calc(scope_t& scope)
} // namespace expr
-namespace {
- expr::parser_t value_expr_parser;
+std::auto_ptr<value_expr> value_expr::amount_expr;
+std::auto_ptr<value_expr> value_expr::total_expr;
+std::auto_ptr<expr::parser_t> value_expr::parser;
+
+void value_expr::initialize()
+{
+ parser.reset(new expr::parser_t);
+}
+
+void value_expr::shutdown()
+{
+ amount_expr.reset();
+ total_expr.reset();
+ parser.reset();
}
value_expr::value_expr(const string& _expr_str) : expr_str(_expr_str)
@@ -1089,7 +1098,7 @@ value_expr::value_expr(const string& _expr_str) : expr_str(_expr_str)
TRACE_CTOR(value_expr, "const string&");
if (! _expr_str.empty())
- ptr = value_expr_parser.parse(expr_str).ptr;
+ ptr = parser->parse(expr_str).ptr;
}
} // namespace ledger