From ea1642b3f969463a49e5a671478c92e4ef129665 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 13 Jun 2010 05:02:14 -0400 Subject: Completely reworked argument passing in expressions --- src/scope.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/scope.cc') diff --git a/src/scope.cc b/src/scope.cc index faad352a..52cf6a90 100644 --- a/src/scope.cc +++ b/src/scope.cc @@ -71,4 +71,23 @@ expr_t::ptr_op_t symbol_scope_t::lookup(const symbol_t::kind_t kind, return child_scope_t::lookup(kind, name); } +value_t& call_scope_t::resolve(const std::size_t index, + value_t::type_t context, + const bool required) +{ + if (index >= args.size()) + throw_(calc_error, _("Too few arguments to function")); + + value_t& value(args[index]); + if (value.is_any()) { + context_scope_t scope(*this, context, required); + value = as_expr(value)->calc(scope); + if (required && ! value.is_type(context)) + throw_(calc_error, _("Expected %1 for argument %2, but received %3") + << value.label(context) << index + << value.label()); + } + return value; +} + } // namespace ledger -- cgit v1.2.3