• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ environment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中environment的典型用法代码示例。如果您正苦于以下问题:C++ environment类的具体用法?C++ environment怎么用?C++ environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了environment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: get_rec_args

void get_rec_args(environment const & env, name const & n, buffer<buffer<bool>> & r) {
    lean_assert(inductive::is_inductive_decl(env, n));
    type_checker tc(env);
    name_generator ngen;
    declaration ind_decl   = env.get(n);
    declaration rec_decl   = env.get(inductive::get_elim_name(n));
    unsigned nparams       = *inductive::get_num_params(env, n);
    unsigned nminors       = *inductive::get_num_minor_premises(env, n);
    unsigned ntypeformers  = *inductive::get_num_type_formers(env, n);
    buffer<expr> rec_args;
    to_telescope(ngen, rec_decl.get_type(), rec_args);
    buffer<name> typeformer_names;
    for (unsigned i = nparams; i < nparams + ntypeformers; i++) {
        typeformer_names.push_back(mlocal_name(rec_args[i]));
    }
    lean_assert(typeformer_names.size() == ntypeformers);
    r.clear();
    // add minor premises
    for (unsigned i = nparams + ntypeformers; i < nparams + ntypeformers + nminors; i++) {
        r.push_back(buffer<bool>());
        buffer<bool> & bv = r.back();
        expr minor_type = mlocal_type(rec_args[i]);
        buffer<expr> minor_args;
        to_telescope(ngen, minor_type, minor_args);
        for (expr & minor_arg : minor_args) {
            buffer<expr> minor_arg_args;
            expr minor_arg_type = to_telescope(tc, mlocal_type(minor_arg), minor_arg_args);
            bv.push_back(is_typeformer_app(typeformer_names, minor_arg_type));
        }
    }
}
开发者ID:cpehle,项目名称:lean,代码行数:31,代码来源:util.cpp


示例2: environment_to_win32_strings

/** 
 * Converts an environment to a string used by CreateProcess(). 
 * 
 * Converts the environment's contents to the format used by the 
 * CreateProcess() system call. The returned char* string is 
 * allocated in dynamic memory; the caller must free it when not 
 * used any more. This is enforced by the use of a shared pointer. 
 * 
 * \return A dynamically allocated char* string that represents 
 *         the environment's content. This string is of the form 
 *         var1=value1\\0var2=value2\\0\\0. 
 */ 
inline boost::shared_array<char> environment_to_win32_strings(const environment &env) 
{ 
    boost::shared_array<char> envp; 

    if (env.empty()) 
    { 
        envp.reset(new char[2]); 
        ::ZeroMemory(envp.get(), 2); 
    } 
    else 
    { 
        std::string s; 
        for (environment::const_iterator it = env.begin(); it != env.end(); ++it) 
        { 
            s += it->first + "=" + it->second; 
            s.push_back(0); 
        } 

        envp.reset(new char[s.size() + 1]); 
#if defined(__CYGWIN__) || defined(_SCL_SECURE_NO_DEPRECATE) 
        ::memcpy(envp.get(), s.c_str(), s.size() + 1); 
#else 
        ::memcpy_s(envp.get(), s.size() + 1, s.c_str(), s.size() + 1); 
#endif 
    } 

    return envp; 
} 
开发者ID:Flusspferd,项目名称:flusspferd,代码行数:40,代码来源:win32_ops.hpp


示例3: write_field

void write_field(environment e, jobject obj, const char* name, T value)
{
  std::string descriptor;
  jvb::detail::descriptors::descriptor<T>
    (e, std::back_inserter(descriptor));
  jclass cls = e.raw()->GetObjectClass(obj);
  jfieldID fid = e.raw()->GetFieldID(cls, name, descriptor.c_str());
  assert(fid != 0);
  jvb::detail::set_field(e.raw(), obj, fid, value);
}
开发者ID:felipealmeida,项目名称:javabind,代码行数:10,代码来源:field.hpp


示例4: write_static_field

void write_static_field(environment e, jvb::class_ class_, const char* name, T value)
{
  std::string descriptor;
  jvb::detail::descriptors::descriptor<T>
    (e, std::back_inserter(descriptor));
  jclass cls = class_.raw();
  jfieldID fid = e.raw()->GetStaticFieldID(cls, name, descriptor.c_str());
  assert(fid != 0);
  jvb::detail::set_static_field(e.raw(), cls, fid, value);
}
开发者ID:felipealmeida,项目名称:javabind,代码行数:10,代码来源:field.hpp


示例5: read_static_field

