void do_mem_stage() { bool_t read = gen_mem_read(); bool_t mem_ok = TRUE; word_t valm = 0; mem_addr = gen_mem_addr(); mem_data = ex_mem_curr->vala; mem_write = gen_mem_write(); if (read) { mem_ok = get_word_val(mem, mem_addr, &valm); sim_log("Memory: Read 0x%x from 0x%x, instruction = %s\n", valm, mem_addr, iname(HPACK(ex_mem_curr->icode, ex_mem_curr->ifun))); } if (mem_write) { word_t sink; /* Do a read of address just to check validity */ mem_ok = get_word_val(mem, mem_addr, &sink); } mem_wb_next->icode = ex_mem_curr->icode; mem_wb_next->ifun = ex_mem_curr->ifun; mem_wb_next->vale = ex_mem_curr->vale; mem_wb_next->valm = valm; mem_wb_next->deste = ex_mem_curr->deste; mem_wb_next->destm = ex_mem_curr->destm; mem_wb_next->exception = mem_ok ? ex_mem_curr->exception : EXC_ADDR; mem_wb_next->stage_pc = ex_mem_curr->stage_pc; }
/* Implements both ID and WB */ void do_id_wb_stages() { /* Set up write backs. Don't occur until end of cycle */ wb_destE = gen_w_dstE(); wb_valE = gen_w_valE(); wb_destM = gen_w_dstM(); wb_valM = gen_w_valM(); id_ex_next->srca = gen_new_E_srcA(); id_ex_next->srcb = gen_new_E_srcB(); id_ex_next->deste = gen_new_E_dstE(); id_ex_next->destm = gen_new_E_dstM(); /* Read the registers */ d_regvala = get_reg_val(reg, id_ex_next->srca); d_regvalb = get_reg_val(reg, id_ex_next->srcb); /* Do forwarding and valA selection */ id_ex_next->vala = gen_new_E_valA(); id_ex_next->valb = gen_new_E_valB(); id_ex_next->icode = if_id_curr->icode; id_ex_next->ifun = if_id_curr->ifun; id_ex_next->valc = if_id_curr->valc; id_ex_next->stage_pc = if_id_curr->stage_pc; id_ex_next->exception = (if_id_curr->icode == I_HALT) ? EXC_HALT : if_id_curr->exception; sim_log("Decode: instr = %s, exc=%s\n", iname(HPACK(if_id_curr->icode, if_id_curr->ifun)), exc_name(if_id_curr->exception)); }
void do_ex_stage() { alu_t alufun = gen_alufun(); bool_t setcc = gen_set_cc(); word_t alua, alub; alua = gen_aluA(); alub = gen_aluB(); e_bcond = take_branch(cc, id_ex_curr->ifun); ex_mem_next->takebranch = id_ex_curr->icode == I_JMP && e_bcond; if (id_ex_curr->icode == I_JMP) sim_log("Execute: %s instruction, cc = %s, branch %staken\n", iname(HPACK(id_ex_curr->icode, id_ex_curr->ifun)), cc_name(cc), ex_mem_next->takebranch ? "" : "not "); /* Perform the ALU operation */ ex_mem_next->vale = compute_alu(alufun, alua, alub); { byte_t instr = HPACK(id_ex_curr->icode, id_ex_curr->ifun); sim_log("Execute: Instruction %s\n", iname(instr)); } if (setcc) { cc_in = compute_cc(alufun, alua, alub); sim_log("Execute: CC cc = %s\n", cc_name(cc_in)); } ex_mem_next->icode = id_ex_curr->icode; ex_mem_next->ifun = id_ex_curr->ifun; ex_mem_next->vala = gen_new_M_valA(); ex_mem_next->deste = id_ex_curr->deste; ex_mem_next->destm = id_ex_curr->destm; ex_mem_next->srca = id_ex_curr->srca; ex_mem_next->exception = id_ex_curr->exception; ex_mem_next->stage_pc = id_ex_curr->stage_pc; }
/*==========================================+ * evaluate_func -- Evaluate builtin function *=========================================*/ PVALUE evaluate_func (PNODE node, SYMTAB stab, BOOLEAN *eflg) { PVALUE val; *eflg = FALSE; if (prog_trace) trace_outl("evaluate_func called: %d: %s", iline(node)+1, iname(node)); val = (*(PFUNC)ifunc(node))(node, stab, eflg); return val; }
static char *format_f() { char valcstring[9]; char valpstring[9]; wstring(valc, 4, 32, valcstring); wstring(valp, 4, 32, valpstring); sprintf(status_msg, "%s %s %s %s %s", iname(HPACK(icode, ifun)), reg_name(ra), reg_name(rb), valcstring, valpstring); return status_msg; }
char *format_if_id(if_id_ptr state){ char valcstring[9]; char valpstring[9]; wstring(state->valc, 4, 32, valcstring); wstring(state->valp, 4, 32, valpstring); sprintf(status_msg, "%s %s %s %s %s %s", stat_name(state->status), iname(HPACK(state->icode,state->ifun)), reg_name(state->ra), reg_name(state->rb), valcstring, valpstring); return status_msg; }
char *format_mem_wb(mem_wb_ptr state){ char valestring[9]; char valmstring[9]; wstring(state->vale, 4, 32, valestring); wstring(state->valm, 4, 32, valmstring); sprintf(status_msg, "%s %s %s %s %s %s", stat_name(state->status), iname(HPACK(state->icode, state->ifun)), valestring, valmstring, reg_name(state->deste), reg_name(state->destm)); return status_msg; }
/* SEQ+ */ static char *format_prev() { char istring[9]; char mstring[9]; char pstring[9]; wstring(prev_valc, 4, 32, istring); wstring(prev_valm, 4, 32, mstring); wstring(prev_valp, 4, 32, pstring); sprintf(status_msg, "%c %s %s %s %s", prev_bcond ? 'Y' : 'N', iname(HPACK(prev_icode, prev_ifun)), istring, mstring, pstring); return status_msg; }
/********************************************************************* 函数:creat 功能:创建文件,存在且可写则覆盖,否则申请i节点,并打开该文件,返回文件指针 **********************************************************************/ int creat(unsigned int user_id, char *filename, unsigned short mode){ struct inode *inode; int dirid,di_ith; int i,j; dirid = namei(filename);//查找文件在当前目录下对应的内存目录项的标号 if (dirid != -1){//如果存在同名文件/目录 inode = iget(dir.direct[dirid].d_ino); if(!(inode->di_mode&DIFILE)){//如果不是文件 printf("存在同名目录!\n"); } if (access(user_id,inode,WRITE) == 0){//判断用户对该文件能否进行写操作 iput(inode); printf("\n creat access not allowed \n"); return -1; } //释放旧文件的block组更新当前文件系统的指针 j = inode->di_size%512?1:0; for (i=0; i<inode->di_size/BLOCKSIZ+j; i++) bfree(inode->di_addr[i]); for (i=0; i<SYSOPENFILE; i++){ if (sys_ofile[i].f_count != 0 && sys_ofile[i].f_inode == inode){ sys_ofile[i].f_off = 0; } } iput(inode);//回收内存节点 return open(user_id,filename,WRITE); } else{ inode = ialloc();//分配磁盘节点 返回相应的内存节点指针 di_ith = iname(filename);//为当前文件分配目录项 dir.size++; //当前目录大小加1 dir.direct[di_ith].d_ino = inode->i_ino;//将磁盘节点赋值给存储目录项的信息节点 //更改磁盘节点的相关数据项的信息 inode->di_mode = mode; inode->di_uid = user[user_id].u_uid; inode->di_gid = user[user_id].u_gid; inode->di_size = 0; inode->di_number = 1; //liwen change to 1 iput(inode); return open(user_id,filename,WRITE); } return 0; }
char *format_ex_mem(ex_mem_ptr state){ char valestring[9]; char valastring[9]; wstring(state->vale, 4, 32, valestring); wstring(state->vala, 4, 32, valastring); sprintf(status_msg, "%s %s %c %s %s %s %s", stat_name(state->status), iname(HPACK(state->icode, state->ifun)), state->takebranch ? 'Y' : 'N', valestring, valastring, reg_name(state->deste), reg_name(state->destm)); return status_msg; }
void MidiInstrument::write(int level, Xml& xml) { xml.header(); xml.tag(level, "los version=\"1.0\""); level++; xml.nput(level, "<MidiInstrument name=\"%s\" panValue=\"%f\"", Xml::xmlString(iname()).toLatin1().constData(), m_panValue); if (_nullvalue != -1) { QString nv; nv.setNum(_nullvalue); xml.nput(" nullparam=\"%s\"", nv.toLatin1().constData()); } xml.put(">"); // ------------- // What about Init, Reset, State, and InitScript ? // ------------- level++; for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g) { PatchGroup* pgp = *g; const PatchList& pl = pgp->patches; xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(pgp->name).toLatin1().constData()); level++; for (ciPatch p = pl.begin(); p != pl.end(); ++p) (*p)->write(level, xml); level--; xml.etag(level, "PatchGroup"); } for (iMidiController ic = _controller->begin(); ic != _controller->end(); ++ic) ic->second->write(level, xml); for(QHash<int, KeyMap*>::const_iterator km = m_keymaps.begin(); km != m_keymaps.end(); ++km) { KeyMap *m = km.value(); m->write(level, xml); } level--; xml.etag(level, "MidiInstrument"); level--; xml.etag(level, "los"); }
char *format_id_ex(id_ex_ptr state){ char valcstring[9]; char valastring[9]; char valbstring[9]; wstring(state->valc, 4, 32, valcstring); wstring(state->vala, 4, 32, valastring); wstring(state->valb, 4, 32, valbstring); sprintf(status_msg, "%s %s %s %s %s %s %s %s %s", stat_name(state->status), iname(HPACK(state->icode, state->ifun)), valcstring, valastring, valbstring, reg_name(state->deste), reg_name(state->destm), reg_name(state->srca), reg_name(state->srcb)); return status_msg; }
void do_ex_stage() { alu_t alufun = gen_alufun(); bool_t setcc = gen_set_cc(); word_t alua, alub; alua = gen_aluA(); alub = gen_aluB(); e_bcond = cond_holds(cc, id_ex_curr->ifun); ex_mem_next->takebranch = e_bcond; if (id_ex_curr->icode == I_JMP) sim_log("\tExecute: instr = %s, cc = %s, branch %staken\n", iname(HPACK(id_ex_curr->icode, id_ex_curr->ifun)), cc_name(cc), ex_mem_next->takebranch ? "" : "not "); /* Perform the ALU operation */ word_t aluout = compute_alu(alufun, alua, alub); ex_mem_next->vale = aluout; sim_log("\tExecute: ALU: %c 0x%x 0x%x --> 0x%x\n", op_name(alufun), alua, alub, aluout); if (setcc) { cc_in = compute_cc(alufun, alua, alub); sim_log("\tExecute: New cc = %s\n", cc_name(cc_in)); } ex_mem_next->icode = id_ex_curr->icode; ex_mem_next->ifun = id_ex_curr->ifun; ex_mem_next->vala = gen_e_valA(); ex_mem_next->deste = gen_e_dstE(); ex_mem_next->destm = id_ex_curr->destm; ex_mem_next->srca = id_ex_curr->srca; ex_mem_next->status = id_ex_curr->status; ex_mem_next->stage_pc = id_ex_curr->stage_pc; }
void EventGroup::SetEvents(const EventArray& events, const BinMemFactory& memfactory) { // put all names in list // size_t num_names = events.NameMap().size(); for (std::map<Int32, std::string>::const_iterator iname( events.NameMap().begin() ); iname != events.NameMap().end(); iname++) { EventNameID nameid; nameid.ID = iname->first; nameid.Name = iname->second; EventMap.Add(nameid); } // copy events size_t num_events = events.NumEvents(); std::vector<BinaryFieldSpec> layout; layout.push_back(BinaryFieldSpec::FromType<Int32>(EventGroup::IDFieldName, 1)); layout.push_back(BinaryFieldSpec::FromType<double>(EventGroup::TimeFieldName, 1)); Allocate(layout, num_events, memfactory); for (EventGroupIter i(*this); i.HasFrame(); i.Next()) { i.Time() = events.EventTime(i.FrameIndex()); i.ID() = events.EventID(i.FrameIndex()); } }
/*================================================+ * evaluate_ufunc -- Evaluate user defined function * node: [in] parsed node of function definition * stab: [in] function's symbol table * eflg: [out] error flag *===============================================*/ PVALUE evaluate_ufunc (PNODE node, SYMTAB stab, BOOLEAN *eflg) { STRING procname = (STRING) iname(node); PNODE func, arg, parm; SYMTAB newstab = NULL; PVALUE val=NULL; INTERPTYPE irc; INT count=0; *eflg = TRUE; /* find func in local or global table */ func = get_proc_node(procname, irptinfo(node)->functab, gfunctab, &count); if (!func) { if (!count) prog_error(node, _("Undefined func: %s"), procname); else prog_error(node, _("Ambiguous call to func: %s"), procname); goto ufunc_leave; } newstab = create_symtab_proc(procname, stab); arg = (PNODE) iargs(node); parm = (PNODE) iargs(func); while (arg && parm) { BOOLEAN eflg=TRUE; PVALUE value = evaluate(arg, stab, &eflg); if (eflg) { if (getlloptint("FullReportCallStack", 0) > 0) prog_error(node, "In user function %s()", procname); return INTERROR; } insert_symtab(newstab, iident(parm), value); arg = inext(arg); parm = inext(parm); } if (arg || parm) { prog_error(node, "``%s'': mismatched args and params\n", procname); goto ufunc_leave; } irc = interpret((PNODE) ibody(func), newstab, &val); switch (irc) { case INTRETURN: case INTOKAY: #ifdef DEBUG llwprintf("Successful ufunc call -- val returned was "); show_pvalue(val); llwprintf("\n"); #endif *eflg = FALSE; goto ufunc_leave; case INTBREAK: case INTCONTINUE: case INTERROR: break; } if (getlloptint("FullReportCallStack", 0) > 0) prog_error(node, "In user function %s()", procname); *eflg = TRUE; delete_pvalue(val); val=NULL; ufunc_leave: if (newstab) { remove_symtab(newstab); newstab = NULL; } return val; }
/* * The purpose here is to provide useful clues about a kernel crash, so * less likely instructions, e.g. floating point, aren't fully decoded. */ static void disassemble(unsigned int instr) { int optype = instr >> 26; char buf[40], *s = buf; s += sprintf(buf, "%08x %s ", instr, iname(instr)); switch (iformat(optype)) { default: case NOT_INST: case MISC: break; case PAL: s += sprintf(s, "%d", instr); break; case BRANCH: { int reg = (instr >> 21) & 0x1f; int offset = instr & 0x1fffff; if (offset >= 0x100000) offset -= 0x200000; if (((optype & 3) == 0) || (optype >= 0x38)) { if ((optype != 0x30) || (reg != 0x1f)) s += sprintf(s, "%s,", ireg_name[reg]); } else s += sprintf(s, "f%d,", reg); s += sprintf(s, ".%+d", (offset + 1) << 2); break; } case MEMORY: { int addr_reg = (instr >> 16) & 0x1f; int value_reg = (instr >> 21) & 0x1f; int offset = instr & 0xffff; if (offset >= 0x8000) offset -= 0x10000; if ((optype >= 0x20) && (optype < 0x28)) s += sprintf(s, "f%d", value_reg); else s += sprintf(s, "%s", ireg_name[value_reg]); s += sprintf(s, ",%d(%s)", offset, ireg_name[addr_reg]); break; } case JUMP: { int target_reg = (instr >> 16) & 0x1f; int return_reg = (instr >> 21) & 0x1f; s += sprintf(s, "%s,", ireg_name[return_reg]); s += sprintf(s, "(%s)", ireg_name[target_reg]); break; } case OPERATE: { int areg = (instr >> 21) & 0x1f; int breg = (instr >> 16) & 0x1f; int creg = instr & 0x1f; int litflag = instr & (1<<12); int lit = (instr >> 13) & 0xff; s += sprintf(s, "%s,", ireg_name[areg]); if (litflag) s += sprintf(s, "%d", lit); else s += sprintf(s, "%s", ireg_name[breg]); s += sprintf(s, ",%s", ireg_name[creg]); break; } case FOPERATE: { int areg = (instr >> 21) & 0x1f; int breg = (instr >> 16) & 0x1f; int creg = instr & 0x1f; s += sprintf(s, "f%d,f%d,f%d", areg, breg, creg); break; } } buf[s-buf] = 0; printk("%s\n", buf); }
/* Return resulting exception status */ static exc_t sim_step() { word_t aluA; word_t aluB; word_t alufun; exc_t status = update_state(); /* Update state from last cycle */ if (plusmode) { pc = gen_pc(); } valp = pc; if (get_byte_val(mem, valp, &instr)) { icode = HI4(instr); ifun = LO4(instr); } else { instr = HPACK(I_NOP,0); icode = I_NOP; ifun = 0; status = EXC_ADDR; sim_log("Couldn't fetch at address 0x%x\n", valp); } valp++; if (gen_need_regids()) { byte_t regids; if (get_byte_val(mem, valp, ®ids)) { ra = GET_RA(regids); rb = GET_RB(regids); } else { ra = REG_NONE; rb = REG_NONE; status = EXC_ADDR; sim_log("Couldn't fetch at address 0x%x\n", valp); } valp++; } else { ra = REG_NONE; rb = REG_NONE; } if (gen_need_valC()) { if (get_word_val(mem, valp, &valc)) { } else { valc = 0; status = EXC_ADDR; sim_log("Couldn't fetch at address 0x%x\n", valp); } valp+=4; } else { valc = 0; } if (status == EXC_NONE && !gen_instr_valid()) { status = EXC_INSTR; } sim_log("IF: Fetched %s at 0x%x. ra=%s, rb=%s, valC = 0x%x\n", iname(HPACK(icode,ifun)), pc, reg_name(ra), reg_name(rb), valc); if (status == EXC_NONE && icode == I_HALT) { status = EXC_HALT; } srcA = gen_srcA(); if (srcA != REG_NONE) { vala = get_reg_val(reg, srcA); } else { vala = 0; } srcB = gen_srcB(); if (srcB != REG_NONE) { valb = get_reg_val(reg, srcB); } else { valb = 0; } destE = gen_dstE(); destM = gen_dstM(); aluA = gen_aluA(); aluB = gen_aluB(); alufun = gen_alufun(); vale = compute_alu(alufun, aluA, aluB); cc_in = cc; if (gen_set_cc()) cc_in = compute_cc(alufun, aluA, aluB); bcond = (icode == I_JMP) && take_branch(cc, ifun); mem_addr = gen_mem_addr(); mem_data = gen_mem_data(); if (status == EXC_NONE && gen_mem_read()) { if (!get_word_val(mem, mem_addr, &valm)) { sim_log("Couldn't read at address 0x%x\n", mem_addr); return EXC_ADDR; } } else valm = 0; mem_write = status == EXC_NONE && gen_mem_write(); if (plusmode) { prev_icode_in = icode; prev_ifun_in = ifun; prev_valc_in = valc; prev_valm_in = valm; prev_valp_in = valp; prev_bcond_in = bcond; } else { /* Update PC */ pc_in = gen_new_pc(); } sim_report(); return status; }
void ManageMetronomeDialog::populate(int deviceIndex) { m_metronomeInstrument->clear(); DeviceList *devices = m_doc->getStudio().getDevices(); DeviceListConstIterator it; int count = 0; Device *dev = 0; for (it = devices->begin(); it != devices->end(); it++) { dev = *it; if (!isSuitable(dev)) continue; if (count == deviceIndex) break; count++; } // sanity if (count < 0 || dev == 0 || !isSuitable(dev)) { return ; } // populate instrument list InstrumentList list = dev->getPresentationInstruments(); InstrumentList::iterator iit; const MidiMetronome *metronome = getMetronome(dev); // if we've got no metronome against this device then create one if (metronome == 0) { InstrumentId id = SystemInstrumentBase; for (iit = list.begin(); iit != list.end(); ++iit) { if ((*iit)->isPercussion()) { id = (*iit)->getId(); break; } } setMetronome(dev, MidiMetronome(id)); metronome = getMetronome(dev); } // metronome should now be set but we still check it if (metronome) { int position = 0; int count = 0; for (iit = list.begin(); iit != list.end(); ++iit) { QString iname(QObject::tr((*iit)->getName().c_str())); QString ipname((*iit)->getLocalizedPresentationName()); QString programName(QObject::tr((*iit)->getProgramName().c_str())); QString text; if ((*iit)->getType() == Instrument::SoftSynth) { iname.replace(QObject::tr("Synth plugin "), ""); programName = ""; AudioPluginInstance *plugin = (*iit)->getPlugin (Instrument::SYNTH_PLUGIN_POSITION); if (plugin) programName = strtoqstr(plugin->getDisplayName()); } else { iname = ipname; } if (programName != "") { text = tr("%1 (%2)").arg(iname).arg(programName); } else { text = iname; } m_metronomeInstrument->addItem(text); if ((*iit)->getId() == metronome->getInstrument()) { position = count; } count++; } m_metronomeInstrument->setCurrentIndex(position); m_barPitch = metronome->getBarPitch(); m_beatPitch = metronome->getBeatPitch(); m_subBeatPitch = metronome->getSubBeatPitch(); slotPitchSelectorChanged(0); m_metronomeResolution->setCurrentIndex(metronome->getDepth()); m_metronomeBarVely->setValue(metronome->getBarVelocity()); m_metronomeBeatVely->setValue(metronome->getBeatVelocity()); m_metronomeSubBeatVely->setValue(metronome->getSubBeatVelocity()); m_playEnabled->setChecked(m_doc->getComposition().usePlayMetronome()); m_recordEnabled->setChecked(m_doc->getComposition().useRecordMetronome()); slotResolutionChanged(metronome->getDepth()); } }
/* Return resulting status */ static byte_t sim_step() { word_t aluA; word_t aluB; word_t alufun; status = STAT_AOK; imem_error = dmem_error = FALSE; update_state(); /* Update state from last cycle */ if (plusmode) { pc = gen_pc(); } valp = pc; instr = HPACK(I_NOP, F_NONE); imem_error = !get_byte_val(mem, valp, &instr); if (imem_error) { sim_log("Couldn't fetch at address 0x%x\n", valp); } imem_icode = HI4(instr); imem_ifun = LO4(instr); icode = gen_icode(); ifun = gen_ifun(); instr_valid = gen_instr_valid(); valp++; if (gen_need_regids()) { byte_t regids; if (get_byte_val(mem, valp, ®ids)) { ra = GET_RA(regids); rb = GET_RB(regids); } else { ra = REG_NONE; rb = REG_NONE; status = STAT_ADR; sim_log("Couldn't fetch at address 0x%x\n", valp); } valp++; } else { ra = REG_NONE; rb = REG_NONE; } if (gen_need_valC()) { if (get_word_val(mem, valp, &valc)) { } else { valc = 0; status = STAT_ADR; sim_log("Couldn't fetch at address 0x%x\n", valp); } valp+=4; } else { valc = 0; } sim_log("IF: Fetched %s at 0x%x. ra=%s, rb=%s, valC = 0x%x\n", iname(HPACK(icode,ifun)), pc, reg_name(ra), reg_name(rb), valc); if (status == STAT_AOK && icode == I_HALT) { status = STAT_HLT; } srcA = gen_srcA(); if (srcA != REG_NONE) { vala = get_reg_val(reg, srcA); } else { vala = 0; } srcB = gen_srcB(); if (srcB != REG_NONE) { valb = get_reg_val(reg, srcB); } else { valb = 0; } cond = cond_holds(cc, ifun); destE = gen_dstE(); destM = gen_dstM(); aluA = gen_aluA(); aluB = gen_aluB(); alufun = gen_alufun(); vale = compute_alu(alufun, aluA, aluB); cc_in = cc; if (gen_set_cc()) cc_in = compute_cc(alufun, aluA, aluB); bcond = cond && (icode == I_JMP); mem_addr = gen_mem_addr(); mem_data = gen_mem_data(); if (gen_mem_read()) { dmem_error = dmem_error || !get_word_val(mem, mem_addr, &valm); if (dmem_error) { sim_log("Couldn't read at address 0x%x\n", mem_addr); } } else valm = 0; mem_write = gen_mem_write(); if (mem_write) { /* Do a test read of the data memory to make sure address is OK */ word_t junk; dmem_error = dmem_error || !get_word_val(mem, mem_addr, &junk); } status = gen_Stat(); if (plusmode) { prev_icode_in = icode; prev_ifun_in = ifun; prev_valc_in = valc; prev_valm_in = valm; prev_valp_in = valp; prev_bcond_in = bcond; } else { /* Update PC */ pc_in = gen_new_pc(); } sim_report(); return status; }
// ============================================================================ // pxpByteCode // ============================================================================ pxpByteCode::pxpByteCode( pkgDecompiler* decompiler ) : Decompiler(decompiler) , CToken(NULL) , CTokenTree(NULL) , CTokenGroup(NULL) , CTokenGroupTree(NULL) , CTokenItem(NULL) , CTokenItemTree(NULL) , CTokenGroupCnd(NULL) , CTokenGroupCndTree(NULL) , unXmlParser() { // temp tree nodes unXmlParseTree bytecode ( wxT("bytecode") ); unXmlParseTree bgroup ( wxT("group") ); unXmlParseTree gname ( wxT("name") ); unXmlParseTree gmemo ( wxT("memo") ); unXmlParseTree gtoken ( wxT("token") ); unXmlParseTree tcode ( wxT("code") ); unXmlParseTree tname ( wxT("name") ); unXmlParseTree tdesc ( wxT("desc") ); unXmlParseTree tdata ( wxT("data") ); unXmlParseTree titem ( wxT("item") ); unXmlParseTree itype ( wxT("type") ); unXmlParseTree iname ( wxT("name") ); unXmlParseTree ttext ( wxT("text") ); unXmlParseTree gcond ( wxT("gcond") ); unXmlParseTree cif ( wxT("if") ); unXmlParseTree ceq ( wxT("eq") ); unXmlParseTree cthen ( wxT("then") ); unXmlParseTree cleft ( wxT("left") ); unXmlParseTree cright ( wxT("right") ); unXmlParseTree ctstream ( wxT("tstream") ); unXmlParseTree cnum ( wxT("num") ); unXmlParseTree nfunc ( wxT("nativefunctions") ); unXmlParseTree ffirst ( wxT("first") ); unXmlParseTree fextended ( wxT("extended") ); // token group - pre bgroup.AddCommand( new_xpObjCreate<pkgTokenGroup>(txpParseTree) ); bgroup.AddCommand( new_xpFunc1( this, &pxpByteCode::SetTokenGroup, txpTokenGroupObject ) ); bgroup.AddCommand( new_xpFunc1( this, &pxpByteCode::SetTokenGroupTree, txpParseTree ) ); gname.AddCommand( new_xpFunc1( txpTokenGroup, &pkgTokenGroup::SetName, txpNodeName(txpParseTree) ) ); gname.AddPostCommand( new_xpFunc1( Decompiler, &pkgDecompiler::AddTokenGroup, txpTokenGroup ) ); // token group - post bgroup.AddPostCommand( new_xpObjClear(txpParseTree) ); bgroup.AddPostCommand( new_xpFunc0( this, &pxpByteCode::ClearTokenGroup ) ); bgroup.AddPostCommand( new_xpFunc0( this, &pxpByteCode::ClearTokenGroupTree ) ); // gcond = pre gcond.AddCommand( new_xpObjCreate<pkgTokenCondition>(txpParseTree) ); gcond.AddCommand( new_xpFunc1( this, &pxpByteCode::SetTokenGroupCnd, txpTokenGroupCndObject ) ); gcond.AddCommand( new_xpFunc1( this, &pxpByteCode::SetTokenGroupCndTree, txpParseTree ) ); // gcond = post gcond.AddPostCommand( new_xpObjClear(txpParseTree) ); gcond.AddPostCommand( new_xpFunc0( this, &pxpByteCode::ClearTokenGroupCnd ) ); gcond.AddPostCommand( new_xpFunc0( this, &pxpByteCode::ClearTokenGroupCndTree ) ); // token - pre gtoken.AddCommand( new_xpObjCreate<dtToken>(txpParseTree) ); gtoken.AddCommand( new_xpFunc1( this, &pxpByteCode::SetToken, txpTokenObject ) ); gtoken.AddCommand( new_xpFunc1( this, &pxpByteCode::SetTokenTree, txpParseTree ) ); tcode.AddCommand( new_xpFunc1( txpTokenTreeObject, &dtToken::SetTokenData, txpNodeData(txpParseTree) ) ); tname.AddCommand( new_xpFunc1( txpTokenTreeObject, &dtToken::SetTokenName, txpNodeName(txpParseTree) ) ); tdesc.AddCommand( new_xpFunc1( txpTokenTreeObject, &dtToken::SetDesc, txpNodeName(txpParseTree) ) ); tdesc.AddCommand( new_xpFunc1( txpTokenGroup, &pkgTokenGroup::AddToken, txpToken ) ); tdesc.AddCommand( new_xpFunc2( Decompiler, &pkgDecompiler::AddToken, txpToken, txpTokenGroupCnd ) ); // token - post gtoken.AddPostCommand( new_xpFunc0( txpToken, &dtToken::DumpInfo ) ); gtoken.AddPostCommand( new_xpObjClear(txpParseTree) ); gtoken.AddPostCommand( new_xpFunc0( this, &pxpByteCode::ClearToken ) ); gtoken.AddPostCommand( new_xpFunc0( this, &pxpByteCode::ClearTokenTree ) ); // titem - pre titem.AddCommand( new_xpFunc1( this, &pxpByteCode::SetTokenItemTree, txpParseTree ) ); itype.AddCommand( new_xpObjFactory( txpTokenItemTree, &GDataTypeFactory, &pkgDataTypeFactory::Create, txpNodeName(txpParseTree) ) ); itype.AddCommand( new_xpFunc1( this, &pxpByteCode::SetTokenItem, txpTokenItemTreeObject ) ); iname.AddCommand( new_xpFunc1( txpTokenItem, &pkgDataType::SetDesc, txpNodeName(txpParseTree) ) ); // titem - post titem.AddPostCommand( new_xpFunc1( txpToken, &dtToken::AddItem, txpTokenItem ) ); titem.AddPostCommand( new_xpObjClear(txpParseTree) ); titem.AddPostCommand( new_xpFunc0( this, &pxpByteCode::ClearTokenItem ) ); titem.AddPostCommand( new_xpFunc0( this, &pxpByteCode::ClearTokenItemTree ) ); ffirst.AddCommand( new_xpFunc1( Decompiler, &pkgDecompiler::SetFunctionIdFirst, txpNodeData(txpParseTree) ) ); fextended.AddCommand( new_xpFunc1( Decompiler, &pkgDecompiler::SetFunctionIdExtended, txpNodeData(txpParseTree) ) ); // construct tree starting from leaves // ie: node on right side *cannot* appear anywhere below on left side // token gtoken.AddChild( tcode, pl::one ); gtoken.AddChild( tname, pl::one ); gtoken.AddChild( tdesc, pl::one ); titem.AddChild( itype, pl::one ); titem.AddChild( iname, pl::one ); tdata.AddChild( titem, pl::minone ); tdata.AddChild( ttext, pl::maxone ); gtoken.AddChild( tdata, pl::maxone ); // if cleft.AddChild( ctstream, pl::maxone ); cleft.AddChild( cnum, pl::maxone ); cright.AddChild( ctstream, pl::maxone ); cright.AddChild( cnum, pl::maxone ); ceq.AddChild( cleft, pl::one ); ceq.AddChild( cright, pl::one ); cif.AddChild( ceq, pl::one ); // then cthen.AddChild( gtoken, pl::any ); // group bgroup.AddChild( gname, pl::one ); bgroup.AddChild( gmemo, pl::any ); gcond.AddChild( cif, pl::one ); gcond.AddChild( cthen, pl::one ); bgroup.AddChild( gcond, pl::maxone ); bgroup.AddChild( gtoken, pl::any ); // native functions nfunc.AddChild( fextended, pl::one ); nfunc.AddChild( ffirst, pl::one ); // bytecode bytecode.AddChild( bgroup, pl::minone ); bytecode.AddChild( nfunc, pl::maxone ); ParseTree = new unXmlParseTree( bytecode ); }
/** Here we open the database connection and create the tables if we have to. When we create a table, we use two vector<string> objects. fieldnames and fieldtypes for the names and types of the fields of the SQL table respectively. Then we initialize the SQLTable using the appropriate templates and we also pass the logger object as an argument, since we want to have one global logger. */ bool Contest::initDB() { dbconnection = new SQLiteConnection(DBNAME, logger, true); if (dbconnection->isReady()) { string iname("code"); string tsname("ts"); vector<string> fieldnames, fieldtypes, indexnames; fieldnames.push_back(iname); fieldtypes.push_back("TEXT"); fieldnames.push_back("gid"); fieldtypes.push_back("INTEGER"); fieldnames.push_back("msisdn"); fieldtypes.push_back("TEXT"); fieldnames.push_back(tsname); fieldtypes.push_back("INTEGER"); indexnames.push_back(tsname); indexnames.push_back("gid"); string tablename = "CODES"; Participants = SQLTable<string, partDetails>(dbconnection, tablename, iname, tsname, fieldnames, fieldtypes, indexnames, true); tablename = "WINNINGCODES"; Winners = SQLTable<string, partDetails>(dbconnection, tablename, iname, tsname, fieldnames, fieldtypes, indexnames, true); tablename = "PRIZES"; fieldnames.clear(); fieldtypes.clear(); indexnames.clear(); iname = "ID"; tsname = "periodbegin"; fieldnames.push_back(iname); fieldtypes.push_back("TEXT"); fieldnames.push_back("gid"); fieldtypes.push_back("INTEGER"); fieldnames.push_back("name"); fieldtypes.push_back("TEXT"); fieldnames.push_back(tsname); fieldtypes.push_back("INTEGER"); fieldnames.push_back("periodend"); fieldtypes.push_back("INTEGER"); fieldnames.push_back("qty_init"); fieldtypes.push_back("INTEGER"); fieldnames.push_back("qty_rem"); fieldtypes.push_back("INTEGER"); indexnames.push_back(iname); indexnames.push_back("periodbegin"); indexnames.push_back("periodend"); if (dbconnection->existsTable(tablename) == true) SetupPrizes = false; Prizes = SQLTable<string, giftDetails>(dbconnection, tablename, iname, tsname, fieldnames, fieldtypes, indexnames, true); tablename = "COUNTERS"; fieldnames.clear(); fieldtypes.clear(); indexnames.clear(); iname = "date"; fieldnames.push_back(iname); fieldtypes.push_back("TEXT"); fieldnames.push_back("codes"); fieldtypes.push_back("INTEGER"); fieldnames.push_back("estcodes"); fieldtypes.push_back("INTEGER"); fieldnames.push_back("msisdns"); fieldtypes.push_back("INTEGER"); fieldnames.push_back("prizes"); fieldtypes.push_back("INTEGER"); indexnames.push_back(iname); Counters = SQLTable<string, Day>(dbconnection, tablename, iname, tsname, fieldnames, fieldtypes, indexnames, true); if (Participants.isReady() && Winners.isReady() && Counters.isReady() && Prizes.isReady()) return true; else return false; } dbconnection->enableTransactions(); return true; }
void do_if_stage() { exc_t nstatus = EXC_NONE; word_t fetchpc = gen_f_pc(); word_t valp = fetchpc; bool_t fetch_ok; byte_t instr; byte_t regids = HPACK(REG_NONE, REG_NONE); word_t valc = 0; f_pc = fetchpc; if (fetchpc == 0) { sim_log("Fetch: Fetch pc = 0, nominal pc = 0x%x\n", pc_curr->pc); } /* Ready to fetch instruction. Speculatively fetch register byte and immediate word */ fetch_ok = get_byte_val(mem, valp, &instr); if (fetch_ok) { if_id_next->icode = GET_ICODE(instr); if_id_next->ifun = GET_FUN(instr); } else { if_id_next->icode = I_NOP; if_id_next->ifun = 0; nstatus = EXC_ADDR; } valp++; if (fetch_ok && gen_need_regids()) { fetch_ok = get_byte_val(mem, valp, ®ids); valp ++; } if_id_next->ra = HI4(regids); if_id_next->rb = LO4(regids); if (fetch_ok && gen_need_valC()) { fetch_ok = get_word_val(mem, valp, &valc); valp+= 4; } if_id_next->valp = valp; if_id_next->valc = valc; pc_next->pc = gen_new_F_predPC(); if (!gen_instr_valid()) { byte_t instr = HPACK(if_id_next->icode, if_id_next->ifun); sim_log("Fetch: Instruction code %s (0x%x) invalid\n", iname(instr), instr); nstatus = EXC_INSTR; } pc_next->exception = (nstatus == EXC_NONE) ? EXC_NONE : EXC_BUBBLE; if_id_next->stage_pc = fetchpc; if_id_next->exception = nstatus; /* Recompute icode for one-write implementation of popl */ if_id_next->icode = gen_new_D_icode(); sim_log("Fetch: Fetched %s at 0x%x, ra = %s, rb = %s, valp = 0x%x, status = %s\n", iname(HPACK(if_id_next->icode, if_id_next->ifun)), if_id_next->stage_pc, reg_name(if_id_next->ra), reg_name(if_id_next->rb), if_id_next->valp, exc_name(nstatus)); }
// ###################################################################### void Beobot2_GistSalLocalizerWorkerI::updateMessage (const RobotSimEvents::EventMessagePtr& eMsg, const Ice::Current&) { // Get a gist-sal message if(eMsg->ice_isA("::BeobotEvents::LandmarkSearchQueueMessage")) { BeobotEvents::LandmarkSearchQueueMessagePtr lsqMsg = BeobotEvents::LandmarkSearchQueueMessagePtr::dynamicCast(eMsg); //Get the current request ID int currRequestID = lsqMsg->RequestID; itsInputFnum = currRequestID; LINFO("Got an lsqMessage with Request ID = %d", currRequestID); // get the inputImage its_input_info_mutex.lock(); itsInputImage = Ice2Image<PixRGB<byte> >(lsqMsg->currIma); //itsInputWin->setTitle(sformat("WM: %d",itsInputFnum).c_str()); //itsInputWin->drawImage(itsInputImage, 0, 0); // get the salient region information itsInputVO.clear(); itsVOKeypointsComputed.clear(); itsInputObjOffset.clear(); uint inputSize = lsqMsg->salientRegions.size(); for(uint i = 0; i < inputSize; i++) { BeobotEvents::SalientRegion salReg = lsqMsg->salientRegions[i]; LDEBUG("W[%4d] sp[%4d,%4d] rect[%4d,%4d,%4d,%4d]", i, salReg.salpt.i, salReg.salpt.j, salReg.objRect.tl.i, salReg.objRect.tl.j, salReg.objRect.br.i, salReg.objRect.br.j); // print the pre-attentive feature vector std::vector<float> features; uint fsize = salReg.salFeatures.size(); for(uint j = 0; j < fsize; j++) { features.push_back(salReg.salFeatures[j]); LDEBUG("[%4d]:%7f", j, salReg.salFeatures[j]); } Point2D<int> salpt(salReg.salpt.i, salReg.salpt.j); Point2D<int> offset( salReg.objRect.tl.i, salReg.objRect.tl.j); Rectangle rect = Rectangle::tlbrO (salReg.objRect.tl.j, salReg.objRect.tl.i, salReg.objRect.br.j, salReg.objRect.br.i); // create a visual object for the salient region Image<PixRGB<byte> > objImg = crop(itsInputImage, rect); std::string testRunFPrefix("testRunFPrefix"); std::string iname("iname"); std::string saveFilePath("saveFilePath"); std::string iName(sformat("%s_SAL_%07d_%02d", testRunFPrefix.c_str(), currRequestID, i)); std::string ifName = iName + std::string(".png"); ifName = saveFilePath + ifName; rutz::shared_ptr<VisualObject> vo(new VisualObject (iName, ifName, objImg, salpt - offset, features, std::vector< rutz::shared_ptr<Keypoint> >(), false, false)); itsInputVO.push_back(vo); itsVOKeypointsComputed.push_back(false); itsInputObjOffset.push_back(offset); LDEBUG("[%d] image[%d]: %s sal:[%d,%d] offset:[%d,%d]", currRequestID, i, iName.c_str(), (salpt - offset).i, (salpt - offset).j, offset.i, offset.j); } its_input_info_mutex.unlock(); its_results_mutex.lock(); itsMatchFound.clear(); itsVOmatch.clear(); itsVOmatch.resize(inputSize); itsLmkMatch.clear(); itsLmkMatch.resize(inputSize); itsSegNumMatch.clear(); itsSegNumMatch.resize(inputSize); itsLenTravMatch.clear(); itsLenTravMatch.resize(inputSize); itsNumObjectSearch.clear(); itsNumObjectSearch.resize(inputSize); for(uint i = 0; i < inputSize; i++) itsMatchFound.push_back(false); for(uint i = 0; i < inputSize; i++) itsNumObjectSearch[i] = 0; itsNumJobsProcessed = 0; its_results_mutex.unlock(); // fill the job queue its_job_queue_mutex.lock(); itsJobQueue.clear(); uint njobs = lsqMsg->jobs.size(); for(uint i = 0; i < njobs; i++) { BeobotEvents::LandmarkSearchJob tempJob = lsqMsg->jobs[i]; itsJobQueue.push_back (GSlocJobData(tempJob.inputSalRegID, tempJob.dbSegNum, tempJob.dbLmkNum, tempJob.dbVOStart, tempJob.dbVOEnd)); } // print the job queue std::list<GSlocJobData>::iterator itr = itsJobQueue.begin(); uint count = 0; while (itr != itsJobQueue.end()) { LDEBUG("[%5d] match obj[%d] lDB[%3d][%3d]:[%3d,%3d]", count, (*itr).objNum, (*itr).segNum, (*itr).lmkNum, (*itr).voStartNum,(*itr).voEndNum); itr++; count++; } its_job_queue_mutex.unlock(); } // Got a landmark match results - stop searching for that salient region else if(eMsg->ice_isA("::BeobotEvents::LandmarkMatchResultMessage")) { BeobotEvents::LandmarkMatchResultMessagePtr lmrMsg = BeobotEvents::LandmarkMatchResultMessagePtr::dynamicCast(eMsg); //Get the current request ID //int currRequestID = gistSalMsg->RequestID; BeobotEvents::LandmarkSearchJob tempJob = lmrMsg->matchInfo; LINFO("Got an lmrMessage"); LINFO("LMR -> found match[%d]: with itsLandmarkDB[%d][%d]", tempJob.inputSalRegID, tempJob.dbSegNum, tempJob.dbLmkNum); its_results_mutex.lock(); if(!itsMatchFound[tempJob.inputSalRegID]) { itsMatchFound[tempJob.inputSalRegID] = true; itsSegNumMatch[tempJob.inputSalRegID] = lmrMsg->segNumMatch; itsLenTravMatch[tempJob.inputSalRegID] = lmrMsg->lenTravMatch; } its_results_mutex.unlock(); } else if(eMsg->ice_isA("::BeobotEvents::CancelSearchMessage")) { its_job_queue_mutex.lock(); itsEmptyQueue = true; its_job_queue_mutex.unlock(); its_results_mutex.lock(); LINFO("CancelSearchMessage: %d processed here", itsNumJobsProcessed); its_results_mutex.unlock(); } }
STDMETHODIMP CUUEngine::Encode( BSTR i_iname, BSTR i_oname, BSTR i_nameinfile, long encoding, long lines, long headers, VARIANT destvar, VARIANT fromvar, VARIANT subjectvar, long *retVal) { FILE *outf; int rc, partno; char *onp, *extp, *partname; const char *dest, *from, *subject; MString deststr, fromstr, subjstr; MString iname(i_iname), oname(i_oname), nameinfile(i_nameinfile); dest = (const char *) destvar.bstrVal; if (destvar.vt != VT_BSTR || *dest == EOS) dest = NULL; else { deststr = destvar.bstrVal; dest = (const char *) deststr; } from = (const char *) fromvar.bstrVal; if (fromvar.vt != VT_BSTR || *from == EOS) from = NULL; else { fromstr = fromvar.bstrVal; from = (const char *) fromstr; } subject = (const char *) subjectvar.bstrVal; if (subjectvar.vt != VT_BSTR || *subject == EOS) subject = NULL; else { subjstr = subjectvar.bstrVal; subject = (const char *) subjstr; } if (nameinfile != NULL && nameinfile[0] != EOS) onp = nameinfile.GetBuffer(); // Caller has specified a name else { // Generate our own if ((onp = strrchr(iname, '\\')) == NULL) { // Look for last slash if ((onp = strrchr(iname, ':')) == NULL) onp = iname.GetBuffer(); // No colons, either else onp++; // Point just past colon } else onp++; // Point just past last slash } if (lines == 0 && (extp = strrchr(oname, '.')) != NULL) // Set single-part extension ue.UUSetOption(UUOPT_ENCEXT, 0, extp+1); if (headers) { // User wants headers if (lines == 0) { // Single file if (!OWriteOK && FExist(oname)) { // Can't overwrite output file MessageHandler("Output file exists", UUMSG_ERROR); *retVal = UURET_EXISTS; return(S_OK); } if ((outf = fopen(oname, "w")) == NULL) { MessageHandler("Could not open output file", 1); *retVal = UURET_IOERR; return(S_OK); } NewStep(); // Warn the owner if (headers == UUVBE_SIMPLE) rc = ue.UUEncodeMulti(outf, NULL, iname.GetBuffer(), encoding, onp, NULL, 0); else rc = ue.UUE_PrepSingle(outf, NULL, iname.GetBuffer(), encoding, onp, 0, (char *) dest, (char *) from, (char *) subject, (headers == UUVBE_MAIL)); fclose(outf); } else { // Multi part MString partlocal(oname); // Copy the output name partname = partlocal.GetBuffer(strlen(oname) + 10); // Grab the buffer if ((extp = strrchr(partname, '.')) == NULL) { // No extension? Add one... extp = partname + strlen(partname); *extp++ = '.'; } else extp++; // Just past the last period partno = 1; // First part do { // Always have at least one... sprintf(extp, "%03d", partno); if (!OWriteOK && FExist(partname)) { // Can't overwrite output file MessageHandler("Output file exists", UUMSG_ERROR); *retVal = UURET_EXISTS; return(S_OK); } if ((outf = fopen(partname, "w")) == NULL) { MessageHandler("Error opening output file.", 1); *retVal = UURET_IOERR; return(S_OK); } NewStep(); // Warn the owner crc32_t lcr = 0; if (headers == UUVBE_SIMPLE) rc = ue.UUEncodePartial(outf, NULL, iname.GetBuffer(), encoding, onp, NULL, 0, partno++, (int) lines, &lcr); else rc = ue.UUE_PrepPartial(outf, NULL, iname.GetBuffer(), encoding, onp, 0, partno++, (int) lines, 0, (char *) dest, (char *) from, (char *) subject, (headers == UUVBE_MAIL)); fclose(outf); } while (rc == UURET_CONT); } } else { NewStep(); // Warn the owner rc = ue.UUEncodeToFile(NULL, iname.GetBuffer(), encoding, onp, oname.GetBuffer(), (int) lines); } *retVal = rc; return S_OK; }
// ??? Break this stuff off into an InstrumentPopup class. This class is too // big. void TrackButtons::populateInstrumentPopup(Instrument *thisTrackInstr, QMenu* instrumentPopup) { // pixmaps for icons to show connection states as variously colored boxes // ??? Factor out the icon-related stuff to make this routine clearer. // getIcon(Instrument *) would be ideal, but might not be easy. // getIcon(Device *) would also be needed. static QPixmap connectedPixmap, unconnectedPixmap, connectedUsedPixmap, unconnectedUsedPixmap, connectedSelectedPixmap, unconnectedSelectedPixmap; static bool havePixmaps = false; if (!havePixmaps) { IconLoader il; connectedPixmap = il.loadPixmap("connected"); connectedUsedPixmap = il.loadPixmap("connected-used"); connectedSelectedPixmap = il.loadPixmap("connected-selected"); unconnectedPixmap = il.loadPixmap("unconnected"); unconnectedUsedPixmap = il.loadPixmap("unconnected-used"); unconnectedSelectedPixmap = il.loadPixmap("unconnected-selected"); havePixmaps = true; } Composition &comp = m_doc->getComposition(); // clear the popup instrumentPopup->clear(); QMenu *currentSubMenu = 0; // position index int count = 0; int currentDevId = -1; // Get the list Studio &studio = m_doc->getStudio(); InstrumentList list = studio.getPresentationInstruments(); // For each instrument for (InstrumentList::iterator it = list.begin(); it != list.end(); ++it) { if (!(*it)) continue; // sanity check // get the Localized instrument name, with the string hackery performed // in Instrument QString iname((*it)->getLocalizedPresentationName()); // translate the program name // // Note we are converting the string from std to Q back to std then to // C. This is obviously ridiculous, but the fact that we have programName // here at all makes me think it exists as some kind of necessary hack // to coax tr() into behaving nicely. I decided to change it as little // as possible to get it to compile, and not refactor this down to the // simplest way to call tr() on a C string. QString programName(strtoqstr((*it)->getProgramName())); programName = QObject::tr(programName.toStdString().c_str()); Device *device = (*it)->getDevice(); DeviceId devId = device->getId(); bool connectedIcon = false; // Determine the proper program name and whether it is connected if ((*it)->getType() == Instrument::SoftSynth) { programName = ""; AudioPluginInstance *plugin = (*it)->getPlugin(Instrument::SYNTH_PLUGIN_POSITION); if (plugin) { // we don't translate any plugin program names or other texts programName = strtoqstr(plugin->getDisplayName()); connectedIcon = (plugin->getIdentifier() != ""); } } else if ((*it)->getType() == Instrument::Audio) { connectedIcon = true; } else { QString conn = RosegardenSequencer::getInstance()-> getConnection(devId); connectedIcon = (conn != ""); } // These two are for selecting the correct icon to display. bool instrUsedByMe = false; bool instrUsedByAnyone = false; if (thisTrackInstr && thisTrackInstr->getId() == (*it)->getId()) { instrUsedByMe = true; instrUsedByAnyone = true; } // If we have switched to a new device, we'll create a new submenu if (devId != (DeviceId)(currentDevId)) { currentDevId = int(devId); // For selecting the correct icon to display. bool deviceUsedByAnyone = false; if (instrUsedByMe) deviceUsedByAnyone = true; else { for (Composition::trackcontainer::iterator tit = comp.getTracks().begin(); tit != comp.getTracks().end(); ++tit) { if (tit->second->getInstrument() == (*it)->getId()) { instrUsedByAnyone = true; deviceUsedByAnyone = true; break; } Instrument *instr = studio.getInstrumentById(tit->second->getInstrument()); if (instr && (instr->getDevice()->getId() == devId)) { deviceUsedByAnyone = true; } } } QIcon icon (connectedIcon ? (deviceUsedByAnyone ? connectedUsedPixmap : connectedPixmap) : (deviceUsedByAnyone ? unconnectedUsedPixmap : unconnectedPixmap)); // Create a submenu for this device QMenu *subMenu = new QMenu(instrumentPopup); subMenu->setMouseTracking(true); subMenu->setIcon(icon); // Not needed so long as AA_DontShowIconsInMenus is false. //subMenu->menuAction()->setIconVisibleInMenu(true); // Menu title QString deviceName = QObject::tr(device->getName().c_str()); subMenu->setTitle(deviceName); // QObject name subMenu->setObjectName(deviceName); // Add the submenu to the popup menu instrumentPopup->addMenu(subMenu); // Connect the submenu to slotInstrumentSelected() connect(subMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotInstrumentSelected(QAction*))); currentSubMenu = subMenu; } else if (!instrUsedByMe) {