static void emit_data_int(List *inits, int size, int off, int depth) { SAVE; Iter *iter = list_iter(inits); while (!iter_end(iter) && 0 < size) { Node *node = iter_next(iter); Node *v = node->initval; emit_padding(node, off); if (node->totype->bitsize > 0) { assert(node->totype->bitoff == 0); long data = eval_intexpr(v); Ctype *totype = node->totype; while (!iter_end(iter)) { node = iter_next(iter); if (node->totype->bitsize <= 0) { break; } v = node->initval; totype = node->totype; data |= ((((long)1 << totype->bitsize) - 1) & eval_intexpr(v)) << totype->bitoff; } emit_data_primtype(totype, &(Node){ AST_LITERAL, totype, .ival = data }); off += totype->size; size -= totype->size; if (iter_end(iter)) break; } else {
static void test_list(void) { List *list = make_list(); assert_int(0, list_len(list)); list_push(list, (void *)1); assert_int(1, list_len(list)); list_push(list, (void *)2); assert_int(2, list_len(list)); Iter *iter = list_iter(list); assert_int(1, (long)iter_next(iter)); assert_int(false, iter_end(iter)); assert_int(2, (long)iter_next(iter)); assert_int(true, iter_end(iter)); assert_int(0, (long)iter_next(iter)); assert_int(true, iter_end(iter)); List *copy = list_copy(list); assert_int(2, list_len(copy)); assert_int(1, (long)list_get(copy, 0)); assert_int(2, (long)list_get(copy, 1)); List *rev = list_reverse(list); iter = list_iter(rev); assert_int(2, (long)iter_next(iter)); assert_int(1, (long)iter_next(iter)); assert_int(0, (long)iter_next(iter)); assert_int(2, list_len(rev)); assert_int(1, (long)list_pop(rev)); assert_int(1, list_len(rev)); assert_int(2, (long)list_pop(rev)); assert_int(0, list_len(rev)); assert_int(0, (long)list_pop(rev)); List *list2 = make_list(); list_push(list2, (void *)5); list_push(list2, (void *)6); assert_int(5, (long)list_shift(list2)); assert_int(6, (long)list_shift(list2)); assert_int(0, (long)list_shift(list2)); List *list3 = make_list(); assert_int(0, (long)list_head(list3)); assert_int(0, (long)list_tail(list3)); list_push(list3, (void *)1); assert_int(1, (long)list_head(list3)); assert_int(1, (long)list_tail(list3)); list_push(list3, (void *)2); assert_int(1, (long)list_head(list3)); assert_int(2, (long)list_tail(list3)); List *list4 = make_list(); list_push(list4, (void *)1); list_push(list4, (void *)2); assert_int(1, (long)list_get(list4, 0)); assert_int(2, (long)list_get(list4, 1)); assert_int(0, (long)list_get(list4, 2)); }
static char *get_caller_list(void) { String *s = make_string(); for (Iter *i = list_iter(functions); !iter_end(i);) { string_appendf(s, "%s", iter_next(i)); if (!iter_end(i)) string_appendf(s, " -> "); } return get_cstring(s); }
void EntityCollisionMgr::Update() { // increase update counter ++updateCounter; // remove deleted entities for( int groupIdx = 0; groupIdx < m_groupCounter; ++groupIdx ) { vObject_t::iterator iter( m_vEntCollBody[groupIdx].begin() ); vObject_t::iterator iter_end( m_vEntCollBody[groupIdx].end() ); while( iter != iter_end ) { object_t* entCollBodyContainer = (*iter); // Remove marked for deletion if( entCollBodyContainer->IsMarkedForDeletion() ) { iter = m_vEntCollBody[groupIdx].erase( iter ); iter_end = m_vEntCollBody[groupIdx].end(); FreeObjectData( entCollBodyContainer ); } else { // next element ++iter; } } } // check collision for each group with the others for( int groupIdx = 0; groupIdx < m_groupCounter; ++groupIdx ) { for( int groupIdx2 = groupIdx+1; groupIdx2 < m_groupCounter; ++groupIdx2 ) { if( IsGroupCollides( groupIdx, groupIdx2 ) ) { vObject_t::iterator iter( m_vEntCollBody[groupIdx].begin() ); vObject_t::iterator iter_end( m_vEntCollBody[groupIdx].end() ); while( iter != iter_end ) { object_t* entCollBodyContainer = (*iter); if( entCollBodyContainer->GetData()->IsEnabled ) { _DoCollision( entCollBodyContainer, m_vEntCollBody[groupIdx2] ); } // next element ++iter; } } } } }
int TAO_Hash_LogRecordStore::purge_old_records (void) { CORBA::ULongLong num_records_to_purge = this->num_records_ * 5U / 100U; if (num_records_to_purge < 1) num_records_to_purge = 1; CORBA::ULong count = 0; // count of matches found. if (num_records_to_purge > 0 ) { // Create iterators LOG_RECORD_STORE_ITER iter (rec_map_.begin ()); LOG_RECORD_STORE_ITER iter_end (rec_map_.end ()); for (CORBA::ULongLong i = 0; iter != iter_end && i < num_records_to_purge; ++i) { this->remove_i (iter++); ++count; } } return count; }
CORBA::ULong TAO_Hash_LogRecordStore::set_records_attribute ( const char *grammar, const char *constraint, const DsLogAdmin::NVList &attr_list) { this->check_grammar (grammar); // TODO: validate attributes here. // Use an Interpreter to build an expression tree. TAO_Log_Constraint_Interpreter interpreter (constraint); // Create iterators LOG_RECORD_STORE_ITER iter (rec_map_.begin ()); LOG_RECORD_STORE_ITER iter_end (rec_map_.end ()); CORBA::ULong count = 0; // count of matches found. for ( ; iter != iter_end; ++iter) { // Use an evaluator. TAO_Log_Constraint_Visitor evaluator (iter->item ()); // Does it match the constraint? if (interpreter.evaluate (evaluator) == 1) { set_record_attribute (iter->item ().id, attr_list); ++count; } } return count; }
CORBA::ULong TAO_Hash_LogRecordStore::delete_records (const char *grammar, const char *constraint) { this->check_grammar (grammar); // Use an Interpreter to build an expression tree. TAO_Log_Constraint_Interpreter interpreter (constraint); // Create iterators LOG_RECORD_STORE_ITER iter (rec_map_.begin ()); LOG_RECORD_STORE_ITER iter_end (rec_map_.end ()); CORBA::ULong count = 0; // count of matches found. while (iter != iter_end) { // Use an evaluator. TAO_Log_Constraint_Visitor evaluator (iter->item ()); // Does it match the constraint? if (interpreter.evaluate (evaluator) == 1) { this->remove_i (iter++); ++count; } else { ++iter; } } return count; }
Variant ArrayData::next() { // We call iter_advance() without checking if m_pos is the canonical invalid // position. This is okay, since all IterAdvance() impls handle this // correctly, but it means that EmptyArray::IterAdvance() is reachable. setPosition(iter_advance(m_pos)); return m_pos != iter_end() ? getValue(m_pos) : Variant(false); }
CORBA::ULong TAO_Hash_LogRecordStore::remove_old_records (void) { if (this->max_record_life_ == 0) { return 0; } TimeBase::TimeT purge_time (ORBSVCS_Time::to_Absolute_TimeT ((ACE_OS::gettimeofday () - ACE_Time_Value(this->max_record_life_)))); // As there is no separate timestamp index, we must iterate through // the entire map. We can't be tempted to think timestamps will be // monotonically increasing with record id. // Create iterators LOG_RECORD_STORE_ITER iter (rec_map_.begin ()); LOG_RECORD_STORE_ITER iter_end (rec_map_.end ()); CORBA::ULong count = 0; // count of matches found. while (iter != iter_end) { // Does it match the constraint? if (iter->item().time < purge_time) { this->remove_i (iter++); ++count; } else { ++iter; } } return count; }
void lttng_ust_dl_update(void *ip) { struct dl_iterate_data data; if (getenv("LTTNG_UST_WITHOUT_BADDR_STATEDUMP")) return; /* * Fixup lttng-ust TLS when called from dlopen/dlclose * instrumentation. */ lttng_ust_fixup_tls(); data.exec_found = 0; data.first = true; data.cancel = false; /* * Iterate through the list of currently loaded shared objects and * generate tables entries for loadable segments using * extract_bin_info_events. * Removed libraries are detected by mark-and-sweep: marking is * done in the iteration over libraries, and sweeping is * performed by iter_end(). */ dl_iterate_phdr(extract_bin_info_events, &data); if (data.first) iter_begin(&data); iter_end(&data, ip); }
void cpp_eval(char *buf) { FILE *fp = fmemopen(buf, strlen(buf), "r"); set_input_file("(eval)", NULL, fp); List *toplevels = read_toplevels(); for (Iter *i = list_iter(toplevels); !iter_end(i);) emit_toplevel(iter_next(i)); }
void EntityCollisionMgr::_DoCollision( object_t* thisCollBodyContainer, const vObject_t& vEntCollBody ) { core::rectf thisRect = thisCollBodyContainer->GetData()->CollData + thisCollBodyContainer->GetData()->Owner->GetPhysicObject()->Position; // check always with entities after this one, previous were already checked vObject_t::const_iterator iter( vEntCollBody.begin() ); vObject_t::const_iterator iter_end( vEntCollBody.end() ); for( ; iter != iter_end; ++iter ) { object_t* otherCollBodyContainer = (*iter); if( ( otherCollBodyContainer->GetData()->IsEnabled ) && ( false == otherCollBodyContainer->IsMarkedForDeletion() ) && ( otherCollBodyContainer->GetData()->collCBFunc || thisCollBodyContainer->GetData()->collCBFunc ) && // at least one is not passive ( receive collision events ) ( otherCollBodyContainer->GetData()->Owner != thisCollBodyContainer->GetData()->Owner ) ) { core::rectf otherRect = otherCollBodyContainer->GetData()->CollData + otherCollBodyContainer->GetData()->Owner->GetPhysicObject()->Position; if( thisRect.isRectCollided( otherRect ) ) { thisCollBodyContainer->GetData()->lastCollisionUpdateCounter = updateCounter; otherCollBodyContainer->GetData()->lastCollisionUpdateCounter = updateCounter; if( thisCollBodyContainer->GetData()->collCBFunc ) { thisCollBodyContainer->GetData()->collCBFunc( thisCollBodyContainer->GetData(), otherCollBodyContainer->GetData() ); } if( otherCollBodyContainer->GetData()->collCBFunc ) { otherCollBodyContainer->GetData()->collCBFunc( otherCollBodyContainer->GetData(), thisCollBodyContainer->GetData() ); } } } } }
ArrayData *ArrayData::pop(Variant &value) { if (!empty()) { ssize_t pos = iter_end(); value = getValue(pos); return remove(getKey(pos), getCount() > 1); } value = null; return NULL; }
static void set_reg_nums(List *args) { numgp = numfp = 0; for (Iter *i = list_iter(args); !iter_end(i);) { Node *arg = iter_next(i); if (is_flotype(arg->ctype)) numfp++; else numgp++; } }
void RenderQueue::Add( RenderQueue* queue ) { DrawablesVector::iterator iter( queue->m_children.begin() ); DrawablesVector::iterator iter_end( queue->m_children.end() ); for( ; iter != iter_end; ++iter ) { m_children.push_back( *iter ); } queue->m_children.clear(); delete queue; }
Variant ArrayData::prev() { // We only call iter_rewind() if m_pos is not the canonical invalid position. // Thus, EmptyArray::IterRewind() is not reachable. auto pos_limit = iter_end(); if (m_pos != pos_limit) { setPosition(iter_rewind(m_pos)); if (m_pos != pos_limit) { return getValue(m_pos); } } return Variant(false); }
static void emit_args(List *vals) { SAVE; Iter *iter = list_iter(vals); while (!iter_end(iter)) { Node *v = iter_next(iter); emit_expr(v); if (is_flotype(v->ctype)) push_xmm(0); else push("rax"); } }
static void classify_args(List *ints, List *floats, List *rest, List *args) { SAVE; int ireg = 0, xreg = 0; int imax = 6, xmax = 8; Iter *iter = list_iter(args); while (!iter_end(iter)) { Node *v = iter_next(iter); if (is_flotype(v->ctype)) list_push((xreg++ < xmax) ? floats : rest, v); else list_push((ireg++ < imax) ? ints : rest, v); } }
static void emit_decl_init(List *inits, int off) { Iter *iter = list_iter(inits); while (!iter_end(iter)) { Node *node = iter_next(iter); assert(node->type == AST_INIT); if (node->initval->type == AST_LITERAL && node->totype->bitsize <= 0) { emit_save_literal(node->initval, node->totype, node->initoff + off); } else { emit_expr(node->initval); emit_lsave(node->totype, node->initoff + off); } } }
Variant ArrayData::each() { if (m_pos != iter_end()) { ArrayInit ret(4, ArrayInit::Mixed{}); Variant key(getKey(m_pos)); Variant value(getValue(m_pos)); ret.set(1, value); ret.set(s_value, value); ret.set(0, key); ret.set(s_key, key); setPosition(iter_advance(m_pos)); return ret.toVariant(); } return Variant(false); }
void start_find_select(void*) { RandomChoice choice(/*rand_,*/ size()); for(iter_rewind(); !iter_end(); iter_inc(), ++choice) { if(choice.choose()) { iter_get(find_s_, find_p_, find_o_); iter_free(); timer_->set_timer<App, &App::start_find>(1000, this, 0); return; } ++choice; } debug_->debug("!fnd %d %d", (int)choice.elements, (int)choice.current); }
DsLogAdmin::RecordList* TAO_Hash_LogRecordStore::query_i (const char *constraint, DsLogAdmin::Iterator_out &iter_out, CORBA::ULong how_many) { // Use an Interpreter to build an expression tree. TAO_Log_Constraint_Interpreter interpreter (constraint); // Sequentially iterate over all the records and pick the ones that // meet the constraints. // Allocate the list of <how_many> length. DsLogAdmin::RecordList* rec_list; ACE_NEW_THROW_EX (rec_list, DsLogAdmin::RecordList (how_many), CORBA::NO_MEMORY ()); rec_list->length(how_many); // Create iterators LOG_RECORD_STORE_ITER iter (rec_map_.begin ()); LOG_RECORD_STORE_ITER iter_end (rec_map_.end ()); CORBA::ULong count = 0; // count of matches found. for ( ; ((iter != iter_end) && (count < how_many)); ++iter) { // Use an evaluator. TAO_Log_Constraint_Visitor evaluator (iter->item ()); // Does it match the constraint? if (interpreter.evaluate (evaluator) == 1) { if (TAO_debug_level > 0) { ORBSVCS_DEBUG ((LM_DEBUG,"Matched constraint! d = %Q, Time = %Q\n", iter->item ().id, iter->item ().time)); } (*rec_list)[count] = iter->item (); // copy the log record. ++count; } } rec_list->length (count); if (iter != iter_end) // There are more records to process. { // Create an iterator to pass out. TAO_Hash_Iterator_i *iter_query = 0; ACE_NEW_THROW_EX (iter_query, TAO_Hash_Iterator_i (this->iterator_poa_.in (), this->reactor_, this, iter, iter_end, count, constraint, this->max_rec_list_len_), CORBA::NO_MEMORY ()); // Transfer ownership to the POA. PortableServer::ServantBase_var safe_iter_query = iter_query; // Activate it. PortableServer::ObjectId_var oid = this->iterator_poa_->activate_object (iter_query); CORBA::Object_var obj = this->iterator_poa_->id_to_reference (oid.in ()); // Narrow it iter_out = DsLogAdmin::Iterator::_narrow (obj.in ()); } return rec_list; }
Variant ArrayData::end() { setPosition(iter_last()); return m_pos != iter_end() ? getValue(m_pos) : Variant(false); }
Variant ArrayData::key() const { return m_pos != iter_end() ? getKey(m_pos) : uninit_null(); }
static void emit_compound_stmt(Node *node) { SAVE; for (Iter *i = list_iter(node->stmts); !iter_end(i);) emit_expr(iter_next(i)); }
List *list_copy(List *list) { List *r = make_list(); for (Iter *i = list_iter(list); !iter_end(i);) list_push(r, iter_next(i)); return r; }
Variant ArrayData::value(int32_t &pos) const { return pos != iter_end() ? getValue(pos) : Variant(false); }
Variant ArrayData::current() const { return m_pos != iter_end() ? getValue(m_pos) : Variant(false); }
void list_append(List *a, List *b) { for (Iter *i = list_iter(b); !iter_end(i);) list_push(a, iter_next(i)); }
List *list_reverse(List *list) { List *r = make_list(); for (Iter *i = list_iter(list); !iter_end(i);) list_unshift(r, iter_next(i)); return r; }