T read_static_field(environment e, jvb::class_ class_, const char* name)
{
  std::string descriptor;
  jvb::detail::descriptors::descriptor<T>
    (e, std::back_inserter(descriptor));
  jclass cls = class_.raw();
  std::cout << "Searching for " << name << " with descriptor " << descriptor << std::endl;
  jfieldID fid = e.raw()->GetStaticFieldID(cls, name, descriptor.c_str());
  assert(fid != 0);
  return jvb::detail::get_static_field(e.raw(), cls, fid, jvb::detail::tag<T>());
}
开发者ID:felipealmeida,项目名称:javabind,代码行数:11,代码来源:field.hpp


示例6: environment_to_envp

/**
 * Converts an environment to a char** table as used by execve().
 *
 * Converts the environment's contents to the format used by the
 * execve() system call. The returned char** array is allocated
 * in dynamic memory; the caller must free it when not used any
 * more. Each entry is also allocated in dynamic memory and is a
 * NULL-terminated string of the form var=value; these must also be
 * released by the caller.
 *
 * This operation is only available on POSIX systems.
 *
 * \return The first argument of the pair is an integer that indicates
 *         how many strings are stored in the second argument. The
 *         second argument is a NULL-terminated, dynamically allocated
 *         array of dynamically allocated strings representing the
 *         enviroment's content. Each array entry is a NULL-terminated
 *         string of the form var=value. The caller is responsible for
 *         freeing them.
 */
inline std::pair<std::size_t, char **>
environment_to_envp(const environment
                    &env) {
  std::size_t nargs = env.size();
  char **envp = new char *[nargs + 1];
  environment::size_type i = 0;
  for (environment::const_iterator it = env.begin(); it != env.end(); ++it) {
    std::string s = it->first + "=" + it->second;
    envp[i] = new char[s.size() + 1];
    std::strncpy(envp[i], s.c_str(), s.size() + 1);
    ++i;
  }
  envp[i] = 0;
  return std::pair<std::size_t, char **>(nargs, envp);
} // environment_to_envp
开发者ID:SysFera,项目名称:libdadiCORBA,代码行数:35,代码来源:posix_helpers.hpp


示例7: action_unit

		void npc::action_unit(environment &current)
		{
			person::action_unit(current);

			point dest = current.player()->position();

			if (m_ai_state == ai_state::idle)
			{
				if (current.distance(dest, position()) <= alert_distance || !health().full())
				{
					m_ai_state = ai_state::alert;
					current.broadcast({ "!", 0xff0000, position(), 1.0 });
				}
			}
			else if (m_ai_state == ai_state::alert)
			{
				auto scene = current.scene();
				auto path = path::find(position(), dest, 50, [&](const point &p) { return scene->traversable(p); });
				if (path)
				{
					auto step = path->begin();
					if (step != path->end())
					{
						auto blocking = scene->blocking(*step);
						if (blocking && !blocking->invincible())
						{
							for (auto &skill : m_skills)
							{
								if (skill.targeted() && skill.useable(this, blocking))
								{
									skill.use(this, blocking);
									break;
								}
								else if (skill.useable(this, dest))
								{
									skill.use(this, dest);
									break;
								}
							}
						}
						else
						{
							scene->move(*this, *step);
						}
					}
				}
			}
		}
开发者ID:is0urce,项目名称:press-x-rail,代码行数:48,代码来源:npc.cpp


示例8: serialize_decl

json serialize_decl(name const & short_name, name const & long_name, environment const & env, options const & o) {
    declaration const & d = env.get(long_name);
    type_context_old tc(env);
    auto fmter = mk_pretty_formatter_factory()(env, o, tc);
    expr type = d.get_type();
    if (LEAN_COMPLETE_CONSUME_IMPLICIT) {
        while (true) {
            if (!is_pi(type))
                break;
            if (!binding_info(type).is_implicit() && !binding_info(type).is_inst_implicit())
                break;
            std::string q("?");
            q += binding_name(type).to_string();
            expr m = mk_constant(name(q.c_str()));
            type   = instantiate(binding_body(type), m);
        }
    }
    json completion;
    completion["text"] = short_name.to_string();
    interactive_report_type(env, o, type, completion);
    add_source_info(env, long_name, completion);
    if (auto doc = get_doc_string(env, long_name))
        completion["doc"] = *doc;
    return completion;
}
开发者ID:fpvandoorn,项目名称:lean,代码行数:25,代码来源:json.cpp


示例9: unwrap

inline jstring unwrap(environment e, const char* c)
{
  assert(c != 0);
  jstring str = e.raw()->NewStringUTF(c);
  assert(str != 0);
  return str;
}
开发者ID:felipealmeida,项目名称:javabind,代码行数:7,代码来源:unwrap.hpp


