2014-07-04 21:25:44 +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 "util/name.h"
|
|
|
|
#include "util/list.h"
|
|
|
|
#include "kernel/environment.h"
|
|
|
|
#include "frontends/lean/cmd_table.h"
|
|
|
|
|
|
|
|
namespace lean {
|
2014-09-02 22:03:33 +00:00
|
|
|
/** \brief Add a new 'class' to the environment (if it is not already declared) */
|
2014-09-19 19:42:22 +00:00
|
|
|
environment add_class(environment const & env, name const & n, bool persistent = true);
|
2014-09-28 19:20:42 +00:00
|
|
|
/** \brief Add a new 'class instance' to the environment with default priority. */
|
2014-09-19 19:42:22 +00:00
|
|
|
environment add_instance(environment const & env, name const & n, bool persistent = true);
|
2014-09-28 19:20:42 +00:00
|
|
|
/** \brief Add a new 'class instance' to the environment. */
|
|
|
|
environment add_instance(environment const & env, name const & n, unsigned priority, bool persistent);
|
2014-07-05 01:49:05 +00:00
|
|
|
/** \brief Return true iff \c c was declared with \c add_class . */
|
|
|
|
bool is_class(environment const & env, name const & c);
|
2014-07-04 21:25:44 +00:00
|
|
|
/** \brief Return the instances of the given class. */
|
|
|
|
list<name> get_class_instances(environment const & env, name const & c);
|
2014-07-08 21:28:33 +00:00
|
|
|
name get_class_name(environment const & env, expr const & e);
|
2014-09-28 19:20:42 +00:00
|
|
|
/** \brief Parse priority for an class instance */
|
|
|
|
optional<unsigned> parse_instance_priority(parser & p);
|
2014-07-04 21:25:44 +00:00
|
|
|
void register_class_cmds(cmd_table & r);
|
2014-09-10 18:19:14 +00:00
|
|
|
|
|
|
|
/** \brief Return true iff \c type is a class or Pi that produces a class. */
|
2014-09-25 19:26:09 +00:00
|
|
|
optional<name> is_ext_class(type_checker & tc, expr const & type);
|
2014-09-10 18:19:14 +00:00
|
|
|
|
|
|
|
/** \brief Return a list of instances of the class \c cls_name that occur in \c ctx */
|
|
|
|
list<expr> get_local_instances(type_checker & tc, list<expr> const & ctx, name const & cls_name);
|
2014-09-23 00:30:29 +00:00
|
|
|
|
|
|
|
void initialize_class();
|
|
|
|
void finalize_class();
|
2014-07-04 21:25:44 +00:00
|
|
|
}
|