list<expr> get_coercions_from_to(type_checker & from_tc, type_checker & to_tc,
                                 expr const & from_type, expr const & to_type, constraint_seq & cs, bool lift_coe) {
    constraint_seq new_cs;
    environment const & env = to_tc.env();
    expr whnf_from_type = from_tc.whnf(from_type, new_cs);
    expr whnf_to_type   = to_tc.whnf(to_type, new_cs);
    if (lift_coe && is_pi(whnf_from_type)) {
        // Try to lift coercions.
        // The idea is to convert a coercion from A to B, into a coercion from D->A to D->B
        if (!is_pi(whnf_to_type))
            return list<expr>(); // failed
        if (!from_tc.is_def_eq(binding_domain(whnf_from_type), binding_domain(whnf_to_type), justification(), new_cs))
            return list<expr>(); // failed, the domains must be definitionally equal
        expr x = mk_local(mk_fresh_name(), "x", binding_domain(whnf_from_type), binder_info());
        expr A = instantiate(binding_body(whnf_from_type), x);
        expr B = instantiate(binding_body(whnf_to_type), x);
        list<expr> coe = get_coercions_from_to(from_tc, to_tc, A, B, new_cs, lift_coe);
        if (coe) {
            cs += new_cs;
            // Remark: each coercion c in coe is a function from A to B
            // We create a new list: (fun (f : D -> A) (x : D), c (f x))
            expr f = mk_local(mk_fresh_name(), "f", whnf_from_type, binder_info());
            expr fx = mk_app(f, x);
            return map(coe, [&](expr const & c) { return Fun(f, Fun(x, mk_app(c, fx))); });
        } else {
            return list<expr>();
        }
    } else {
        expr const & fn   = get_app_fn(whnf_to_type);
        list<expr> r;
        if (is_constant(fn)) {
            r = get_coercions(env, whnf_from_type, const_name(fn));
        } else if (is_pi(whnf_to_type)) {
            r = get_coercions_to_fun(env, whnf_from_type);
        } else if (is_sort(whnf_to_type)) {
            r = get_coercions_to_sort(env, whnf_from_type);
        }
        if (r)
            cs += new_cs;
        return r;
    }
}
Example #2
0
std::unique_ptr<FitFunction>
FitFunctionFactoryImplementation<Kernel, DataTagList>::create_function( const fit_window::Plane& data, bool mle )
{
    assert(data.has_per_pixel_background || use_background);
    std::unique_ptr<FitFunction> result;
    boost::mpl::for_each< DataTagList >( 
        boost::bind( instantiate(),
                     _1, boost::ref(*this), boost::ref(data), mle, boost::ref(result) ) );
    assert(result);
    return result;
}
Example #3
0
int main(int
#ifdef BOOST_FLOAT128_C
   argc
#endif
   , char*[])
{
#ifdef BOOST_FLOAT128_C
   if(argc > 1000)
      instantiate(BOOST_FLOAT128_C(1.23));
#endif
}
Example #4
0
    pointer pop() {
        check_for_unused_instances();
        if (unused_instances_.empty()) {
            unused_instances_.emplace(instantiate());
        }

        auto instance = unused_instances_.front();
        using_instances_.emplace_back(instance);
        unused_instances_.pop();
        return instance;
    }