示例10: mk_op

static optional<pair<expr, expr>> mk_op(environment const & env, old_local_context & ctx, type_checker_ptr & tc,
                                        name const & op, unsigned nunivs, unsigned nargs, std::initializer_list<expr> const & explicit_args,
                                        constraint_seq & cs, tag g) {
    levels lvls;
    for (unsigned i = 0; i < nunivs; i++)
        lvls = levels(mk_meta_univ(mk_fresh_name()), lvls);
    expr c = mk_constant(op, lvls);
    expr op_type = instantiate_type_univ_params(env.get(op), lvls);
    buffer<expr> args;
    for (unsigned i = 0; i < nargs; i++) {
        if (!is_pi(op_type))
            return optional<pair<expr, expr>>();
        expr arg = ctx.mk_meta(some_expr(binding_domain(op_type)), g);
        args.push_back(arg);
        op_type  = instantiate(binding_body(op_type), arg);
    }
    expr r = mk_app(c, args, g);
    for (expr const & explicit_arg : explicit_args) {
        if (!is_pi(op_type))
            return optional<pair<expr, expr>>();
        r = mk_app(r, explicit_arg);
        expr type = tc->infer(explicit_arg, cs);
        justification j = mk_app_justification(r, op_type, explicit_arg, type);
        if (!tc->is_def_eq(binding_domain(op_type), type, j, cs))
            return optional<pair<expr, expr>>();
        op_type  = instantiate(binding_body(op_type), explicit_arg);
    }
    return some(mk_pair(r, op_type));
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:29,代码来源:calc_proof_elaborator.cpp


示例11: get_noncomputable_reason

optional<name> get_noncomputable_reason(environment const & env, name const & n) {
    declaration const & d = env.get(n);
    if (!d.is_definition())
        return optional<name>();
    type_checker tc(env);
    if (tc.is_prop(d.get_type()))
        return optional<name>(); // definition is a proposition, then do nothing
    expr const & v = d.get_value();
    auto ext = get_extension(env);
    bool ok  = true;
    /* quick check */
    for_each(v, [&](expr const & e, unsigned) {
            if (!ok) return false; // stop the search
            if (is_constant(e) && is_noncomputable(tc, ext, const_name(e))) {
                ok = false;
            }
            return true;
        });
    if (ok) {
        return optional<name>();
    }
    /* expensive check */
    try {
        get_noncomputable_reason_fn proc(tc);
        proc(v);
        return optional<name>();
    } catch (get_noncomputable_reason_fn::found & r) {
        return optional<name>(r.m_reason);
    }
}
开发者ID:avigad,项目名称:lean,代码行数:30,代码来源:noncomputable.cpp


示例12: apply

environment decl_attributes::apply(environment env, io_state const & ios, name const & d) const {
    if (m_is_instance) {
        if (m_priority) {
            #if defined(__GNUC__) && !defined(__CLANG__)
            #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
            #endif
            env = add_instance(env, d, *m_priority, m_persistent);
        } else {
            env = add_instance(env, d, m_persistent);
        }
    }
    if (m_is_trans_instance) {
        if (m_priority) {
            #if defined(__GNUC__) && !defined(__CLANG__)
            #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
            #endif
            env = add_trans_instance(env, d, *m_priority, m_persistent);
        } else {
            env = add_trans_instance(env, d, m_persistent);
        }
    }
    if (m_is_coercion)
        env = add_coercion(env, ios, d, m_persistent);
    auto decl = env.find(d);
    if (decl && decl->is_definition()) {
        if (m_is_reducible)
            env = set_reducible(env, d, reducible_status::Reducible, m_persistent);
        if (m_is_irreducible)
            env = set_reducible(env, d, reducible_status::Irreducible, m_persistent);
        if (m_is_semireducible)
            env = set_reducible(env, d, reducible_status::Semireducible, m_persistent);
        if (m_is_quasireducible)
            env = set_reducible(env, d, reducible_status::Quasireducible, m_persistent);
        if (m_unfold_hint)
            env = add_unfold_hint(env, d, m_unfold_hint, m_persistent);
        if (m_unfold_full_hint)
            env = add_unfold_full_hint(env, d, m_persistent);
    }
    if (m_constructor_hint)
        env = add_constructor_hint(env, d, m_persistent);
    if (m_symm)
        env = add_symm(env, d, m_persistent);
    if (m_refl)
        env = add_refl(env, d, m_persistent);
    if (m_trans)
        env = add_trans(env, d, m_persistent);
    if (m_subst)
        env = add_subst(env, d, m_persistent);
    if (m_recursor)
        env = add_user_recursor(env, d, m_recursor_major_pos, m_persistent);
    if (m_is_class)
        env = add_class(env, d, m_persistent);
    if (m_rewrite)
        env = add_rewrite_rule(env, d, m_persistent);
    if (m_has_multiple_instances)
        env = mark_multiple_instances(env, d, m_persistent);
    return env;
}
开发者ID:htzh,项目名称:lean,代码行数:58,代码来源:decl_attributes.cpp


示例13: extract_arg_types_core

static pair<expr, unsigned> extract_arg_types_core(environment const & env, name const & f, buffer<expr> & arg_types) {
    declaration d = env.get(f);
    expr f_type = d.get_type();
    while (is_pi(f_type)) {
        arg_types.push_back(binding_domain(f_type));
        f_type = binding_body(f_type);
    }
    return mk_pair(f_type, length(d.get_univ_params()));
}
开发者ID:codyroux,项目名称:lean,代码行数:9,代码来源:calc.cpp


示例14: mk_fresh_name

name mk_fresh_name(environment const & env, name const & prefix, char const * suffix, unsigned & idx) {
    while (true) {
        name curr(prefix, suffix);
        curr = curr.append_after(idx);
        idx++;
        if (!env.find(curr) && !is_vm_function(env, curr))
            return curr;
    }
}
开发者ID:sakas--,项目名称:lean,代码行数:9,代码来源:util.cpp


示例15: get_constructor_arity

unsigned get_constructor_arity(environment const & env, name const & n) {
    declaration d = env.get(n);
    expr e = d.get_type();
    unsigned r = 0;
    while (is_pi(e)) {
        r++;
        e = binding_body(e);
    }
    return r;
}
开发者ID:sakas--,项目名称:lean,代码行数:10,代码来源:util.cpp


示例16: find_id

 static jmethodID find_id(environment e, Class cls)
 {
   std::string descriptor;
   jvb::detail::descriptors::descriptor_function
     <void, typename boost::function_types::parameter_types<F>::type>
     (e, std::back_inserter(descriptor));
   jmethodID id = e.raw()->GetMethodID(cls.raw(), "<init>", descriptor.c_str());
   assert(id != 0);
   return id;
 }
开发者ID:felipealmeida,项目名称:javabind,代码行数:10,代码来源:constructors.hpp


示例17: get_undef_global

optional<name> get_undef_global(level const & l, environment const & env) {
    optional<name> r;
    for_each(l, [&](level const & l) {
            if (!has_global(l) || r)
                return false;
            if (is_global(l) && !env.is_universe(global_id(l)))
                r = global_id(l);
            return true;
        });
    return r;
}
开发者ID:pazthor,项目名称:lean,代码行数:11,代码来源:level.cpp


示例18: mk_fresh_name

static name mk_fresh_name(environment const & env, buffer<name> const & names, name const & s) {
    unsigned i = 1;
    name c = s;
    while (true) {
        if (!env.find(c) &&
            std::find(names.begin(), names.end(), c) == names.end())
            return c;
        c = s.append_after(i);
        i++;
    }
}
开发者ID:bmalehorn,项目名称:lean,代码行数:11,代码来源:projection.cpp


示例19: find_id

 static jmethodID find_id(environment e, jclass cls, const char* name)
 {
     typedef typename boost::function_types::result_type<F>::type return_type;
     typedef typename boost::function_types::parameter_types<F>::type parameter_types;
     std::string type;
     detail::descriptors::descriptor_function<return_type, parameter_types>
     (e, std::back_inserter<std::string>(type));
     assert(cls != 0);
     jmethodID id = e.raw()->GetStaticMethodID(cls, name, type.c_str());
     assert(id != 0);
     return id;
 }
开发者ID:felipealmeida,项目名称:javabind,代码行数:12,代码来源:static_method.hpp


示例20: get_max_height

static unsigned get_max_height(environment const & env, expr const & v) {
    unsigned h = 0;
    for_each(v, [&](expr const & e, unsigned) {
            if (is_constant(e)) {
                auto d = env.find(const_name(e));
                if (d && d->get_height() > h)
                    h = d->get_height();
            }
            return true;
        });
    return h;
}
开发者ID:GallagherCommaJack,项目名称:lean,代码行数:12,代码来源:declaration.cpp



注:本文中的environment类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ epicsGuard类代码示例发布时间:2022-05-31
下一篇:
C++ env_var_t类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap