2014-07-08 17:55:49 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include "library/head_map.h"
|
2015-03-14 01:58:34 +00:00
|
|
|
#include "library/explicit.h"
|
2014-07-08 17:55:49 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
head_index::head_index(expr const & e) {
|
2015-03-14 01:58:34 +00:00
|
|
|
expr f = get_app_fn(e);
|
|
|
|
while (true) {
|
2015-05-29 21:51:28 +00:00
|
|
|
if (is_as_atomic(f))
|
|
|
|
f = get_app_fn(get_as_atomic_arg(f));
|
|
|
|
else if (is_explicit(f))
|
2015-03-14 01:58:34 +00:00
|
|
|
f = get_explicit_arg(f);
|
|
|
|
else if (is_consume_args(f))
|
|
|
|
f = get_consume_args_arg(f);
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2014-07-08 17:55:49 +00:00
|
|
|
m_kind = f.kind();
|
|
|
|
if (is_constant(f))
|
|
|
|
m_const_name = const_name(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
int head_index::cmp::operator()(head_index const & i1, head_index const & i2) const {
|
|
|
|
if (i1.m_kind != i2.m_kind || i1.m_kind != expr_kind::Constant)
|
|
|
|
return static_cast<int>(i1.m_kind) - static_cast<int>(i2.m_kind);
|
|
|
|
else
|
|
|
|
return quick_cmp(i1.m_const_name, i2.m_const_name);
|
|
|
|
}
|
|
|
|
}
|