Example #5
0
bool is_ceqv(tmp_type_context & tctx, expr e) {
    if (has_expr_metavar(e))
        return false;
    name_set to_find;
    // Define a procedure for removing arguments from to_find.
    auto visitor_fn = [&](expr const & e, unsigned) {
        if (is_local(e)) {
            to_find.erase(mlocal_name(e));
            return false;
        } else if (is_metavar(e)) {
            return false;
        } else {
            return true;
        }
    };
    environment const & env = tctx.env();
    bool is_std = is_standard(env);
    buffer<expr> hypotheses; // arguments that are propositions
    while (is_pi(e)) {
        if (!to_find.empty()) {
            // Support for dependent types.
            // We may find the instantiation for the previous arguments
            // by matching the type.
            for_each(binding_domain(e), visitor_fn);
        }
        expr local = tctx.mk_tmp_local(binding_domain(e));
        if (binding_info(e).is_inst_implicit()) {
            // If the argument can be instantiated by type class resolution, then
            // we don't need to find it in the lhs
        } else if (is_std && tctx.is_prop(binding_domain(e))) {
            // If the argument is a proposition, we store it in hypotheses.
            // We check whether the lhs occurs in hypotheses or not.
            hypotheses.push_back(binding_domain(e));
        } else {
            to_find.insert(mlocal_name(local));
        }
        e = instantiate(binding_body(e), local);
    }
    expr lhs, rhs;
    if (!is_simp_relation(env, e, lhs, rhs))
        return false;
    // traverse lhs, and remove found variables from to_find
    for_each(lhs, visitor_fn);
    if (!to_find.empty())
        return false;
    // basic looping ceq detection: the left-hand-side should not occur in the right-hand-side,
    // nor it should occur in any of the hypothesis
    if (occurs(lhs, rhs))
        return false;
    if (std::any_of(hypotheses.begin(), hypotheses.end(), [&](expr const & h) { return occurs(lhs, h); }))
        return false;
    return true;
}
Example #6
0
bool ranking_synthesis_satt::generate_functions(void)
{
  exprt templ = instantiate();

  if(body.variable_map.size()==0 || templ.is_false())
    return false;

  // some coefficient values
  c_valuest c_values;

  debug("Template:" + from_expr(ns, "", templ));

  satcheckt::resultt result=satcheckt::P_SATISFIABLE;

  while(result==satcheckt::P_SATISFIABLE)
  {
    if(c_values.size()==0)
      initialize_coefficients(c_values);
    else
    {
      if(increase_coefficients(c_values))
        break;
    }

    result=check_for_counterexample(templ, c_values,
                                    conversion_time, solver_time);
  }

  if(result==satcheckt::P_ERROR)
    throw ("Solver error.");
  else if(result==satcheckt::P_UNSATISFIABLE) // no counter-example
  {
    debug("Found ranking functions");

    // put the coefficient values in the rank relation
    replace_mapt replace_map;

    for(c_valuest::const_iterator it=c_values.begin();
        it!=c_values.end();
        it++)
    {
      replace_map[it->first] = from_integer(it->second, it->first.type());
    }

    replace_expr(replace_map, rank_relation);
    simplify(rank_relation, ns);

    return true;
  }
  else
    return false;
}
Example #7
0
// meta_constant level.instantiate : level → list (name × level) → list level
vm_obj level_instantiate(vm_obj const & o, vm_obj const & lst) {
    level const & l = to_level(o);
    buffer<name> ns;
    buffer<level> ls;
    vm_obj it = lst;
    while (!is_simple(it)) {
        vm_obj const & h = cfield(it, 0);
        ns.push_back(to_name(cfield(h, 0)));
        ls.push_back(to_level(cfield(h, 1)));
        it = cfield(it, 1);
    }
    return to_obj(instantiate(l, to_list(ns), to_list(ls)));
}
Example #8
0
optional<name> defeq_canonizer::get_head_symbol(expr type) {
    type    = m_ctx.whnf(type);
    expr const & fn = get_app_fn(type);
    if (is_constant(fn)) {
        return optional<name>(const_name(fn));
    } else if (is_pi(type)) {
        type_context::tmp_locals locals(m_ctx);
        expr l = locals.push_local_from_binding(type);
        return get_head_symbol(instantiate(binding_body(type), l));
    } else {
        return optional<name>();
    }
}
Example #9
0
void simulator_ctt::execute_assume(
  statet &state,
  const program_formulat::formula_goto_programt::instructiont &instruction)
{
  formulat condition=
    instantiate(state, 0, instruction.guard);
    
  if(condition.is_true()) return;

  // just add it to the guard
  state.data_w().guard=
    formula_container.gen_and(state.data_w().guard, condition);
}
Example #10
0
/// Applies a set of templates to an input file and writes an output file.
///
/// \param templates The templates to use.
/// \param input_file The path to the input to process.
/// \param output_file The path to the file into which to write the output.
///
/// \throw text::error If the input or output files cannot be opened.
/// \throw text::syntax_error If there is any problem processing the input.
void
text::instantiate(const templates_def& templates,
                  const fs::path& input_file, const fs::path& output_file)
{
    std::ifstream input(input_file.c_str());
    if (!input)
        throw text::error(F("Failed to open %s for read") % input_file);

    std::ofstream output(output_file.c_str());
    if (!output)
        throw text::error(F("Failed to open %s for write") % output_file);

    instantiate(templates, input, output);
}
Example #11
0
void tst_instantiate(ast_manager & m, expr * f) {
    if (is_quantifier(f)) {
        tst_instantiate(m, to_quantifier(f)->get_expr());
        return;
    }
    quantifier * q = find_quantifier(f);
    if (q) {
        expr_ref_vector cnsts(m);
        for (unsigned i = 0; i < q->get_num_decls(); i++) 
            cnsts.push_back(m.mk_fresh_const("a", q->get_decl_sort(i)));
        expr_ref r(m);
        instantiate(m, q, cnsts.c_ptr(), r);
        TRACE("var_subst", tout << "quantifier:\n" << mk_pp(q, m) << "\nresult:\n" << mk_pp(r, m) << "\n";);
    }
Example #12
0
void simulator_ctt::execute_assign(
  statet &state,
  const program_formulat::formula_goto_programt::instructiont &instruction)
{
  statet new_state(state);
  
  new_state.detatch();

  for(program_formulat::assignst::const_iterator
      it=instruction.code.assigns.begin();
      it!=instruction.code.assigns.end();
      it++)
    if(it->in_use)
    {
      assert(it->variable<program_formula.variables.size());

      new_state.data_w().set_var(
        it->variable,
        0,
        instantiate(state, 0, it->value));
    }
  
  // do constraint
  formulat instantiated_constraint=
    instantiate(
      state,
      new_state,
      0,
      instruction.code.constraint);

  new_state.data_w().guard=
    formula_container.gen_and(
      state.data_w().guard,
      instantiated_constraint);
  
  state.swap(new_state);
}
Example #13
0
//==============================================================================
ArrowShape::ArrowShape(const Eigen::Vector3d& _tail,
                       const Eigen::Vector3d& _head,
                       const Properties& _properties,
                       const Eigen::Vector4d& _color,
                       std::size_t _resolution)
  : MeshShape(Eigen::Vector3d::Ones(), nullptr),
    mTail(_tail),
    mHead(_head),
    mProperties(_properties)
{
  instantiate(_resolution);
  configureArrow(mTail, mHead, mProperties);
  setColorMode(MeshShape::COLOR_INDEX);
  notifyColorUpdated(_color);
}
    ImageStackDatasource* ImageStackDatasourceFactory::instantiate(AlgebraicParameterSet* paramSet)
    {
        for(auto it = protoTypes.rbegin(); it != protoTypes.rend(); ++it)
        {
            auto dataSource = it->second.get();
            if(dataSource->canHandleResource(paramSet))
            {
                LOGGER("Chosen ImageStackDatasource: " << dataSource->getName() << ".");
                return dataSource->instantiate(paramSet);
            }
        }

        std::string filename = paramSet->get<InputParameterSet>()->getProjectionsPath().string();
        throw Exception("Unable to open image stack " + filename + "! Incorrect filename or plugin missing?");
    }
Example #15
0
void Java_java_lang_Class_newInstance(void)
{
    INSTANCE_CLASS currentClass = getFP()->thisMethod->ofClass;
    CLASS clazz = topStackAsType(CLASS);

    if (IS_ARRAY_CLASS(clazz)
        || ((clazz->accessFlags & (ACC_INTERFACE | ACC_ABSTRACT)) != 0)) {
        raiseException("java/lang/InstantiationException");
        return;
    }

    if (classHasAccessToClass(currentClass, clazz)) {
        METHOD method = lookupMethod(clazz, initNameAndType, currentClass);
        if (   (method != NULL)
            && (method->ofClass == (INSTANCE_CLASS)clazz)
               /* I don't understand why, but we're not allowed access to
                * a protected <init> method of a superclass. */
            && classHasAccessToMember(currentClass, 
                   (method->accessFlags & ~ACC_PROTECTED),
                   (INSTANCE_CLASS)clazz, (INSTANCE_CLASS)clazz)

            )
        {
            START_TEMPORARY_ROOTS
                DECLARE_TEMPORARY_ROOT(INSTANCE, object,
                                       instantiate((INSTANCE_CLASS)clazz));
                if (object != NULL) {
                    /*  Put the result back on the stack */
                    topStackAsType(INSTANCE) = object; /* Will get the result */
                    /* We now need to call the initializer.  We'd like to just
                     * push a second copy of the object onto the stack, and then
                     * do pushFrame(method).  But we can't, because that would
                     * not necessarily coincide with the stack map of the
                     * current method.
                     */
                    pushFrame(RunCustomCodeMethod);
                    pushStackAsType(CustomCodeCallbackFunction,
                                    newInstanceReturnObject);
                    pushStackAsType(INSTANCE, object);
                    /* pushFrame may signal a stack overflow.  */
                    pushFrame(method);
                } else {
                    /* We will already have thrown an appropriate error */
                }
            END_TEMPORARY_ROOTS
            return;
        }
    }
Example #16
0
   void CPU::throwException(VirtualContext& context, const String& exceptionname, const String& reason)
   {
      VirtualClass& klass = context.resolveClass(exceptionname);
      VirtualObject& exception = instantiate(context, klass, -1);
      String callstack = buildCallStack();

      exception.getMember(0).setString(context.mStringCache.lookup(reason));
      exception.getMember(1).setString(context.mStringCache.lookup(callstack));

      if ( !handleException(context, exception) )
      {
         String msg = UTEXT("Unhandled exception '") + klass.getName() + UTEXT("'\n") + callstack;
         std::string m = msg.toUtf8();
         Log::getInstance().error(m.c_str());
      }
   }
Example #17
0
formulat simulator_baset::instantiate(
  const state_dt &current,
  const state_dt *next,
  unsigned t,
  formulat formula)
{
  if(formula.is_null()) return formula;

  switch(formula.id())
  {
  case formula_nodet::CONST_TRUE:
  case formula_nodet::CONST_FALSE:
    return formula;

  case formula_nodet::VARIABLE:
    return current.get_var(formula.variable(), t);

  case formula_nodet::NEXT_VARIABLE:
    assert(next!=NULL);
    return next->get_var(formula.variable(), t);
    
  case formula_nodet::NOT:
    return formula_container.gen_not(
      instantiate(current, next, t, formula.a()));

  case formula_nodet::AND:
    return formula_container.gen_and(
      instantiate(current, next, t, formula.a()),
      instantiate(current, next, t, formula.b()));

  case formula_nodet::OR:
    return formula_container.gen_or(
      instantiate(current, next, t, formula.a()),
      instantiate(current, next, t, formula.b()));

  case formula_nodet::NONDET:
  case formula_nodet::IFF:
  case formula_nodet::XOR:
    return formula_container.new_node(
      formula.id(),
      instantiate(current, next, t, formula.a()),
      instantiate(current, next, t, formula.b()));

  default:
    assert(false);
  }
  
  assert(false);
  return formulat(NULL);
}
void demolitions_system::advance_cascade_explosions(const logic_step step) {
	auto& cosm = step.get_cosmos();
	const auto& clk = cosm.get_clock();

	cosm.for_each_having<components::cascade_explosion>(
		[&](const auto it) {
			const auto& cascade_def = it.template get<invariants::cascade_explosion>();
			auto& cascade = it.template get<components::cascade_explosion>();

			auto& when_next = cascade.when_next_explosion;

			if (clk.now >= when_next) {
				auto rng = cosm.get_nontemporal_rng_for(it);

				{
					const auto next_explosion_in_ms = rng.randval(cascade_def.explosion_interval_ms);
					when_next = clk.now;
					when_next.step += next_explosion_in_ms / clk.dt.in_milliseconds();
				}

				{
					const auto angle_displacement = rng.randval_h(cascade_def.max_explosion_angle_displacement);
					const auto& body = it.template get<components::rigid_body>();

					auto vel = body.get_velocity();
					vel.rotate(angle_displacement, vec2());
					body.set_velocity(vel);
				}

				auto expl_in = cascade_def.explosion;
				expl_in *= rng.randval_vm(1.f, cascade_def.explosion_scale_variation);

				expl_in.instantiate(
					step,
					it.get_logic_transform(),
					damage_cause(it)
				);

				--cascade.explosions_left;

				if (0 == cascade.explosions_left) {
					step.queue_deletion_of(it, "Cascade explosions exhausted");
				}
			}
		}
	);
}
Example #19
0
tactic intros_tactic(list<name> _ns, bool relax_main_opaque) {
    auto fn = [=](environment const & env, io_state const &, proof_state const & s) {
        list<name> ns    = _ns;
        goals const & gs = s.get_goals();
        if (empty(gs)) {
            throw_no_goal_if_enabled(s);
            return optional<proof_state>();
        }
        goal const & g      = head(gs);
        name_generator ngen = s.get_ngen();
        auto tc             = mk_type_checker(env, ngen.mk_child(), relax_main_opaque);
        expr t              = g.get_type();
        expr m              = g.get_meta();
        bool gen_names      = empty(ns);
        try {
            while (true) {
                if (!gen_names && is_nil(ns))
                    break;
                if (!is_pi(t)) {
                    if (!is_nil(ns)) {
                        t = tc->ensure_pi(t).first;
                    } else {
                        expr new_t = tc->whnf(t).first;
                        if (!is_pi(new_t))
                            break;
                        t = new_t;
                    }
                }
                name new_name;
                if (!is_nil(ns)) {
                    new_name = head(ns);
                    ns       = tail(ns);
                } else {
                    new_name = get_unused_name(binding_name(t), m);
                }
                expr new_local = mk_local(ngen.next(), new_name, binding_domain(t), binding_info(t));
                t              = instantiate(binding_body(t), new_local);
                m              = mk_app(m, new_local);
            }
            goal new_g(m, t);
            return some(proof_state(s, goals(new_g, tail(gs)), ngen));
        } catch (exception &) {
            return optional<proof_state>();
        }
    };
    return tactic01(fn);
}
Example #20
0
void AssemblyItem::slot_instantiate()
{
    const string instance_name_suggestion =
        make_unique_name(
            string(m_assembly.get_name()) + "_inst",
            m_parent.assembly_instances());

    const string instance_name =
        get_entity_name_dialog(
            treeWidget(),
            "Instantiate Assembly",
            "Assembly Instance Name:",
            instance_name_suggestion);

    if (!instance_name.empty())
        instantiate(instance_name);
}
Example #21
0
 expr pack(unsigned i, unsigned arity, buffer<expr> const & args, expr const & type) {
     lean_assert(arity > 0);
     if (i == arity - 1) {
         return args[i];
     } else {
         lean_assert(is_constant(get_app_fn(type), get_psigma_name()));
         expr a        = args[i];
         expr A        = app_arg(app_fn(type));
         expr B        = app_arg(type);
         lean_assert(is_lambda(B));
         expr new_type = instantiate(binding_body(B), a);
         expr b        = pack(i+1, arity, args, new_type);
         bool mask[2]  = {true, true};
         expr AB[2]    = {A, B};
         return mk_app(mk_app(m_ctx, get_psigma_mk_name(), 2, mask, AB), a, b);
     }
 }
Example #22
0
environment mk_rec_on(environment const & env, name const & n) {
    if (!inductive::is_inductive_decl(env, n))
        throw exception(sstream() << "error in 'rec_on' generation, '" << n << "' is not an inductive datatype");
    name rec_on_name(n, "rec_on");
    name_generator ngen;
    declaration rec_decl = env.get(inductive::get_elim_name(n));

    buffer<expr> locals;
    expr rec_type = rec_decl.get_type();
    while (is_pi(rec_type)) {
        expr local = mk_local(ngen.next(), binding_name(rec_type), binding_domain(rec_type), binding_info(rec_type));
        rec_type   = instantiate(binding_body(rec_type), local);
        locals.push_back(local);
    }

    // locals order
    //   A C minor_premises indices major-premise

    // new_locals order
    //   A C indices major-premise minor-premises
    buffer<expr> new_locals;
    unsigned idx_major_sz = *inductive::get_num_indices(env, n) + 1;
    unsigned minor_sz     = *inductive::get_num_minor_premises(env, n);
    unsigned AC_sz        = locals.size() - minor_sz - idx_major_sz;
    for (unsigned i = 0; i < AC_sz; i++)
        new_locals.push_back(locals[i]);
    for (unsigned i = 0; i < idx_major_sz; i++)
        new_locals.push_back(locals[AC_sz + minor_sz + i]);
    unsigned rec_on_major_idx = new_locals.size() - 1;
    for (unsigned i = 0; i < minor_sz; i++)
        new_locals.push_back(locals[AC_sz + i]);
    expr rec_on_type = Pi(new_locals, rec_type);

    levels ls = param_names_to_levels(rec_decl.get_univ_params());
    expr rec  = mk_constant(rec_decl.get_name(), ls);
    expr rec_on_val = Fun(new_locals, mk_app(rec, locals));

    bool use_conv_opt = true;
    environment new_env = module::add(env,
                                      check(env, mk_definition(env, rec_on_name, rec_decl.get_univ_params(),
                                                               rec_on_type, rec_on_val, use_conv_opt)));
    new_env = set_reducible(new_env, rec_on_name, reducible_status::Reducible);
    new_env = add_unfold_hint(new_env, rec_on_name, rec_on_major_idx);
    new_env = add_aux_recursor(new_env, rec_on_name);
    return add_protected(new_env, rec_on_name);
}
ENS_API_EXPORT OMX_ERRORTYPE NmfHost_ProcessingComponent::construct() {
    OMX_ERRORTYPE error;

#ifndef HOST_ONLY
    CM_REGISTER_STUBS_SKELS(ens_cpp);
#endif //#ifndef HOST_ONLY

	// trace stuff
	// create ExtraZone if needed
	error = mENSComponent.getTraceBuilder()->createExtraZone(mENSComponent.getNMFDomainHandle());
    if (error != OMX_ErrorNone) return error;

	setTraceInfo(mENSComponent.getSharedTraceInfoPtr(), mENSComponent.getPortCount()); 

    error = instantiate();
    if (error != OMX_ErrorNone) return error;

    error = start();
    if (error != OMX_ErrorNone) return error;

    error = configure();
    if (error != OMX_ErrorNone) return error;

    // Initialize NMF component state machine (ports + component)
	fsmInit_t init = {0,0,0,0};
    init.portsDisabled = 0;
    for (OMX_U32 i =0 ; i< mENSComponent.getPortCount(); i++) {
        if(!(mENSComponent.getPort(i)->isEnabled())){
            init.portsDisabled |= 1 << i;
        }
    }

	init.portsTunneled = 0;
	for (OMX_U32 i =0 ; i< mENSComponent.getPortCount(); i++) {
		if(mENSComponent.getPort(i)->getTunneledComponent()){
			init.portsTunneled |= 1 << i;
		}
	}

	init.traceInfoAddr = mENSComponent.getSharedTraceInfoPtr();
	
	mIfsmInit.fsmInit(init);

	return OMX_ErrorNone;
}
Example #24
0
bool ranking_synthesis_seneschalt::generate_functions(void)
{
  #if 0
  std::cout << "GENERATE: " << templ << std::endl;
  #endif


  if(instantiate()==nil_exprt())
    return false;

  std::cout << "INPUT IS: " << std::endl;
  system("cat seneschal.input");

  status("Calling seneschal...");
  fine_timet before = current_time();
  system(">seneschal.out ; >seneschal.err; "
         "seneschal seneschal.input 1> seneschal.out 2> seneschal.err");
  solver_time += current_time()-before;
  solver_calls++;


	{
		std::cout << "STDOUT WAS: " << std::endl;
		system("cat seneschal.out");
		std::cout << "STDERR WAS: " << std::endl;
		system("cat seneschal.err");
	}

	exprt rf("nil");
	if(!read_output(rf)) throw ("SENESCHAL ERROR");

//  remove("seneschal.input");
//  remove("seneschal.err");
//  remove("seneschal.out");

  if(rf.id()!="nil")
  {
    if(!extract_ranking_relation(rf))
      return false;

    return true;
  }
  else
    return false;
}
void SP::SP_Driver::computePattern(double _totalLength) {
  totalLength = _totalLength;


  if (!hasRelWeight) {
    /* In this case we only repeat the first star seen, all the other are
     * merely removed. We adapt the repetitions so that it matches the total
     * length
     */
     computeAbsPattern();
  }

  else
    optimizeCoordinate(repetitions.size()-1);

  instantiate();
  computeFinalVectors();
}
Example #26
0
    /* If type of d is a proposition or return a type, we don't need to compile it.
       We can just generate (fun args, neutral_expr)

       This procedure returns true if type of d is a proposition or return a type,
       and store the dummy code above in */
    bool compile_irrelevant(declaration const & d, buffer<procedure> & procs) {
        type_context ctx(m_env, transparency_mode::All);
        expr type = d.get_type();
        type_context::tmp_locals locals(ctx);
        while (true) {
            type = ctx.relaxed_whnf(type);
            if (!is_pi(type))
                break;
            expr local = locals.push_local_from_binding(type);
            type       = instantiate(binding_body(type), local);
        }
        if (ctx.is_prop(type) || is_sort(type)) {
            expr r = locals.mk_lambda(mk_neutral_expr());
            procs.emplace_back(d.get_name(), optional<pos_info>(), r);
            return true;
        } else {
            return false;
        }
    }
Example #27
0
IngameController::IngameController() {
    view = new IngameView(this);
    //Init Systems
    eventSys = new EventsSystem();
    collSys = new CollisionSystem();
    physicsSys = new PhysicsSystem();
    scriptSys = new ScriptSystem();
    //Init Entities
    thePlayer = new Player(this);
    time.Zero;

    //La manière la plus dégeulasse de faire un spawner, mais pas le time !
    instantiate(new EnemyFactory(this, 1.f, 2.f), sf::Vector2f(660.f, 70.f), sf::Vector2i(-1, 0));


    //entities.insert(new Enemy(this));

    subController = nullptr;
}
Example #28
0
static int nfct_parse_ct(nfct_msg *ctmsg, struct nlmsghdr *nlh)
{
    struct nfgenmsg *nfmsg = (struct nfgenmsg *)NLMSG_DATA(nlh);
    conn_entry *e;
    struct nlattr *nla;
    int len;

    if(! instantiate(e))
        return 0;
    BZERO(e);
    e->l3num = nfmsg->nfgen_family;
    nla = (struct nlattr *)((char *)NLMSG_DATA(nlh) + NLMSG_ALIGN(sizeof(struct nfgenmsg)));
    len = NLMSG_PAYLOAD(nlh, sizeof(struct nfgenmsg));
    nla_parse(e->nla, CTA_MAX, nla, len);
    if(e->nla[CTA_STATUS])
        e->status = ntohl(nla_get_be32(e->nla[CTA_STATUS]));
    ctmsg->entry = e;
    return 0;
}
Example #29
0
static struct dentry *proc_lookupfd_common(struct inode *dir,
					   struct dentry *dentry,
					   instantiate_t instantiate)
{
	struct task_struct *task = get_proc_task(dir);
	struct dentry *result = ERR_PTR(-ENOENT);
	unsigned fd = name_to_int(dentry);

	if (!task)
		goto out_no_task;
	if (fd == ~0U)
		goto out;

	result = instantiate(dir, dentry, task, (void *)(unsigned long)fd);
out:
	put_task_struct(task);
out_no_task:
	return result;
}
Example #30
0
void simulator_ctt::execute_functioncall(
  const statet &state,
  edget &edge)
{
  const program_formulat::formula_goto_programt::instructiont
    &instruction=*state.data().threads.front().PC;
  const irep_idt &function_id=instruction.code.function;
  
  // find in program formula
  program_formulat::function_mapt::const_iterator
    f_it=program_formula.function_map.find(function_id);

  assert(f_it!=program_formula.function_map.end());
  
  const program_formulat::functiont &f=f_it->second;

  // produce a start state
  
  statet start_state(state);
  statet::threadt &thread=start_state.data_w().threads.back();
  
  // adjust PC
  thread.program=&(f.body);
  thread.PC=thread.start_pc();
  
  // assign args
  assert(instruction.code.function_args.size()==f.args.size());
  
  for(unsigned i=0; i<f.args.size(); i++)
  {
    formulat formula=instruction.code.function_args[i];
    formula=instantiate(state, 0, formula);
    start_state.data_w().set_var(f.args[i], 0, formula);
  }

  std::cout << "Adding edge for " << function_id << std::endl;
  
  // add edge
  edget &f_edge=new_edge(function_id, start_state);
  
  f_edge.calls.push_back(conft(edge, state));
}