void tag_delete::execute(context &ctx, std::ostream &out, const tag *caller) const { const string &collection = get_parameter(ctx, "collection"); if (collection.empty()) throw tag_delete_exception( _("query collection (collection) is not defined")); string db_ptr = ctx.get_value("@MONGODB:DATABASE@"); if (db_ptr.empty()) { throw tag_delete_exception( _("MongoDB database is not defined in the current context")); } database *db = (database*)from_string<void*>(db_ptr); ctx.enter(); try { BSONObjBuilder b; ctx.add_value("@MONGODB:PARAM@", to_string<BSONObjBuilder*>(&b)); // call inherited method tag_impl::execute(ctx, out, caller); db->remove(collection, b.obj()); } catch (...) { ctx.leave(); throw; } ctx.leave(); }
//ÊÖ„Ó pop void reset() { if(_n == 0) { _ctx_ptr = NULL; if(_ctx) { _ctx.reset(); } return; } if(_ctx_ptr == NULL) { _ctx_ptr = _ctx; } if(_n == 1) { duk_pop(_ctx_ptr); } else { duk_pop_n(_ctx_ptr,_n); } _n = 0; _ctx_ptr = NULL; if(_ctx) { _ctx.reset(); } }
//[reg id, reg value, taint]* [REG_INVALID_, 0, 0] void EmitRegisters(FILE *f, const CONTEXT *ctx, context &delta){ ADDRINT v, taint; int i, sz; //XXX: if you change order of these ids, you also need to change numbering //in motriage.ml, function: rid2reg REG regs[] = {LEVEL_BASE::REG_EAX, LEVEL_BASE::REG_EBX, LEVEL_BASE::REG_ECX, LEVEL_BASE::REG_EDX, LEVEL_BASE::REG_ESI, LEVEL_BASE::REG_EDI, LEVEL_BASE::REG_EBP, LEVEL_BASE::REG_ESP, LEVEL_BASE::REG_EFLAGS, LEVEL_BASE::REG_EIP}; context::iterator it; sz = sizeof(regs)/sizeof(regs[0]); write_u32(f, TAG_REGS); write_u32(f, sz); for(i=0;i<sz;i++){ REG r = regs[i]; v = PIN_GetContextReg(ctx, r); write_u32(f, i); //we don't use PIN's ids write_u32(f, v); it = delta.find(r); if(it != delta.end()){ taint = it->second; } else{ taint = 0; } write_u32(f, taint); fprintf(stderr, "%s v=0x%08x, t=0x%08x\n", REG_StringShort(r).c_str(), v, taint); } }
mk_unfold::mk_unfold(context& ctx): rule_transformer::plugin(100, false), m_ctx(ctx), m(ctx.get_manager()), rm(ctx.get_rule_manager()), m_unify(ctx) {}
HAMIGAKI_BJAM_DECL string_list native_rule(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); const std::string& module_name = args[0][0]; const std::string& rule_name = args[1][0]; typedef std::map<std::string,bjam::native_rule> table_type; typedef table_type::const_iterator iter_type; module& m = ctx.get_module(module_name); const table_type& table = m.native_rules; iter_type it = table.find(rule_name); if (it == table.end()) throw rule_not_found(rule_name); const bjam::native_rule& rule = it->second; rule_definition def; def.parameters = rule.parameters; def.native = rule.native; def.module_name = module_name; def.exported = true; m.rules.set_native_rule(rule_name, def); return string_list(); }
void checkbox_w::build( context &ctxt ) { const style &s = ctxt.get_style(); draw::paint c; platform::context &hwc = ctxt.hw_context(); gl::api &ogl = hwc.api(); _unchecked.rebuild( hwc ); _checked.rebuild( hwc ); c.set_fill_color( s.active_icon( s.background_color() ) ); _unchecked.add( ogl, draw::iconCheckBoxEmpty(), c ); c.set_fill_color( s.dominant_color() ); _checked.add( ogl, draw::iconCheckBoxChecked(), c ); size sz = s.widget_minimum_size(); auto native = ctxt.to_native( sz ); _unchecked.shape_size( native.w(), native.h() ); _checked.shape_size( native.w(), native.h() ); _unchecked.set_size( sz.w(), sz.h() ); _checked.set_size( sz.w(), sz.h() ); auto &l = layout_target(); l->set_minimum( sz ); l->set_maximum( sz ); }
HAMIGAKI_BJAM_DECL string_list import(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& src_module = ctx.get_module(args[0].try_front()); const string_list& src_rules = args[1]; const boost::optional<std::string>& tgt_module_name = args[2].try_front(); module& tgt_module = ctx.get_module(tgt_module_name); const string_list& tgt_rules = args[3]; const bool localize = !args[4].empty(); if (src_rules.size() != tgt_rules.size()) throw std::runtime_error("the count of rule names mismatch"); // FIXME for (std::size_t i = 0, size = src_rules.size(); i < size; ++i) { rule_definition def = src_module.rules.get_rule_definition(src_rules[i]); if (localize) def.module_name = tgt_module_name; def.exported = false; tgt_module.rules.set_rule_definition(tgt_rules[i], def); } return string_list(); }
mk_unbound_compressor::mk_unbound_compressor(context & ctx) : plugin(500), m_context(ctx), m_manager(ctx.get_manager()), m_rules(ctx.get_rule_manager()), m_pinned(m_manager) { }
void variability_feature_bundle_transform:: apply(const context& ctx, meta_model::model& m) { tracing::scoped_transform_tracer stp(lg, "variability feature bundle transform", transform_id, m.name().qualified().dot(), *ctx.tracer(), m); const auto& bundles(m.variability_elements().feature_bundles()); if (bundles.empty()) return; const auto& fm(*ctx.feature_model()); const auto fg(make_feature_group(fm)); for (auto& pair : bundles) { auto& fb(*pair.second); for (auto& ft : fb.feature_templates()) update(fg, ft); } if (m.variability_elements().feature_template_initializer() == nullptr) return; auto& fti(*m.variability_elements().feature_template_initializer()); for (auto& pair : bundles) { auto& fb(*pair.second); fti.bundles().push_back(fb.name()); } fti.bundles().sort(); stp.end_transform(m); }
aig_exporter::aig_exporter(const rule_set& rules, context& ctx, const fact_vector *facts) : m_rules(rules), m_facts(facts), m(ctx.get_manager()), m_rm(ctx.get_rule_manager()), m_aigm(m), m_next_decl_id(1), m_next_aig_expr_id(2), m_num_and_gates(0), m_latch_vars(m), m_latch_varsp(m), m_ruleid_var_set(m), m_ruleid_varp_set(m) { std::set<func_decl*> predicates; for (rule_set::decl2rules::iterator I = m_rules.begin_grouped_rules(), E = m_rules.end_grouped_rules(); I != E; ++I) { predicates.insert(I->m_key); } for (fact_vector::const_iterator I = facts->begin(), E = facts->end(); I != E; ++I) { predicates.insert(I->first); } // reserve pred id = 0 for initalization purposes unsigned num_preds = (unsigned)predicates.size() + 1; // poor's man round-up log2 unsigned preds_bitsize = log2(num_preds); if ((1U << preds_bitsize) < num_preds) ++preds_bitsize; SASSERT((1U << preds_bitsize) >= num_preds); for (unsigned i = 0; i < preds_bitsize; ++i) { m_ruleid_var_set.push_back(m.mk_fresh_const("rule_id", m.mk_bool_sort())); m_ruleid_varp_set.push_back(m.mk_fresh_const("rule_id_p", m.mk_bool_sort())); } }
void eit_section_filter::do_handle_section( context& c, const char* section_buffer, size_t section_length) { section s; s.unpack(section_buffer, section_length); event_information_table eit; s.convert(eit); if(s.header.table_id == 0x4E) //FIXME c.get_view().print( c.get_packet_num(), s.header, eit, subtable_is_changed(s.header, eit)); if(s.header.table_id == 0x4E && s.header.section_number == 0) { if(subtable_is_changed(s.header, eit)){ c.signal_eit(); } } // FIXME if(s.header.section_number == s.header.last_section_number) { version_ [s.header.table_id] [s.header.table_id_extension] [eit.transport_stream_id] [eit.original_network_id] = s.header.version; } }
void tag_database::execute(context &ctx, std::ostream &out, const tag *caller) const { const string &dsn = get_parameter(ctx, "dsn"); const string &database = get_parameter(ctx, "id"); if (dsn.empty()) { throw tag_database_exception( _("data source name (dsn) is not defined")); } string db_ptr = ctx.get_value(string("@SQLITE:DATABASE@") + database); if (!db_ptr.empty()) { tag_impl::execute(ctx, out, caller); return; } ctx.enter(); try { pool_ptr<sqlite_connection> c = database_pool::instance().acquire(dsn); if (!c->is_open()) c->open(dsn); // save the pointer to database for nested tags ctx.add_value(string("@SQLITE:DATABASE@") + get_parameter(ctx, "id"), to_string<sqlite3*>(c->get_ptr())); tag_impl::execute(ctx, out, caller); ctx.leave(); } catch (...) { ctx.leave(); throw; } }
void pat_section_filter::do_handle_section( context& c, const char* section_buffer, size_t section_length) { section s; s.unpack(section_buffer, section_length); program_association_table pat; s.convert<program_association_table>(pat); c.get_view().print( c.get_packet_num(), s.header, pat, last_version_ != s.header.version); if(last_version_ == s.header.version) return; c.pat = pat; for(auto& i : pat.association) { if(i.program_number != 0) { if(!c.is_opened(i.pmt_pid)) { c.open_section_filter( i.pmt_pid, std::unique_ptr<section_filter>( new pmt_section_filter())); } } } last_version_ = s.header.version; }
mk_magic_sets::mk_magic_sets(context & ctx, func_decl* goal) : plugin(10000, true), m_context(ctx), m(ctx.get_manager()), rm(ctx.get_rule_manager()), m_pinned(m), m_goal(goal, m) { }
/** * In case BOOST_COMPUTE_USE_OFFLINE_CACHE macro is defined, * the compiled binary is stored for reuse in the offline cache located in * $HOME/.boost_compute on UNIX-like systems and in %APPDATA%/boost_compute * on Windows. */ static program build_with_source( const std::string &source, const context &context, const std::string &options = std::string() ) { #ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE // Get hash string for the kernel. std::string hash; { device d(context.get_device()); platform p(d.get_info<cl_platform_id>(CL_DEVICE_PLATFORM)); std::ostringstream src; src << "// " << p.name() << " v" << p.version() << "\n" << "// " << context.get_device().name() << "\n" << "// " << options << "\n\n" << source; hash = detail::sha1(src.str()); } // Try to get cached program binaries: try { boost::optional<program> prog = load_program_binary(hash, context); if (prog) { prog->build(options); return *prog; } } catch (...) { // Something bad happened. Fallback to normal compilation. } // Cache is apparently not available. Just compile the sources. #endif const char *source_string = source.c_str(); cl_int error = 0; cl_program program_ = clCreateProgramWithSource(context, uint_(1), &source_string, 0, &error); if(!program_){ BOOST_THROW_EXCEPTION(runtime_exception(error)); } program prog(program_, false); prog.build(options); #ifdef BOOST_COMPUTE_USE_OFFLINE_CACHE // Save program binaries for future reuse. save_program_binary(hash, prog); #endif return prog; }
join_planner(context & ctx, rule_set & rs_aux_copy) : m_context(ctx), m(ctx.get_manager()), rm(ctx.get_rule_manager()), m_var_subst(ctx.get_var_subst()), m_rs_aux_copy(rs_aux_copy), m_introduced_rules(ctx.get_rule_manager()), m_pinned(ctx.get_manager()) { }
mk_coalesce::mk_coalesce(context& ctx): rule_transformer::plugin(50, false), m_ctx(ctx), m(ctx.get_manager()), rm(ctx.get_rule_manager()), m_sub1(m), m_sub2(m), m_idx(0) {}
transformer::transformer(const dynamic::workflow& w, context& c) : context_(c), identifier_parser_(new sml::identifier_parser(c.top_level_module_names(), c.model().name().external_module_path(), c.model().name().model_name())), dynamic_workflow_(w) { BOOST_LOG_SEV(lg, debug) << "Initial context: " << context_; }
HAMIGAKI_BJAM_DECL string_list update(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); string_list old = ctx.targets_to_update(); ctx.targets_to_update(args[0]); return old; }
coding::meta_model::model injection_model_to_coding_model_transform:: apply(const context& ctx, const injection::meta_model::model& m) { tracing::scoped_transform_tracer stp(lg, "injection model to coding model transform", transform_id, m.name(), *ctx.coding_context().tracer(), m); /* * First we compute the model name and technical space by reading * data from configuration. */ const auto& cfg(*m.configuration()); auto& gcfg(m.configuration()); const auto& fm(*ctx.coding_context().feature_model()); const auto fg(make_feature_group(fm)); const auto nc(make_naming_configuration(fg, cfg)); const auto model_location(create_location(nc)); coding::meta_model::model r; coding::helpers::name_builder b(true/*model_name_mode*/); b.external_modules(model_location.external_modules()); b.model_modules(model_location.model_modules()); r.name(b.build()); r.input_technical_space(to_technical_space(m.input_technical_space())); BOOST_LOG_SEV(lg, debug) << "Computed model name: " << r.name(); /* * Then we populate all model elements by adapting the injection * elements into coding elements. */ const helpers::adapter ad; for (const auto& e : m.elements()) { const auto l(e.in_global_module() ? empty_location : model_location); process_element(ad, l, e, r); } /* * Finally we handle the creation of the root module. This is done * separately from regular module processing due to the vagaries * of the root module: its not an element from an injection * perspective, etc. */ r.root_module(boost::make_shared<coding::meta_model::structural::module>()); auto& rm(*r.root_module()); rm.name(r.name()); rm.configuration(gcfg); rm.configuration()->name().qualified(rm.name().qualified().dot()); rm.is_root(true); helpers::stereotypes_helper h; const auto scr(h.from_string(m.stereotypes())); rm.dynamic_stereotypes(scr.dynamic_stereotypes()); rm.documentation(m.documentation()); insert(r.root_module(), r.structural_elements().modules()); stp.end_transform(r); return r; }
HAMIGAKI_BJAM_DECL string_list instance(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& instance_module = ctx.get_module(args[0][0]); instance_module.class_module = args[1][0]; return string_list(); }
void begin_frame(context& gc) { //glEnable(GL_CULL_FACE); //glCullFace(GL_FRONT); glDisable(GL_CULL_FACE); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float ofsx = -gc.screen_size().width_/2.0f; float ofsy = -gc.screen_size().height_/2.0f; if (rotate_ == -999.0f) { // first time rotate_ = gc.rotate(); ofsx_ = ofsx; ofsy_ = ofsy; } if (gc.rotate()- rotate_ > 180.0f) rotate_ += 360.0f; if (gc.rotate() - rotate_ < -180.0f) rotate_ -= 360.0f; rotate_ = rotate_ * 0.9f + gc.rotate() * 0.1f; ofsx_ = ofsx_ * 0.95f + ofsx * 0.05f; ofsy_ = ofsy_ * 0.95f + ofsy * 0.05f; //glOrthof(0.0f, (float)gc.screen_size_.width_, (float)gc.screen_size_.height_, 0.0f, -1.0f, 1.0f); float w = (float)gc.device_screen_size().width_; float h = (float)gc.device_screen_size().height_; glOrthof(-1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1000.0f); glScalef(2.0f/w, 2.0f/h, 1.0f); glRotatef(-rotate_, 0.0f,0.0f,1.0f); glTranslatef(ofsx_, ofsy_, 0.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); #if 0 { const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; const double a = t*90.0; glDisable(GL_DEPTH_TEST); glColor4d(1,1,1,1); glPushMatrix(); glTranslated(400.0,300.0,0.0); glRotated(60,1,0,0); glRotated(a,0,0,1); glutSolidSphere(100,16,16); glPopMatrix(); } #endif }
HAMIGAKI_BJAM_DECL string_list delete_module(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& m = ctx.get_module(args[0].try_front()); m.rules.clear(); m.variables.clear(); return string_list(); }
void checkbox_w::paint( context &ctxt ) { _checked.set_position( x(), y() ); _unchecked.set_position( x(), y() ); bool c = _state; if ( _tracking ) c = _current; if ( c ) _checked.draw( ctxt.hw_context() ); else _unchecked.draw( ctxt.hw_context() ); }
std::vector<msg_on_chan> get_all_msg_on_chan(context const&pb) { std::vector<msg_on_chan> result; for (;;) { msg_on_chan got(pb.get(), pb.get_channel()); if (got.message().empty() && got.channel().empty()) { break; } result.emplace_back(got); } return result; }
HAMIGAKI_BJAM_DECL string_list import_module(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); const string_list& imported = args[0]; module& tgt_module = ctx.get_module(args[1].try_front()); tgt_module.imported_modules.insert(imported.begin(), imported.end()); return string_list(); }
HAMIGAKI_BJAM_DECL string_list imported_modules(context& ctx) { frame& f = ctx.current_frame(); const list_of_list& args = f.arguments(); module& m = ctx.get_module(args[0].try_front()); return string_list( m.imported_modules.begin(), m.imported_modules.end() ); }
void final_call(context &ctx) { // Take ownership of state (if any), deleting it on return ownedobj_ptr<invocation_data> as(get_state_existing(ctx)); if (as) { // We have state ctx.result(finalfun(as->state)); } else { // There was no allocated state ctx.result(finalfun(state_zero)); } }
void dl_query_ask_ground_query(context & ctx, func_decl * pred, relation_fact & f, bool should_be_successful) { expr * const * q_args = reinterpret_cast<expr * const *>(f.c_ptr()); app * query = ctx.get_manager().mk_app(pred, q_args); lbool is_sat = ctx.query(query); std::cerr << "@@ query should succeed: " << should_be_successful << "\n"; SASSERT(is_sat != l_undef); if((is_sat != l_true) == should_be_successful) { std::cerr<<"wrong ground query answer!\n"; UNREACHABLE(); } }
mk_interp_tail_simplifier::mk_interp_tail_simplifier(context & ctx, unsigned priority) : plugin(priority), m(ctx.get_manager()), m_context(ctx), m_simp(ctx.get_rewriter()), a(m), m_rule_subst(ctx), m_tail(m), m_itail_members(m), m_conj(m) { m_cfg = alloc(normalizer_cfg, m); m_rw = alloc(normalizer_rw, m, *m_cfg); }