Added new "addr" value expression function

It returns the address of the given object as an integer.  This can be
used to uniquely compare entities.
This commit is contained in:
John Wiegley 2010-06-03 05:37:21 -04:00
parent 30479c0e12
commit 3a0f096cb6
2 changed files with 12 additions and 0 deletions

View file

@ -218,6 +218,10 @@ namespace {
return true;
}
value_t get_addr(account_t& account) {
return long(&account);
}
value_t get_depth_spacer(account_t& account)
{
std::size_t depth = 0;
@ -296,6 +300,8 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
return WRAP_FUNCTOR(get_wrapper<&get_account>);
else if (name == "account_base")
return WRAP_FUNCTOR(get_wrapper<&get_account_base>);
else if (name == "addr")
return WRAP_FUNCTOR(get_wrapper<&get_addr>);
else if (name == "any")
return WRAP_FUNCTOR(&fn_any);
else if (name == "all")

View file

@ -323,6 +323,10 @@ namespace {
return item.pos ? long(item.pos->sequence) : 0L;
}
value_t get_addr(item_t& item) {
return long(&item);
}
value_t get_depth(item_t&) {
return 0L;
}
@ -376,6 +380,8 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind,
return WRAP_FUNCTOR(get_wrapper<&get_actual>);
else if (name == "actual_date")
return WRAP_FUNCTOR(get_wrapper<&get_actual_date>);
else if (name == "addr")
return WRAP_FUNCTOR(get_wrapper<&get_addr>);
break;
case 'b':