uint ImplicitExceptionTable::at( uint exec_off ) const { uint l = len(); for( uint i=0; i<l; i++ ) if( *adr(i) == exec_off ) return *(adr(i)+1); return 0; // Failed to find any execption offset }
void ImplicitExceptionTable::verify(nmethod *nm) const { for (uint i = 0; i < len(); i++) { if ((*adr(i) > (unsigned int)nm->code_size()) || (*(adr(i)+1) > (unsigned int)nm->code_size())) fatal1("Invalid offset in ImplicitExceptionTable at %lx", _data); } }
void ImplicitExceptionTable::append( uint exec_off, uint cont_off ) { assert( (sizeof(implicit_null_entry) >= 4) || (exec_off < 65535), "" ); assert( (sizeof(implicit_null_entry) >= 4) || (cont_off < 65535), "" ); uint l = len(); if (l == _size) { uint old_size_in_elements = _size*2; if (_size == 0) _size = 4; _size *= 2; uint new_size_in_elements = _size*2; _data = REALLOC_RESOURCE_ARRAY(uint, _data, old_size_in_elements, new_size_in_elements); } *(adr(l) ) = exec_off; *(adr(l)+1) = cont_off; _len = l+1; };
void vlaalign(int size) { char __attribute__((aligned(16))) tmp[size+32]; char tmp2[size+16]; adr(tmp); }
void Assembler::adr(const Register& rd, Label* label) { // Flush the instruction buffer if necessary before getting an offset. // Note that ADR is not a branch, but it encodes an offset like a branch. BufferOffset offset = Emit(0); Instruction* ins = getInstructionAt(offset); // Encode the relative offset. adr(ins, rd, LinkAndGetByteOffsetTo(offset, label)); }
void GRSimSender::sendPacket(int robotID, RobotCommandPacket rawPacket) { ParameterManager* pm = ParameterManager::getInstance(); grSim_Packet grSimPacket; grSimPacket.mutable_commands()->set_isteamyellow((ourColor==Yellow)); grSimPacket.mutable_commands()->set_timestamp(0.0); grSim_Robot_Command* command = grSimPacket.mutable_commands()->add_robot_commands(); command->set_id(robotID); double max_lin_vel = 0.01; // you should set this parameter command->set_wheel1(rawPacket.getWheelSpeed(4)/max_lin_vel); command->set_wheel2(rawPacket.getWheelSpeed(3)/max_lin_vel); command->set_wheel3(rawPacket.getWheelSpeed(2)/max_lin_vel); command->set_wheel4(rawPacket.getWheelSpeed(1)/max_lin_vel); command->set_wheelsspeed(true); if(rawPacket.byWheelSpeed){ command->set_wheelsspeed(true); } else { double d_sign = (rawPacket.getVelocity().Y() >= 0)? 1:-1; command->set_velnormal(rawPacket.getVelocity().lenght2D() * -d_sign / max_lin_vel); command->set_veltangent(tan(M_PI_2 + atan2(rawPacket.getVelocity().Y(), rawPacket.getVelocity().X()))); command->set_velangular(rawPacket.getVelocity().Teta()); // command->set_velnormal(rawPacket.getVelocity().X()); // command->set_veltangent(rawPacket.getVelocity().Y()); // command->set_velangular(0); // qDebug() << rawPacket.getVelocity().X() << " " << rawPacket.getVelocity().Y() << " " << rawPacket.getVelocity().Teta(); } // dangerous test /* command->set_velnormal(-2); command->set_veltangent(0); command->set_velangular(0);*/ command->set_kickspeedx(rawPacket.m_kickPower); command->set_kickspeedz(0); // chip kick command->set_spinner((rawPacket.m_isDribbler)? 1:0); if(connected) { std::string s; grSimPacket.SerializeToString(&s); // Net::Address multiaddr; // multiaddr.setHost(pm->get<string>("network.GRSIM_COMMAND_ADDRESS").c_str(), // pm->get<int>("network.GRSIM_COMMAND_PORT")); QHostAddress adr(pm->get<string>("network.GRSIM_COMMAND_ADDRESS").c_str()); quint16 port =pm->get<int>("network.GRSIM_COMMAND_PORT"); this->writeDatagram(s.c_str(),s.length(),adr,port); //this->send(s.c_str(), s.length(), multiaddr); } }
int run(cpu *pcpu) { char byte; pcpu->fl = CPU_CLEAN; if ((byte = get_byte(pcpu->ip)) < 0) { pcpu->fl = CPU_ERROR; pcpu->ip++; return -1; } //printf("Cel id-> %d, byte : 0x%x, at IP: %s\n",pcpu->pcel->id ,byte, decodificar(get_byte(pcpu->ip))); //show_regs(pcpu,0); switch(byte) { case 0X00 : nop0(pcpu); break; case 0X01 : nop1(pcpu); break; case 0X02 : pushax(pcpu); break; case 0X03 : pushbx(pcpu); break; case 0X04 : pushcx(pcpu); break; case 0X05 : pushdx(pcpu); break; case 0X06 : popax(pcpu); break; case 0X07 : popbx(pcpu); break; case 0X08 : popcx(pcpu); break; case 0X09 : popdx(pcpu); break; case 0X0a : movcd(pcpu); break; case 0X0b : movab(pcpu); break; case 0X0c : movii(pcpu); break; case 0X0d : sub_ab(pcpu); break; case 0X0e : sub_ac(pcpu); break; case 0X0f : inc_a(pcpu); break; case 0X10 : inc_b(pcpu); break; case 0X11 : dec_c(pcpu); break; case 0X12 : inc_c(pcpu); break; case 0X13 : zero(pcpu); break; case 0X14 : not0(pcpu); break; case 0X15 : shl(pcpu); break; case 0X16 : ifz(pcpu); break; case 0X17 : jmp(pcpu); break; case 0X18 : jmpb(pcpu); break; case 0X19 : call(pcpu); break; case 0X1a : ret(pcpu); break; case 0X1b : adr(pcpu); break; case 0X1c : adrb(pcpu); break; case 0x1d : adrf(pcpu); break; case 0X1e : mal(pcpu); break; case 0X1f : divide(pcpu); break; //default:printf("CPU: Instruccion No Encontrada!\n");break; } return 0; }
void MonitorExitStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); if (_compute_lock) { // lock_reg was destroyed by fast unlocking attempt => recompute it ce->monitor_address(_monitor_ix, _lock_reg); } ce->store_parameter(_lock_reg->as_register(), 0); // note: non-blocking leaf routine => no call info needed Runtime1::StubID exit_id; if (ce->compilation()->has_fpu_code()) { exit_id = Runtime1::monitorexit_id; } else { exit_id = Runtime1::monitorexit_nofpu_id; } __ adr(lr, _continuation); __ far_jump(RuntimeAddress(Runtime1::entry_for(exit_id))); }
void KraftView::slotNewAddress( const Addressee& contact, bool interactive ) { Addressee adr( contact ); if( contact.isEmpty() ) { return; } QString newAddress = mAddressProvider->formattedAddress( contact ); const QString currAddress = m_headerEdit->m_postAddressEdit->toPlainText(); bool replace = true; m_headerEdit->m_labName->setText( contact.realName() ); if( currAddress.isEmpty() ) { replace = true; } else if( currAddress != newAddress ) { // non empty and current different from new address // need to ask first if we overwrite if( interactive ) { if( KMessageBox::questionYesNo( this, i18n("The address label is not empty and different from the selected one.<br/>" "Do you really want to replace it with the text shown below?<pre>%1</pre>").arg(newAddress), i18n("Address Overwrite") ) == KMessageBox::No ) replace = false; } else { // this happens when the document is loaded and the address arrives from addressbook replace = false; } } else if( currAddress == newAddress ) { // both are equal, no action needed return; } if( replace ) { mContactUid = contact.uid(); m_headerEdit->m_postAddressEdit->setText( newAddress ); // Generate the welcome m_headerEdit->m_letterHead->clear(); QStringList li = generateLetterHead( adr ); m_headerEdit->m_letterHead->insertItems(-1, li ); m_headerEdit->m_letterHead->setCurrentIndex( KraftSettings::self()->salut() ); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(RifColumnBasedRsmspecParserTest, TestTableValues) { QString data; QTextStream out(&data); out << "1\n"; out << "---------------------------------------\n"; out << "SUMMARY OF RUN SIP USER FILE DATA VECTORS\n"; out << "---------------------------------------\n"; out << "TIME WLVP WPLT WTEST WFOFF WBUP\n"; out << "DAYS BARSA BARSA BARSA BARSA BARSA\n"; out << "\n"; out << " P-15P P-15P P-15P P-15P P-15P \n"; out << " 1 0.0 0.0 0.0 0.0 0.0\n"; out << " 2 0.0 0.0 0.0 0.0 0.0\n"; out << " 3 0.0 0.0 0.0 0.0 0.0\n"; out << " 4 0.0 0.0 0.0 0.0 0.0\n"; out << " 5 0.0 0.0 0.0 0.0 0.0\n"; out << " 6 0.0 0.0 0.0 0.0 0.0\n"; out << " 7 0.0 0.0 282 0.0 0.0\n"; out << " 8 0.0 0.0 279 0.0 0.0\n"; out << " 9 0.0 0.0 0.0 0.0 0.0\n"; out << " 10 0.0 0.0 0.0 0.0 0.0\n"; out << " 11 0.0 0.0 0.0 0.0 0.0\n"; out << " 12 0.0 0.0 0.0 0.0 0.0\n"; out << " 13 0.0 0.0 0.0 0.0 0.0\n"; out << " 14 0.0 0.0 0.0 0.0 0.0\n"; out << " 15 0.0 0.0 0.0 0.0 0.0\n"; out << " 16 0.0 0.0 0.0 0.0 0.0\n"; out << " 17 0.0 0.0 0.0 0.0 0.0\n"; out << " 18 0.0 0.0 0.0 0.0 0.0\n"; out << "1\n"; out << "---------------------------------------\n"; out << "SUMMARY OF RUN SIP USER FILE DATA VECTORS\n"; out << "---------------------------------------\n"; out << "TIME WLVP WPLT WTEST WFOFF WBUP\n"; out << "DAYS BARSA BARSA BARSA BARSA BARSA\n"; out << "\n"; out << " P-9P P-9P P-9P P-9P P-9P \n"; out << " 1 0.0 0.0 0.0 0.0 0.0\n"; out << " 2 0.0 0.0 0.0 0.0 0.0\n"; out << " 3 0.0 0.0 0.0 0.0 0.0\n"; out << " 4 0.0 0.0 370 0.0 0.0\n"; out << "\n"; RifColumnBasedUserDataParser parser = RifColumnBasedUserDataParser(data); auto tables = parser.tableData(); ASSERT_EQ(size_t(2), tables.size()); ASSERT_EQ(size_t(6), tables.at(0).columnInfos().size()); ASSERT_EQ(size_t(6), tables.at(1).columnInfos().size()); ASSERT_EQ(size_t(18), tables.at(0).columnInfos().at(0).values.size()); ASSERT_EQ(size_t(4), tables.at(1).columnInfos().at(0).values.size()); EXPECT_EQ(0.0, tables.at(0).columnInfos().at(1).values.at(6)); EXPECT_EQ(282.0, tables.at(0).columnInfos().at(3).values.at(6)); EXPECT_EQ(3.0, tables.at(1).columnInfos().at(0).values.at(2)); EXPECT_EQ(370.0, tables.at(1).columnInfos().at(3).values.at(3)); EXPECT_EQ("WLVP", tables.at(0).columnInfos().at(1).summaryAddress.quantityName()); EXPECT_EQ("P-15P", tables.at(0).columnInfos().at(5).summaryAddress.wellName()); EXPECT_EQ("P-9P", tables.at(1).columnInfos().at(1).summaryAddress.wellName()); EXPECT_NE("P-9P", tables.at(1).columnInfos().at(0).summaryAddress.wellName()); RifColumnBasedUserData userData; userData.parse(data); RifEclipseSummaryAddress adr(RifEclipseSummaryAddress::SUMMARY_WELL, "WLVP", -1, -1, "", "P-15P", -1, "", -1, -1, -1, -1); QDateTime firstTimeStep = RiaQDateTimeTools::addDays(RiaQDateTimeTools::epoch(), 1.0); auto timeSteps = userData.timeSteps(adr); EXPECT_EQ(size_t(18), timeSteps.size()); EXPECT_EQ(firstTimeStep.toTime_t(), timeSteps[0]); }
void ImplicitExceptionTable::print(address base) const { tty->print("{"); for( uint i=0; i<len(); i++ ) tty->print("< "INTPTR_FORMAT", "INTPTR_FORMAT" > ",base + *adr(i), base + *(adr(i)+1)); tty->print_cr("}"); }
int Face3Space::refine(hObj& f,const int) { /// full break /// 0-3 - subfaces_, 4-6 - subedges_ /// /* /// |\. /// |2 \. /// | \. /// ---6--\. /// |\ 3| \. /// | 4 5 \. /// |0___\_|____1\. */ Face3D & face( *static_cast<Face3D*>(&f) ); face.updatePointers(); assert(face.type_ == Face3D::myType); if(!face.isBroken()) { hHybridMesh & m(*face.myMesh); face.mySize_= sizeof(Face3D); face.nMyClassSons_=4; assert(m.edges_.getById(face.components(0)).isBroken()); assert(m.edges_.getById(face.components(1)).isBroken()); assert(m.edges_.getById(face.components(2)).isBroken()); const Vertex* v[6]={ &m.vertices_[face.verts(0)], &m.vertices_[face.verts(1)], &m.vertices_[face.verts(2)], &m.vertices_.getById(m.edge(face.verts(0),face.verts(1)).sons(0)), &m.vertices_.getById(m.edge(face.verts(0),face.verts(2)).sons(0)), &m.vertices_.getById(m.edge(face.verts(1),face.verts(2)).sons(0)) }; // new edges_ // indexes of verts in v[6] for new edges static const int edgesVerts[3][2]={{3,4},{3,5},{4,5}}; for(uTind i(0); i < 3; ++i) { const uTind vertices[2] ={ v[ edgesVerts[i][0] ]->pos_, v[ edgesVerts[i][1] ]->pos_}; Edge & child = *m.edges_.newObj<Edge>(vertices); child.parent_= face.id_; child.level_= face.level_+1; face.sons(i)=child.id_; // child.status(INACTIVE); child.components(0)=v[ edgesVerts[i][0] ]->id_; child.components(1)=v[ edgesVerts[i][1] ]->id_; } // new faces3 // define vertices building childrens const uTind verts[4][4]= { {v[0]->pos_,v[3]->pos_,v[4]->pos_,UNKNOWN}, {v[3]->pos_,v[1]->pos_,v[5]->pos_,UNKNOWN}, {v[4]->pos_,v[5]->pos_,v[2]->pos_,UNKNOWN}, {// this one is flipped v[3]->pos_,v[5]->pos_,v[4]->pos_,UNKNOWN} }; #ifdef _DEBUG double parentNormVec[3]={0.0}, childNormVec[3]={0.0}; m.faceNormal(face,parentNormVec,NULL); #endif BYTE * adr( reinterpret_cast<BYTE*>(&face)+ face.mySize_); for(uTind i(0); i < 4; ++i) { Face3 & faceChild = *m.faces_.newObj<Face3>(verts[i],adr); faceChild.parent_= face.id_; faceChild.level_= face.level_+ 1; // faceChild.status(INACTIVE); adr += faceChild.mySize_; // code below is no more needed, as this is coverd in Face3 constructor //faceChild.components(0)=verts_n_comps[i][3 ]; //faceChild.components(1)=verts_n_comps[i][3+1]; //faceChild.components(2)=verts_n_comps[i][3+2]; faceChild.neighs(0) = 0; faceChild.neighs(1) = 0; faceChild.flags(B_COND) = face.flags(B_COND); //faceChild.neighs(0) = face.neighs(0); //faceChild.neighs(1) = face.neighs(1); #ifdef _DEBUG m.faceNormal(faceChild, childNormVec,NULL); assert(abs(parentNormVec[0]-childNormVec[0]) <= SMALL); assert(abs(parentNormVec[1]-childNormVec[1]) <= SMALL); assert(abs(parentNormVec[2]-childNormVec[2]) <= SMALL); #endif if(i==3) { // fourth is flipped faceChild.flags(F_TYPE)=F_FLIPPED; } } #ifdef _DEBUG out_stream <<"\n refine Face3("<<face.pos_<<") " <<face.verts(0)<<" " <<face.verts(1)<<" " <<face.verts(2); for(int i(0); i < 3; ++i) { Face3 & faceChild = *face.getMyClassChild<Face3>(i); out_stream <<"\n child Face3("<<faceChild.pos_<<") : " <<faceChild.verts(0)<<" " <<faceChild.verts(1)<<" " <<faceChild.verts(2); } #endif ++(m.faces_.dividedObjs_); } return ( sizeof(Face3D) - sizeof(Face3) ) + 4*sizeof(Face3); }
void ImplicitRangeCheckTable::print(address base, outputStream* out) const { out->print("{"); for( uint i=0; i<len(); i++ ) out->print("< "INTPTR_FORMAT", "INTPTR_FORMAT" > ",base+*adr(i),base+*(adr(i)+1)); out->print_cr("}"); }
static void dump_import_directory(const void *const section_base, const DWORD section_base_virtual, const IMAGE_IMPORT_DESCRIPTOR * imp) /* dump of import directory. * quite a challenge because of broken linkers, unbound/old-bound and new-bound directories */ { #define indent " " #define adr(rva) ((const void*)((char*)section_base+((DWORD)(rva))-section_base_virtual)) for (; !IsBadReadPtr(imp, sizeof(*imp)) && imp->Name; imp++) { const IMAGE_THUNK_DATA *import_entry, *mapped_entry; enum { bound_none, bound_old, bound_new } bound; printf("\n" indent "from \"%s\":\n", (char *)adr(imp->Name)); if (imp->TimeDateStamp == ~0UL) { puts(indent "bound, new style"); bound = bound_new; } else if (imp->TimeDateStamp) { printf(indent "bound (old style) to %s", asctime(gmtime((const time_t *)&imp->TimeDateStamp))); bound = bound_old; } else { puts(indent "not bound"); bound = bound_none; } printf(indent "name table at %#lx, address table at %#lx\n", imp->OriginalFirstThunk, imp->FirstThunk); if (imp->OriginalFirstThunk) { import_entry = adr(imp->OriginalFirstThunk); mapped_entry = adr(imp->FirstThunk); } else { puts(indent "(hint table missing, probably Borland bug)"); import_entry = adr(imp->FirstThunk); mapped_entry = 0; bound = bound_none; } printf(indent "%6s %s\n", "hint", "name"); printf(indent "%6s %s\n", "----", "----"); { int count, nextforwarder = bound==bound_old ? imp->ForwarderChain : -1; for (count = 0; import_entry->u1.Ordinal; count++, import_entry++, bound ? mapped_entry++ : 0) { if (IMAGE_SNAP_BY_ORDINAL(import_entry->u1.Ordinal)) printf(indent "%6lu %-20s", IMAGE_ORDINAL(import_entry->u1.Ordinal),"<ordinal>"); else { const IMAGE_IMPORT_BY_NAME *name_import = adr(import_entry->u1.AddressOfData); printf(indent "%6u %-20.50s", name_import->Hint, name_import->Name); } if (bound) if (count != nextforwarder) printf("%#12lx\n", (unsigned long)mapped_entry->u1.Function); else { printf("%12s\n", " --> forward"); nextforwarder = (int)mapped_entry->u1.ForwarderString; } else puts(""); } } } if (IsBadReadPtr(imp, sizeof(*imp))) puts(indent "!! data inaccessible!!"); #undef adr #undef indent }
static void dump_export_directory(const void *const section_base, const DWORD section_base_virtual, const IMAGE_EXPORT_DIRECTORY * const exp, const size_t section_length) /* output of an export directory */ { #define indent " " #define adr(rva) ((const void*)((char*)section_base+((DWORD)(rva))-section_base_virtual)) /* prepare for bad linkers */ if (IsBadReadPtr(exp, sizeof(*exp))) { puts(indent "!! data inaccessible!!"); return; } printf(indent "module name: \"%s\"\n", (char *)adr(exp->Name)); printf(indent "created (GMT): %s", asctime(gmtime((const time_t *)&exp->TimeDateStamp))); printf(indent "version: %d.%d\n", exp->MajorVersion, exp->MinorVersion); printf(indent "%lu exported functions, list at %lx\n", exp->NumberOfFunctions, exp->AddressOfFunctions); if (exp->NumberOfNames && exp->AddressOfNames) printf(indent "%lu exported names, list at %lx\n", exp->NumberOfNames, exp->AddressOfNames); else puts(indent "(no name table provided)"); printf(indent "Ordinal base: %lu\n", exp->Base); { const WORD *ordinal_table = adr(exp->AddressOfNameOrdinals); const DWORD *function_table = adr(exp->AddressOfFunctions); const DWORD *name_table = exp->AddressOfNames ? adr(exp->AddressOfNames) : 0; size_t i; unsigned unused_slots = 0; /* functions with an RVA of 0 seem to be unused */ printf(indent "%4s %4s %-30s %6s\n", "Ord.", "Hint", "Name", "RVA"); printf(indent "%4s %4s %-30s %6s\n", "----", "----", "----", "---"); for (i = 0; i < exp->NumberOfFunctions; i++) { const DWORD addr = function_table[i]; if (!addr) /* skip unused slots */ { ++unused_slots; continue; } /* ordinal */ printf(indent "%4u ", i + exp->Base); /* if names provided, list all names of this * export ordinal */ if (name_table) { size_t n; int found = 0; for (n = 0; n < exp->NumberOfNames; n++) { /* according to the spec, you should * compare to the ordinal 'i+exp->Base' * rather than to 'i', but I've found * this to work and the ordinal not to * work. */ if (ordinal_table[n] == i) { /* begin new line for * additional names */ if (found) fputs("\n" indent " ", stdout); printf("%4lu %-30s", (unsigned long)n,adr(name_table[n])); ++found; } } if (!found) /* no names */ printf("%4s %-30s", "","(nameless)"); else if (found > 1) /* several names, put address in new line */ fputs("\n" indent indent, stdout); putchar(' '); } /* entry point */ if (addr >= section_base_virtual && addr < section_base_virtual + section_length) /* forwarder */ puts(adr(addr)); else /* normal export */ printf("%6lx\n", addr); } if (unused_slots) printf(indent "-- there are %u unused slots --\n", unused_slots); } #undef adr #undef indent }