diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-13 15:04:53 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-13 15:04:53 -0400 |
commit | 0c699e4d57fe91fa04c4c2f23f9c2f2a6a5da582 (patch) | |
tree | 985c50c080c077fa931ed9bf01c3895cbb851eda /src/scope.cc | |
parent | 40f553228f5a28034c6635fdcb4c86af28a385ed (diff) | |
parent | cf0147fcd04fc7ec4b3849350430e47169581e64 (diff) | |
download | fork-ledger-0c699e4d57fe91fa04c4c2f23f9c2f2a6a5da582.tar.gz fork-ledger-0c699e4d57fe91fa04c4c2f23f9c2f2a6a5da582.tar.bz2 fork-ledger-0c699e4d57fe91fa04c4c2f23f9c2f2a6a5da582.zip |
Merge branch 'next'
Diffstat (limited to 'src/scope.cc')
-rw-r--r-- | src/scope.cc | 19 |
1 files changed, 19 insertions, 0 deletions
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 |