refactor(*): uses aliases for unordered_map and unordered_set

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-12-18 11:42:43 -08:00
parent 1e4fa76a47
commit 47c7bb1bde
13 changed files with 42 additions and 22 deletions

View file

@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <unordered_set>
#include <vector>
#include <utility>
#include <functional>
@ -14,7 +13,10 @@ Author: Leonardo de Moura
#include "util/exception.h"
#include "util/name_map.h"
#include "kernel/environment.h"
#include "kernel/expr_maps.h"
#include "kernel/expr_sets.h"
#include "library/expr_pair.h"
#include "library/expr_pair_maps.h"
#include "library/io_state.h"
#include "library/all/all.h"
#include "frontends/lean/operator_info.h"
@ -31,12 +33,12 @@ static std::vector<bool> g_empty_vector;
struct lean_extension : public environment_extension {
typedef std::pair<std::vector<bool>, name> implicit_info;
// Remark: only named objects are stored in the dictionary.
typedef name_map<operator_info> operator_table;
typedef name_map<implicit_info> implicit_table;
typedef std::unordered_map<expr, list<operator_info>, expr_hash, std::equal_to<expr>> expr_to_operators;
typedef std::unordered_map<expr_pair, expr, expr_pair_hash, expr_pair_eq> coercion_map;
typedef std::unordered_map<expr, list<expr_pair>, expr_hash, std::equal_to<expr>> expr_to_coercions;
typedef std::unordered_set<expr, expr_hash, std::equal_to<expr>> coercion_set;
typedef name_map<operator_info> operator_table;
typedef name_map<implicit_info> implicit_table;
typedef expr_struct_map<list<operator_info>> expr_to_operators;
typedef expr_pair_struct_map<expr> coercion_map;
typedef expr_struct_map<list<expr_pair>> expr_to_coercions;
typedef expr_struct_set coercion_set;
operator_table m_nud; // nud table for Pratt's parser
operator_table m_led; // led table for Pratt's parser

View file

@ -12,7 +12,6 @@ Author: Leonardo de Moura
#include <readline/readline.h>
#include <readline/history.h>
#endif
#include <unordered_map>
#include <utility>
#include <string>
#include <tuple>

View file

@ -8,8 +8,6 @@ Author: Leonardo de Moura
#include <algorithm>
#include <vector>
#include <tuple>
#include <set>
#include <unordered_map>
#include "util/thread.h"
#include "util/safe_arith.h"
#include "util/realpath.h"

View file

@ -8,7 +8,6 @@ Author: Leonardo de Moura
#include <iostream>
#include <memory>
#include <vector>
#include <unordered_map>
#include <set>
#include "util/lua.h"
#include "util/shared_mutex.h"

View file

@ -6,10 +6,11 @@ Author: Leonardo de Moura
*/
#pragma once
#include <unordered_map>
#include <functional>
#include "kernel/expr.h"
namespace lean {
// Maps based on pointer equality. That is, two keys are equal iff they are pointer equal
template<typename T>
using expr_map = typename std::unordered_map<expr, T, expr_hash_alloc, expr_eqp>;
@ -22,4 +23,7 @@ using expr_cell_map = typename std::unordered_map<expr_cell *, T, expr_cell_hash
template<typename T>
using expr_cell_offset_map = typename std::unordered_map<expr_cell_offset, T, expr_cell_offset_hash, expr_cell_offset_eqp>;
// Maps based on structural equality. That is, two keys are equal iff they are structurally equal
template<typename T>
using expr_struct_map = typename std::unordered_map<expr, T, expr_hash, std::equal_to<expr>>;
};

View file

@ -7,6 +7,7 @@ Author: Leonardo de Moura
#pragma once
#include <unordered_set>
#include <utility>
#include <functional>
#include "util/hash.h"
#include "kernel/expr.h"
@ -48,4 +49,7 @@ struct expr_cell_pair_eqp {
};
typedef std::unordered_set<expr_cell_pair, expr_cell_pair_hash, expr_cell_pair_eqp> expr_cell_pair_set;
// =======================================
// Similar to expr_set, but using structural equality
typedef std::unordered_set<expr, expr_hash, std::equal_to<expr>> expr_struct_set;
}

View file

@ -6,7 +6,6 @@ Author: Leonardo de Moura
*/
#include <algorithm>
#include <limits>
#include <unordered_map>
#include "util/list.h"
#include "util/flet.h"
#include "util/freset.h"
@ -15,6 +14,7 @@ Author: Leonardo de Moura
#include "util/sexpr/options.h"
#include "kernel/normalizer.h"
#include "kernel/expr.h"
#include "kernel/expr_maps.h"
#include "kernel/context.h"
#include "kernel/environment.h"
#include "kernel/builtin.h"
@ -73,7 +73,7 @@ closure const & to_closure(expr const & e) { lean_assert(is_closure(e)); retur
/** \brief Expression normalizer. */
class normalizer::imp {
typedef std::unordered_map<expr, expr, expr_hash_alloc, expr_eqp> cache;
typedef expr_map<expr> cache;
ro_environment::weak_ref m_env;
context m_ctx;

View file

@ -5,7 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include <unordered_map>
#include "kernel/expr_maps.h"
#include "kernel/replace_fn.h"
#include "kernel/context.h"
@ -21,7 +21,7 @@ namespace lean {
*/
class replace_visitor {
protected:
typedef std::unordered_map<expr, expr, expr_hash_alloc, expr_eqp> cache;
typedef expr_map<expr> cache;
cache m_cache;
context m_ctx;
expr save_result(expr const & e, expr && r, bool shared);

View file

@ -4,11 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <unordered_map>
#include "util/freset.h"
#include "util/flet.h"
#include "util/interrupt.h"
#include "kernel/type_checker.h"
#include "kernel/expr_maps.h"
#include "kernel/environment.h"
#include "kernel/kernel_exception.h"
#include "kernel/normalizer.h"
@ -21,7 +21,7 @@ namespace lean {
static name g_x_name("x");
/** \brief Auxiliary functional object used to implement infer_type. */
class type_checker::imp {
typedef std::unordered_map<expr, expr, expr_hash_alloc, expr_eqp> cache;
typedef expr_map<expr> cache;
typedef buffer<unification_constraint> unification_constraints;
ro_environment::weak_ref m_env;

View file

@ -0,0 +1,15 @@
/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include <unordered_map>
#include "kernel/expr.h"
#include "library/expr_pair.h"
namespace lean {
// Map based on structural equality
template<typename T>
using expr_pair_struct_map = std::unordered_map<expr_pair, T, expr_pair_hash, expr_pair_eq>;
}

View file

@ -4,7 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <unordered_map>
#include "util/name.h"
#include "util/sstream.h"
#include "util/name_map.h"

View file

@ -4,11 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include <unordered_map>
#include "util/flet.h"
#include "util/freset.h"
#include "util/interrupt.h"
#include "kernel/environment.h"
#include "kernel/expr_maps.h"
#include "kernel/normalizer.h"
#include "kernel/builtin.h"
#include "kernel/kernel_exception.h"
@ -22,7 +22,7 @@ Author: Leonardo de Moura
namespace lean {
static name g_x_name("x");
class type_inferer::imp {
typedef std::unordered_map<expr, expr, expr_hash_alloc, expr_eqp> cache;
typedef expr_map<expr> cache;
typedef buffer<unification_constraint> unification_constraints;
ro_environment m_env;

View file

@ -5,7 +5,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include <utility>
namespace lean {
/**
\brief Template for simulating "fluid-resets".