2013-07-30 08:39:29 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include "context.h"
|
|
|
|
#include "exception.h"
|
|
|
|
|
|
|
|
namespace lean {
|
2013-09-07 18:11:45 +00:00
|
|
|
std::pair<context_entry const &, context> context::lookup_ext(unsigned i) const {
|
|
|
|
list<context_entry> const * it1 = &m_list;
|
2013-07-30 08:39:29 +00:00
|
|
|
while (*it1) {
|
|
|
|
if (i == 0)
|
2013-09-07 18:11:45 +00:00
|
|
|
return std::pair<context_entry const &, context>(head(*it1), context(tail(*it1)));
|
2013-08-14 21:42:48 +00:00
|
|
|
--i;
|
|
|
|
it1 = &tail(*it1);
|
|
|
|
}
|
|
|
|
throw exception("unknown free variable");
|
|
|
|
}
|
|
|
|
|
2013-09-07 18:11:45 +00:00
|
|
|
context_entry const & context::lookup(unsigned i) const {
|
|
|
|
list<context_entry> const * it1 = &m_list;
|
2013-08-14 21:42:48 +00:00
|
|
|
while (*it1) {
|
|
|
|
if (i == 0)
|
|
|
|
return head(*it1);
|
2013-07-30 08:39:29 +00:00
|
|
|
--i;
|
|
|
|
it1 = &tail(*it1);
|
|
|
|
}
|
|
|
|
throw exception("unknown free variable");
|
|
|
|
}
|
|
|
|
}
|