2014-05-31 04:05:47 +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
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <utility>
|
|
|
|
#include "util/lua.h"
|
|
|
|
#include "kernel/environment.h"
|
|
|
|
|
|
|
|
namespace lean {
|
2014-07-28 04:01:59 +00:00
|
|
|
/** \brief Add the alias \c a for \c e. */
|
2014-11-30 02:29:48 +00:00
|
|
|
environment add_expr_alias(environment const & env, name const & a, name const & e, bool overwrite = false);
|
2014-07-07 22:40:32 +00:00
|
|
|
/**
|
2014-07-28 04:01:59 +00:00
|
|
|
\brief Add alias \c a for \c e, and also add it to all parent scopes
|
2014-07-07 22:40:32 +00:00
|
|
|
until in a namespace scope.
|
|
|
|
*/
|
2014-11-30 02:29:48 +00:00
|
|
|
environment add_expr_alias_rec(environment const & env, name const & a, name const & e, bool overwrite = false);
|
2014-07-07 22:40:32 +00:00
|
|
|
|
2014-05-31 04:05:47 +00:00
|
|
|
/** \brief If \c t is aliased in \c env, then return its name. Otherwise, return none. */
|
2014-07-28 04:01:59 +00:00
|
|
|
optional<name> is_expr_aliased(environment const & env, name const & t);
|
2014-05-31 04:05:47 +00:00
|
|
|
|
2014-06-10 17:05:51 +00:00
|
|
|
/** \brief Return expressions associated with the given alias. */
|
2014-07-28 04:01:59 +00:00
|
|
|
list<name> get_expr_aliases(environment const & env, name const & n);
|
2014-06-12 19:29:04 +00:00
|
|
|
|
|
|
|
/**
|
2014-07-28 04:01:59 +00:00
|
|
|
\brief Add the alias \c a for level \c l. An error is generated if the new alias shadows
|
2014-06-12 19:29:04 +00:00
|
|
|
existing aliases and/or declarations. We don't have "choice" construct for universe
|
|
|
|
levels.
|
|
|
|
*/
|
2014-07-28 04:01:59 +00:00
|
|
|
environment add_level_alias(environment const & env, name const & a, name const & l);
|
2014-06-12 19:29:04 +00:00
|
|
|
|
|
|
|
/** \brief If \c l is aliased in \c env, then return its name. Otherwise, return none. */
|
2014-07-28 04:01:59 +00:00
|
|
|
optional<name> is_level_aliased(environment const & env, name const & l);
|
2014-06-12 19:29:04 +00:00
|
|
|
|
|
|
|
/** \brief Return the level associated with the given alias. */
|
2014-07-28 04:01:59 +00:00
|
|
|
optional<name> get_level_alias(environment const & env, name const & n);
|
2014-05-31 04:05:47 +00:00
|
|
|
|
2014-06-13 15:26:05 +00:00
|
|
|
/**
|
|
|
|
\brief Create an alias for each declaration named <tt>prefix.rest</tt>.
|
|
|
|
The alias for <tt>prefix.rest</tt> is <tt>new_prefix.rest</tt>.
|
|
|
|
|
|
|
|
The command will also create aliases for universe level declarations.
|
|
|
|
However, an error is thrown if the universe level shadows existing aliases and/or declarations.
|
|
|
|
We don't have "choice" construct for universe levels.
|
|
|
|
|
|
|
|
\remark \c new_prefix may be the anonymous name.
|
|
|
|
*/
|
|
|
|
environment add_aliases(environment const & env, name const & prefix, name const & new_prefix,
|
2014-11-30 02:29:48 +00:00
|
|
|
unsigned num_exceptions = 0, name const * exceptions = nullptr, bool overwrite = false);
|
|
|
|
inline environment overwrite_aliases(environment const & env, name const & prefix, name const & new_prefix) {
|
|
|
|
return add_aliases(env, prefix, new_prefix, 0, nullptr, true);
|
|
|
|
}
|
2014-06-13 15:26:05 +00:00
|
|
|
|
2014-09-04 01:37:01 +00:00
|
|
|
bool is_exception(name const & n, name const & prefix, unsigned num_exceptions, name const * exceptions);
|
|
|
|
|
2014-09-02 19:57:20 +00:00
|
|
|
void for_each_expr_alias(environment const & env, std::function<void(name const &, list<name> const &)> const & fn);
|
|
|
|
|
2014-05-31 04:05:47 +00:00
|
|
|
void open_aliases(lua_State * L);
|
2014-09-23 00:30:29 +00:00
|
|
|
void initialize_aliases();
|
|
|
|
void finalize_aliases();
|
2014-05-31 04:05:47 +00:00
|
|
|
}
|