summaryrefslogtreecommitdiff
path: root/src/scope.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-13 05:02:14 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-13 05:02:14 -0400
commitea1642b3f969463a49e5a671478c92e4ef129665 (patch)
tree9eba47b8708123b4e3f539dd9d747f1f85d9d2fe /src/scope.cc
parentad3b30a9641b8e09c38ea76e7011b614152d8faf (diff)
downloadfork-ledger-ea1642b3f969463a49e5a671478c92e4ef129665.tar.gz
fork-ledger-ea1642b3f969463a49e5a671478c92e4ef129665.tar.bz2
fork-ledger-ea1642b3f969463a49e5a671478c92e4ef129665.zip
Completely reworked argument passing in expressions
Diffstat (limited to 'src/scope.cc')
-rw-r--r--src/scope.cc19
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