int main(int ac, char *ag[]) { QToyunda *toyunda; QApplication *qapp; SQArgDescMap optionDesc; QMap<QString, QVariant> option; QDebugErrorHandler *errorHandler; errorHandler = new QDebugErrorHandler(); defineOption(optionDesc); qapp = new QApplication(ac, ag); // Handle arguments QStringList arg = qapp->arguments(); arg.removeFirst(); bool vopt = SQArg::fillWithDesc(option, arg, optionDesc); // Help if (option["help"].toBool() || vopt == false) { QTextStream cout(stdout); cout << "QToyunda\nSynopsis : "; cout << "./qtoyunda --player playername --renderer renderername --video videofile --subtitle subtitlefile\n\n"; cout.flush(); if (option["help"].toBool()) { cout << "All option available :\n"; cout.flush(); SQArg::generateLongHelp(optionDesc); return 0; } return 1; } // Player and renderer option QStringList playerOption; if (!option["playeroption"].toString().isEmpty()) playerOption = option["playeroption"].toString().split(","); QStringList rendererOption; if (!option["rendereroption"].toString().isEmpty()) rendererOption = option["rendereroption"].toString().split(","); rendererOption << "logo=:/main/Toyunda logo.png"; qDebug() << rendererOption; toyunda = new QToyunda(errorHandler); toyunda->setPlayerName(option["player"].toString()); toyunda->setRendererName(option["renderer"].toString()); toyunda->setPlayerOption(playerOption); toyunda->setRendererOption(rendererOption); QDir pluginPath = qApp->applicationDirPath(); pluginPath.cd("plugins"); toyunda->setPluginDirectory(pluginPath); toyunda->loadPlugins(); // FIXME playeroptionhelp and roh must not depend and toyunda if (option["playeroptionhelp"].toBool()) { toyunda->showPlayerOption(); return 0; } if (option["rendereroptionhelp"].toBool()) { toyunda->showRendererOption(); return 0; } qDebug() << "Init toyunda"; if (!toyunda->init()) { qCritical() << "Can't init qtoyunda, abord"; return 1; } qDebug() << "Load files"; toyunda->load(option["video"].toString(), option["subtitle"].toString()); qDebug() << "Play the video"; toyunda->play(); toyunda->showRenderer(); int ret = qapp->exec(); toyunda->dispose(); return ret; }
Expr* PrimInliner::tryInline() { // Returns the failure result or the result of the primitive (if the // primitive can't fail) if the primitive has been inlined; returns // NULL otherwise. If the primitive has been inlined but can't fail, // the bci in the MethodDecoder is set to the first instruction after // the failure block. // NB: The comparisons below should be replaced with pointer comparisons // comparing with the appropriate vmSymbol. Should fix this at some point. char* name = _pdesc->name(); Expr* res = NULL; switch (_pdesc->group()) { case IntArithmeticPrimitive: if (number_of_parameters() == 2) { Expr* x = parameter(0); Expr* y = parameter(1); if (equal(name, "primitiveAdd:ifFail:")) { res = smi_ArithmeticOp(tAddArithOp, x, y); break; } if (equal(name, "primitiveSubtract:ifFail:")) { res = smi_ArithmeticOp(tSubArithOp, x, y); break; } if (equal(name, "primitiveMultiply:ifFail:")) { res = smi_ArithmeticOp(tMulArithOp, x, y); break; } if (equal(name, "primitiveDiv:ifFail:")) { res = smi_Div(x, y); break; } if (equal(name, "primitiveMod:ifFail:")) { res = smi_Mod(x, y); break; } if (equal(name, "primitiveBitAnd:ifFail:")) { res = smi_BitOp(tAndArithOp, x, y); break; } if (equal(name, "primitiveBitOr:ifFail:")) { res = smi_BitOp(tOrArithOp , x, y); break; } if (equal(name, "primitiveBitXor:ifFail:")) { res = smi_BitOp(tXOrArithOp, x, y); break; } if (equal(name, "primitiveRawBitShift:ifFail:")) { res = smi_Shift(x, y); break; } } break; case IntComparisonPrimitive: if (number_of_parameters() == 2) { Expr* x = parameter(0); Expr* y = parameter(1); if (equal(name, "primitiveSmallIntegerEqual:ifFail:")) { res = smi_Comparison(EQBranchOp, x, y); break; } if (equal(name, "primitiveSmallIntegerNotEqual:ifFail:")) { res = smi_Comparison(NEBranchOp, x, y); break; } if (equal(name, "primitiveLessThan:ifFail:")) { res = smi_Comparison(LTBranchOp, x, y); break; } if (equal(name, "primitiveLessThanOrEqual:ifFail:")) { res = smi_Comparison(LEBranchOp, x, y); break; } if (equal(name, "primitiveGreaterThan:ifFail:")) { res = smi_Comparison(GTBranchOp, x, y); break; } if (equal(name, "primitiveGreaterThanOrEqual:ifFail:")) { res = smi_Comparison(GEBranchOp, x, y); break; } } break; case FloatArithmeticPrimitive: break; case FloatComparisonPrimitive: break; case ObjArrayPrimitive: if (equal(name, "primitiveIndexedObjectSize")) { res = array_size(); break; } if (equal(name, "primitiveIndexedObjectAt:ifFail:")) { res = array_at_ifFail(ArrayAtNode::object_at); break; } if (equal(name, "primitiveIndexedObjectAt:put:ifFail:")) { res = array_at_put_ifFail(ArrayAtPutNode::object_at_put); break; } break; case ByteArrayPrimitive: if (equal(name, "primitiveIndexedByteSize")) { res = array_size(); break; } if (equal(name, "primitiveIndexedByteAt:ifFail:")) { res = array_at_ifFail(ArrayAtNode::byte_at); break; } if (equal(name, "primitiveIndexedByteAt:put:ifFail:")) { res = array_at_put_ifFail(ArrayAtPutNode::byte_at_put); break; } break; case DoubleByteArrayPrimitive: if (equal(name, "primitiveIndexedDoubleByteSize")) { res = array_size(); break; } if (equal(name, "primitiveIndexedDoubleByteAt:ifFail:")) { res = array_at_ifFail(ArrayAtNode::double_byte_at); break; } if (equal(name, "primitiveIndexedDoubleByteCharacterAt:ifFail:")) { res = array_at_ifFail(ArrayAtNode::character_at); break; } if (equal(name, "primitiveIndexedDoubleByteAt:put:ifFail:")) { res = array_at_put_ifFail(ArrayAtPutNode::double_byte_at_put);break; } break; case BlockPrimitive: if (strncmp(name, "primitiveValue", 14) == 0) { res = block_primitiveValue(); break; } break; case NormalPrimitive: if (strncmp(name, "primitiveNew", 12) == 0) { res = obj_new(); break; } if (equal(name, "primitiveShallowCopyIfFail:ifFail:")) { res = obj_shallowCopy(); break; } if (equal(name, "primitiveEqual:")) { res = obj_equal(); break; } if (equal(name, "primitiveClass")) { res = obj_class(true); break; } if (equal(name, "primitiveClassOf:")) { res = obj_class(false); break; } if (equal(name, "primitiveHash")) { res = obj_hash(true); break; } if (equal(name, "primitiveHashOf:")) { res = obj_hash(false); break; } if (equal(name, "primitiveProxyByteAt:ifFail:")) { res = proxy_byte_at(); break; } if (equal(name, "primitiveProxyByteAt:put:ifFail:")) { res = proxy_byte_at_put(); break; } break; default: fatal1("bad primitive group %d", _pdesc->group()); break; } if (CompilerDebug) { cout(PrintInlining && (res != NULL))->print("%*sinlining %s %s\n", _scope->depth + 2, "", _pdesc->name(), _usingUncommonTrap ? "(unc. failure)" : (_cannotFail ? "(cannot fail)" : "")); } if (!_usingUncommonTrap && !_cannotFail) theCompiler->reporter->report_prim_failure(_pdesc); return res; }
int main(int argc, char **argv) { int correctAddDelete = 0; if(argIs("/CAD")) // Correct Add Delete { correctAddDelete = 1; } if(argIs("/M")) // Make sabun { char *beforeDir; char *afterDir; char *outDir; char *sabunFile; cout("+----------------------------+\n"); cout("| 変更前のフォルダをドロップ |\n"); cout("+----------------------------+\n"); beforeDir = dropDir(); cout("+----------------------------+\n"); cout("| 変更後のフォルダをドロップ |\n"); cout("+----------------------------+\n"); afterDir = dropDir(); outDir = makeTempDir(NULL); sabunFile = combine(outDir, "Sabun.bin"); makeSabun(sabunFile, beforeDir, afterDir, correctAddDelete); execute_x(xcout("START %s", outDir)); memFree(beforeDir); memFree(afterDir); memFree(outDir); memFree(sabunFile); } else // 差分適用 { char *targetDir; char *sabunFile; cout("+----------------------------------+\n"); cout("| 対象フォルダをドロップ |\n"); cout("| * このフォルダの中身を更新します |\n"); cout("+----------------------------------+\n"); targetDir = dropDir(); cout("+------------------------+\n"); cout("| 差分ファイルをドロップ |\n"); cout("+------------------------+\n"); sabunFile = dropFile(); cout("\n"); cout("対象フォルダを変更します。\n"); cout("処理を開始してからはキャンセル出来ません。\n"); cout("続行するにはエンターキーを押してね。\n"); if(clearGetKey() == 0x0d) { cout("\n"); cout("アップデートしています..."); if(sabunUpdate(sabunFile, targetDir) == 0) // ? アップデート対象外だった。 { cout("\r"); cout("+----------------------------+\n"); cout("| エラー/アップデート対象外 |\n"); cout("+----------------------------+\n"); } else cout("\rアップデートは完了しました。\n"); clearWaitKey(5000); // 見えるように } memFree(targetDir); memFree(sabunFile); } }
static void ShowSaveData(void) { cout("StageNo: %u\n", StageNo); cout("HiScore: %u\n", HiScore); cout("ExtraOpened: %d\n", m_01(ExtraOpened)); }
void MainWindow::slotPrintStdOut() { QTextStream cout(stdout); cout << sudoProc->readAllStandardOutput(); }
QStringList Manager::newMove(const QString &indexString, const int &level) { QTextStream cout(stdout); // set cout for console debug QStringList array; cout << QDir::setCurrent("/usr/share/harbour-pocketmonsters/qml/pages/xmls/") << endl; QFile pokedex( indexString + ".xml"); cout << pokedex.open(QIODevice::ReadOnly) << endl; QXmlStreamReader xml(&pokedex); QString newMoveId; while (!xml.atEnd() && !xml.hasError()) { xml.readNext(); if ( xml.isStartElement() && xml.name().toString() == "move" && xml.attributes().value("level").toString() == QString::number(level) ) { cout << "found :" << xml.attributes().value("id").toString() << endl; newMoveId = xml.attributes().value("id").toString(); } } if (xml.hasError()) { cout << "XML error: " << xml.errorString() << "line:column - " << xml.lineNumber() << ":" << xml.columnNumber() << endl; } else if (xml.atEnd()) { cout << "Reached end, done" << endl; } cout << QDir::setCurrent("/usr/share/harbour-pocketmonsters/qml/pages/xmls/") << endl; QFile movedex( "movedex.xml"); cout << movedex.open(QIODevice::ReadOnly) << endl; QXmlStreamReader xml2(&movedex); bool found = false; while (!xml2.atEnd() && !xml2.hasError()) { xml2.readNext(); QXmlStreamAttributes attributes = xml2.attributes(); QString name = xml2.name().toString(); if ( !found && xml2.isStartElement() && name == "index" && attributes.value("id").toString() == newMoveId ) { array.append(attributes.value("id").toString()); found = true; } if ( found && xml2.isEndElement() && name == "index") found = false; if ( found && xml2.isStartElement() && name != "index") array.append(xml2.readElementText()); } if (xml2.hasError()) { cout << "XML error: " << xml2.errorString() << " - line:column - " << xml2.lineNumber() << ":" << xml2.columnNumber() << endl; } else if (xml2.atEnd()) { cout << "Reached end, done" << endl; } for ( int i = 0; i < array.length(); i++) cout << array[i] << ":"; cout << endl; return array; }
bool juezNormal(bool compareWhite, string archSalidaEsperada) { ofstream cout("logJN.txt", fstream::app); bool accepted = true; string archAlum = "salida_exec_alumno"; char c; ifstream respCorrecta(archSalidaEsperada.c_str()); ifstream respAlumno(archAlum.c_str()); if(!respAlumno.good()) { cout << "No se puede leer el archivo de resultado del alumno." << endl; } else { //cout << "Abrí el archivo del alumno." << endl; } if(!respCorrecta.good()) { cout << "No se puede abrir la salida esperada." << endl; return false; } else { //cout << "Abrí el archivo de salida esperada." << endl; } cout << "\nLa respuesta esperada es:" << endl; cout << "-----" << endl; while(respCorrecta.get(c)) { cout << c; } cout << "-----" << endl; cout << endl << "La respuesta del alumno fue:" << endl; cout << "-----" << endl; while(respAlumno.get(c)) { cout << c; } cout << "-----" << endl << endl; respCorrecta.close(); respAlumno.close(); respCorrecta.open(archSalidaEsperada.c_str()); respAlumno.open(archAlum.c_str()); if(compareWhite) { char caracterEsp, caracterAlum; //cout << endl << "\tComparo en modo estricto " << archSalidaEsperada << " con " << archAlum << endl; while(respCorrecta.good()) { respCorrecta.get(caracterEsp); //Comparo caracter por caracter if(respAlumno.good()) { respAlumno.get(caracterAlum); cout << "Comparo "; switch(caracterEsp) { case '\n': cout << "\\n"; case '\r': cout << "\\r"; case '\t': cout << "\\t"; default: cout << caracterEsp; } cout << " con "; switch(caracterAlum) { case '\n': cout << "\\n"; case '\r': cout << "\\r"; case '\t': cout << "\\t"; default: cout << caracterEsp; } cout << "\t"; if(caracterEsp != caracterAlum) { accepted = false; cout << "Mal" << endl; } else { cout << "Bien" << endl; } } else { accepted = false; cout << "El archivo de correcto es más largo que el de respuesta del alumno." << endl; cout << "Sugerencia: Agregue salto de linea al final del archivo del alumno." << endl; break; } } if(respAlumno.peek() != EOF) { accepted = false; cout << "El archivo de respuesta del alumno es más largo que el correcto." << endl; cout << "Sugerencia: Quite un salto de linea o espacio al final del archivo del alumno." << endl; } cout << "Terminé de comparar." << endl; } else // Modo normal. { string cadenaAlum, cadenaEsp; //cout << endl << "\tComparo en modo normal " << archSalidaEsperada << " con " << archAlum << endl; while(respCorrecta >> cadenaEsp) { if(respAlumno >> cadenaAlum) { //cout << "Comparo " << cadenaAlum << " con " << cadenaEsp << "\t"; if(cadenaAlum != cadenaEsp) { accepted = false; //cout << "Mal" << endl; } else { //cout << "Bien" << endl; } } else { accepted = false; cout << "La salida del alumno está incompleta." << endl; } } if(respAlumno >> cadenaAlum) { accepted = false; cout << "La salida del alumno tiene más cadenas de caracteres de las que debe." << endl; } }
void bootloader(unsigned timeout) { int c; int arg = 0; unsigned i; unsigned address = board_info.fw_size; /* force erase before upload will work */ uint32_t first_word = 0xffffffff; static union { uint8_t c[256]; uint32_t w[64]; } flash_buffer; /* (re)start the timer system */ systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB); systick_set_reload(board_info.systick_mhz * 1000); /* 1ms tick, magic number */ systick_interrupt_enable(); systick_counter_enable(); /* if we are working with a timeout, start it running */ if (timeout) timer[TIMER_BL_WAIT] = timeout; while (true) { // Wait for a command byte led_off(LED_ACTIVITY); do { /* if we have a timeout and the timer has expired, return now */ if (timeout && !timer[TIMER_BL_WAIT]) return; /* try to get a byte from the host */ c = cin_wait(0); } while (c < 0); led_on(LED_ACTIVITY); // common argument handling for commands switch (c) { case PROTO_GET_SYNC: case PROTO_CHIP_ERASE: case PROTO_CHIP_VERIFY: case PROTO_DEBUG: /* expect EOC */ if (cin_wait(1000) != PROTO_EOC) goto cmd_bad; break; case PROTO_PROG_MULTI: /* expect count */ arg = cin_wait(1000); if (arg < 0) goto cmd_bad; break; case PROTO_GET_DEVICE: case PROTO_READ_MULTI: /* expect arg/count then EOC */ arg = cin_wait(1000); if (arg < 0) goto cmd_bad; if (cin_wait(1000) != PROTO_EOC) goto cmd_bad; break; } // handle the command byte switch (c) { case PROTO_GET_SYNC: // sync break; case PROTO_GET_DEVICE: // report board info switch (arg) { case PROTO_DEVICE_BL_REV: cout((uint8_t *)&bl_proto_rev, sizeof(bl_proto_rev)); break; case PROTO_DEVICE_BOARD_ID: cout((uint8_t *)&board_info.board_type, sizeof(board_info.board_type)); break; case PROTO_DEVICE_BOARD_REV: cout((uint8_t *)&board_info.board_rev, sizeof(board_info.board_rev)); break; case PROTO_DEVICE_FW_SIZE: cout((uint8_t *)&board_info.fw_size, sizeof(board_info.fw_size)); break; default: goto cmd_bad; } break; case PROTO_CHIP_ERASE: // erase the program area + read for programming flash_unlock(); for (i = 0; flash_func_sector_size(i) != 0; i++) flash_func_erase_sector(i); address = 0; break; case PROTO_CHIP_VERIFY: // reset for verification of the program area address = 0; break; case PROTO_PROG_MULTI: // program bytes if (arg % 4) goto cmd_bad; if ((address + arg) > board_info.fw_size) goto cmd_bad; if (arg > sizeof(flash_buffer.c)) goto cmd_bad; for (i = 0; i < arg; i++) { c = cin_wait(1000); if (c < 0) goto cmd_bad; flash_buffer.c[i] = c; } if (cin_wait(1000) != PROTO_EOC) goto cmd_bad; if (address == 0) { // save the first word and don't program it until // everything else is done first_word = flash_buffer.w[0]; // replace first word with bits we can overwrite later flash_buffer.w[0] = 0xffffffff; } arg /= 4; for (i = 0; i < arg; i++) { flash_func_write_word(address, flash_buffer.w[i]); address += 4; } break; case PROTO_READ_MULTI: // readback bytes if (arg % 4) goto cmd_bad; if ((address + arg) > board_info.fw_size) goto cmd_bad; arg /= 4; /* handle readback of the not-yet-programmed first word */ if ((address == 0) && (first_word != 0xffffffff)) { cout((uint8_t *)&first_word, 4); address += 4; arg--; } while (arg-- > 0) { cout_word(flash_func_read_word(address)); address += 4; } break; case PROTO_BOOT: // program the deferred first word if (first_word != 0xffffffff) { flash_func_write_word(0, first_word); // revert in case the flash was bad... first_word = 0xffffffff; } // quiesce and jump to the app return; case PROTO_DEBUG: // XXX reserved for ad-hoc debugging as required break; default: continue; } // we got a command worth syncing, so kill the timeout because // we are probably talking to the uploader timeout = 0; // send the sync response for this command sync_response(); continue; cmd_bad: // Currently we do nothing & let the programming tool time out // if that's what it wants to do. // Let the initial delay keep counting down so that we ignore // random chatter from a device. while(true); continue; } }
void Thing::show() { QTextStream cout(stdout); cout << m_Number << '\t' << m_Character << endl; }
static void sync_response(void) { cout(PROTO_INSYNC); // "in sync" cout(PROTO_OK); // "OK" }
static void cout_word(uint32_t val) { cout((uint8_t *)&val, 4); }
// Bootloader protocol logic // static void bootloader(void) { uint8_t c; uint8_t count, i; static uint16_t address; // Wait for a command byte LED_BOOTLOADER = LED_ON; c = cin(); LED_BOOTLOADER = LED_OFF; // common tests for EOC switch (c) { case PROTO_GET_SYNC: case PROTO_GET_DEVICE: case PROTO_CHIP_ERASE: case PROTO_PARAM_ERASE: case PROTO_READ_FLASH: case PROTO_DEBUG: if (cin() != PROTO_EOC) goto cmd_bad; } switch (c) { case PROTO_GET_SYNC: // sync break; case PROTO_GET_DEVICE: cout(BOARD_ID); cout(board_frequency); break; case PROTO_CHIP_ERASE: // erase the program area flash_erase_app(); break; case PROTO_PARAM_ERASE: flash_erase_scratch(); break; case PROTO_LOAD_ADDRESS: // set address address = cin(); address |= (uint16_t)cin() << 8; if (cin() != PROTO_EOC) goto cmd_bad; break; case PROTO_PROG_FLASH: // program byte c = cin(); if (cin() != PROTO_EOC) goto cmd_bad; flash_write_byte(address++, c); break; case PROTO_READ_FLASH: // readback byte c = flash_read_byte(address++); cout(c); break; case PROTO_PROG_MULTI: count = cin(); if (count > sizeof(buf)) goto cmd_bad; for (i = 0; i < count; i++) buf[i] = cin(); if (cin() != PROTO_EOC) goto cmd_bad; for (i = 0; i < count; i++) flash_write_byte(address++, buf[i]); break; case PROTO_READ_MULTI: count = cin(); if (cin() != PROTO_EOC) goto cmd_bad; for (i = 0; i < count; i++) { c = flash_read_byte(address++); cout(c); } break; case PROTO_REBOOT: // generate a software reset, which should boot to the application RSTSRC |= (1 << 4); case PROTO_DEBUG: // XXX reserved for ad-hoc debugging as required break; default: goto cmd_bad; } sync_response(); cmd_bad: return; }
void ImageFile::printImageContents() { QTextStream cout(stdout); for(int i=0; i<lectura.size(); i++) cout<<lectura.at(i)<<endl; }
int main(int argc, char **argv) { int changed = 0; if(argIs("/D")) { GameDir = nextArg(); goto readArgs; } // Check 'GameDir' { char *file; errorCase_m(!existDir(GameDir), "Wrong Game-Dir"); file = combine(GameDir, "koumajou.exe"); errorCase_m(!existFile(file), "Wrong Game-Dir, koumajou.exe does not exist!"); memFree(file); file = combine(GameDir, "data"); errorCase_m(!existDir(file), "Wrong Game-Dir, data does not exist!"); memFree(file); } LoadSaveData(); ShowSaveData(); readArgs: if(argIs("/S")) { StageNo = toValue(nextArg()); changed = 1; goto readArgs; } if(argIs("/H")) { HiScore = toValue(nextArg()); changed = 1; goto readArgs; } if(argIs("/E+")) { ExtraOpened = 1; changed = 1; goto readArgs; } if(argIs("/E-")) { ExtraOpened = 0; changed = 1; goto readArgs; } if(changed) { cout(">\n"); ShowSaveData(); OutputSaveData(); } }
void Compiler::computeBlockInfo() { FlagSetting(EliminateUnneededNodes, true); // unused context nodes must be eliminated GrowableArray<InlinedScope*>* allContexts = new GrowableArray<InlinedScope*>(25); topScope->collectContextInfo(allContexts); // for now, just allocate all contexts as in interpreter // fix this later: collect all uplevel-accessed PRegs at same loop depth, form physical // contexts for these // also, if uplevel-read and single def --> could copy into context and keep // stack/register copy // remove all unused contexts // need to iterate because removing a nested context may enable removal of a parent context // (could avoid iteration with topo sort, but there are few contexts anyway) bool changed = EliminateContexts; while (changed) { changed = false; for (int i = allContexts->length() - 1; i >= 0; i--) { InlinedScope* s = allContexts->at(i); if (s == NULL) continue; PReg* contextPR = s->context(); assert(contextPR->isSinglyAssigned(), "should have exactly one def"); GrowableArray<Expr*>* temps = s->contextTemporaries(); bool noUplevelAccesses = true; // check if all context temps can be stack-allocated for (int j = temps->length() - 1; j >= 0; j--) { PReg* r = temps->at(j)->preg(); if (r->uplevelR() || r->uplevelW() // this temp is still uplevel-accessed, so can't eliminate context || (r->isBlockPReg() && !r->isUnused()) // this block still forces a context ) { noUplevelAccesses = false; break; } } // TO DO: check if context is needed for NLRs // (noUplevelAccesses alone does not allow elimination) if (/*noUplevelAccesses || */contextPR->isSinglyUsed()) { // can eliminate context -- no uplevel-accessed vars // (single use is context initializer) if (CompilerDebug) cout(PrintEliminateContexts)->print("%*s*eliminating context %s\n", s->depth, "", contextPR->safeName()); contextPR->scope()->gen()->removeContextCreation(); allContexts->at_put(i, NULL); // make code generator break if it tries to access this context changed = true; } } } // now collect all remaining contexts int i = allContexts->length(); contextList = new GrowableArray<InlinedScope*>(i, i, NULL); while (i-- > 0) { // should merge several contexts into one physical context if possible // fix this later InlinedScope* s = allContexts->at(i); if (s == NULL) continue; PReg* contextPR = s->context(); if (CompilerDebug) { cout(PrintEliminateContexts)->print("%*s*could not eliminate context %s in scope %s\n", s->depth, "", contextPR->safeName(), s->key()->print_string()); } reporter->report_context(s); contextList->at_put(i, s); ContextCreateNode* c = s->contextInitializer()->creator(); c->set_contextNo(i); GrowableArray<Expr*>* temps = s->contextTemporaries(); // allocate the temps in this context (but only if they're used) int ntemps = temps->length(); int size = 0; for (int j = 0; j < ntemps; j++) { PReg* p = temps->at(j)->preg(); // should be: // if (p->isUsed() && (p->uplevelR() || p->uplevelW())) { // but doesn't work yet (probably must fix set_self_via_context etc.) // -Urs 6/96 if (p->isUsed()) { // allocate p to context temp assert(p->scope() == s || p->isBlockPReg(), "oops"); Location loc = Mapping::contextTemporary(i, size, s->scopeID()); if (p->isBlockPReg()) { // Blocks aren't actually assigned (at the PReg level) so that the inlining info // isn't lost. Thus we need to create a fake destination here if the context exists. SAPReg* dest = new SAPReg(s, loc, true, true, PrologueBCI, EpilogueBCI); Expr* e = new UnknownExpr(dest, NULL); //contextPR->scope()->contextInitializer()->initialize(j, init); temps->at_put(j, e); } else { p->allocateTo(loc); } size++; } } c->set_sizeOfContext(size); if (size < ntemps && c->scope()->number_of_noninlined_blocks() > 0) { // this hasn't been exercised much compiler_warning("while compiling %s: eliminated some context temps", key->print_string()); } } // Compute the number of noninlined blocks for the nmethod and allocate const int nblocks = topScope->number_of_noninlined_blocks(); if (is_method_compile() || nblocks > 0) { // allocate nblocks+1 jumpTable entries const jumpTableID id = Universe::code->jump_table()->allocate(nblocks + 1); if (is_method_compile()) { main_jumpTable_id = id; } else { promoted_jumpTable_id = id; } // first is for nmethod itself int block_index = 1; for (int i = bbIterator->exposedBlks->length() - 1; i >= 0; i--) { BlockPReg* blk = bbIterator->exposedBlks->at(i); if (blk->isUsed()) { assert(block_index <= nblocks, "nblocks too small"); blk->closure()->set_id(id.sub(block_index++)); } } assert(nblocks + 1 == block_index, "just checking"); } }
int main(int argc, char *argv[]) { QTextStream cout(stdout); QTime phaseTimer; FPGrowth* fpgrowth; int duration; QList<ItemList> frequentItemsets; QList<SupportCount> frequentItemsetsSupportCounts; ItemNQHash itemNamesAndQuantities; QPair<QHash<ItemID, ItemName>, QHash<ItemID, QPair<Quantity, Quantity> > > intervalFrequentItemsetsMappings; QList<int> durations; QString filename; float minimumSupport; float minimumConfidence; if (argc < 2) { QTextStream cerr(stderr); cerr << "Usage: DMP <inputfile> <minsup> <minconf>" << endl << "\t- inputfile must be a .arff file with numeric attributes" << endl << "\t- minsup must be a float (percentage)" << endl << "\t- minconf must be a float (percentage)" << endl; cerr.flush(); exit(1); } else { filename = QString(argv[1]); minimumSupport = atof(argv[2]); minimumConfidence = atof(argv[3]); } fpgrowth = new FPGrowth(filename, minimumSupport); // Preprocessing stages. cout << "|- PREPROCESSING" << endl; // Stage 1. cout << " |- Preprocessing stage 1: parsing item names, quantities and support counts." << endl; phaseTimer.start(); fpgrowth->preprocessingPhase1(); durations.append(phaseTimer.elapsed()); itemNamesAndQuantities = fpgrowth->getItemNQs(); cout << QString(" |- Duration: %1 ms.").arg(durations.last()) << endl; // Stage 2. cout << " |- Preprocessing stage 2: parsing transactions and building an FP-tree." << endl; phaseTimer.start(); fpgrowth->preprocessingPhase2(); durations.append(phaseTimer.elapsed()); cout << QString(" |- Duration: %1 ms.").arg(durations.last()) << endl; // Calculating stages. cout << "|- CALCULATING" << endl; // Stage 3. cout << " |- Calculating stage 1: frequent itemset generation." << endl; phaseTimer.start(); frequentItemsets = fpgrowth->calculatingPhase1(); durations.append(phaseTimer.elapsed()); cout << QString(" |- Duration: %1 ms.").arg(durations.last()) << endl; // Stage 4. cout << " |- Calculating stage 2: calculate support for frequent itemsets." << endl; phaseTimer.start(); frequentItemsetsSupportCounts = fpgrowth->calculatingPhase2(frequentItemsets); durations.append(phaseTimer.elapsed()); cout << QString(" |- Duration: %1 ms.").arg(durations.last()) << endl; // Stage 5. cout << " |- Calculating stage 3: rule generation" << endl; phaseTimer.start(); QList<AssociationRule> associationRules = RuleMiner::generateAssociationRules(frequentItemsets, frequentItemsetsSupportCounts, minimumConfidence); durations.append(phaseTimer.elapsed()); cout << QString(" |- Duration: %1 ms.").arg(durations.last()) << endl; // Stage 6. cout << " |- Calculating stage 4: transform frequent itemsets for interval rule generation" << endl; phaseTimer.start(); QList<ItemList> intervalFrequentItemsets = frequentItemsets; intervalFrequentItemsetsMappings = IntervalTransformer::transform(&intervalFrequentItemsets, itemNamesAndQuantities, minimumConfidence); QHash<ItemID, ItemName> idNameMapping = intervalFrequentItemsetsMappings.first; QHash<ItemID, QPair<Quantity, Quantity> > idQuantitiesMapping = intervalFrequentItemsetsMappings.second; durations.append(phaseTimer.elapsed()); cout << QString(" |- Duration: %1 ms.").arg(durations.last()) << endl; // Stage 7. cout << " |- Calculating stage 5: interval rule generation" << endl; phaseTimer.start(); QList<SupportCount> empty; QList<AssociationRule> intervalAssociationRules = RuleMiner::generateAssociationRules(intervalFrequentItemsets, empty, minimumConfidence); durations.append(phaseTimer.elapsed()); cout << QString(" |- Duration: %1 ms.").arg(durations.last()) << endl; qDebug() << intervalAssociationRules; // Actual processing time. duration = 0; for (int i = 1; i < durations.size(); i++) duration += durations[i]; cout << QString("ACTUAL PROCESSING TIME: %1 ms (excludes preprocesing stage 1)").arg(duration) << endl; // Total time. duration = 0; foreach (int d, durations) duration += d; cout << QString("TOTAL PROCESSING TIME: %1 ms (all stages)").arg(duration) << endl; // Output rules of type A. cout << endl << "Rules of type A:" << endl; if (associationRules.size() == 0) cout << "\tNone." << endl; foreach (AssociationRule rule, associationRules) { // Prefix. cout << "\t"; // Antecedent. cout << "{"; for (int i = 0; i < rule.antecedent.size(); i++) { if (i > 0) cout << ", "; Item item = rule.antecedent[i]; cout << itemNamesAndQuantities[item.id].name.toStdString().c_str(); cout << "="; cout << itemNamesAndQuantities[item.id].quantity; } cout << "}"; // Arrow. cout << " => "; // Consequent; cout << "{"; for (int i = 0; i < rule.consequent.size(); i++) { if (i > 0) cout << ", "; Item item = rule.consequent[i]; cout << itemNamesAndQuantities[item.id].name.toStdString().c_str(); cout << "="; cout << itemNamesAndQuantities[item.id].quantity; } cout << "}"; // Confidence. cout << " (conf=" << rule.confidence << ")" << endl; }
QStringList Manager::fetchMonster(const int &id, const int &level) { QTextStream cout(stdout); // set cout for console debug QStringList array; QString idString; if ( id < 10 ) idString = "00" + QString::number(id); else if ( id < 100) idString = "0" + QString::number(id); else idString = QString::number(id); array.append(QString::number(id)); array.append(idString); array.append(QString::number(level)); cout << QDir::setCurrent("/usr/share/harbour-pocketmonsters/qml/pages/xmls/") << endl; QFile pokedex( idString + ".xml"); cout << pokedex.open(QIODevice::ReadOnly) << endl; QXmlStreamReader xml(&pokedex); while (!xml.atEnd() && !xml.hasError()) { xml.readNext(); if ( xml.isStartElement() && xml.name().toString() == "index" && xml.attributes().value("id").toString() == idString) { xml.readNext(); } else if ( ( xml.name().toString() == "moveset" ) ) { break; } if ( xml.isStartElement() ) { QString string = xml.readElementText(); array.append(string); } } if (xml.hasError()) { cout << "XML error: " << xml.errorString() << "line:column - " << xml.lineNumber() << ":" << xml.columnNumber() << endl; } else if (xml.atEnd()) { cout << "Reached end, done" << endl; } QVector <int> levelsArray; QVector <int> idsArray; while (!xml.atEnd() && !xml.hasError()) { xml.readNext(); QXmlStreamAttributes attributes = xml.attributes(); if ( xml.isStartElement() && xml.name().toString() == "move") { levelsArray.append(attributes.value("level").toInt()); idsArray.append(attributes.value("id").toInt()); } } if (xml.hasError()) { cout << "XML error: " << xml.errorString() << "line:column - " << xml.lineNumber() << ":" << xml.columnNumber() << endl; } else if (xml.atEnd()) { cout << "Reached end, done" << endl; } if ( levelsArray.length() < 5 ) { if ( level >= levelsArray[0]) array.append(QString::number(idsArray[0])); if ( level >= levelsArray[1]) array.append(QString::number(idsArray[1])); if ( level >= levelsArray[2]) array.append(QString::number(idsArray[2])); if ( level >= levelsArray[3]) array.append(QString::number(idsArray[3])); } while ( array.length() < 23 ) array.append(QString::number(0)); for ( int i = 0; i < array.length(); i++) { cout << array[i] << ";"; } cout << endl; fetchMonsterDone(); return array; }
static void MainLoop(void) { uint ip = 0; if(!DoLock()) return; removeFileIfExist(ParamsFile); removeFileIfExist(AnswerFile); mutexRelease(MutexHandle); SockStartup(); cout("START\n"); while(!collectEvents(StopAppEventHandle, 0)) { collectEvents(StartEventHandle, 3000); if(!DoLock()) break; if(existFile(ParamsFile)) { char *ansFile; if(Serializer) { char *wrkFile = makeTempFile(NULL); Serializer(ParamsFile, wrkFile); removeFile(ParamsFile); moveFile(wrkFile, ParamsFile); memFree(wrkFile); } removeFileIfExist(AnswerFile); // Cleanup mutexRelease(MutexHandle); cout("REQUEST START %I64u\n", getFileSize(ParamsFile)); ansFile = sockClient((uchar *)&ip, ServerDomain, ServerPort, ParamsFile, Idle); cout("REQUEST END %08x\n", ansFile); if(StopAppEventCaught || !DoLock()) { if(ansFile) { removeFile(ansFile); memFree(ansFile); } break; } removeFileIfExist(AnswerFile); // Cleanup (2bs) if(ansFile) { if(Deserializer) { Deserializer(ansFile, AnswerFile); removeFile(ansFile); } else moveFile(ansFile, AnswerFile); memFree(ansFile); cout("ANSWER %I64u\n", getFileSize(AnswerFile)); } removeFileIfExist(ParamsFile); // Cleanup eventSet(AnswerEventHandle); // リクエストの完了(応答)を通知 } mutexRelease(MutexHandle); } cout("END\n"); SockCleanup(); if(handleWaitForMillis(MutexHandle, 2000)) { // Cleanup removeFileIfExist(ParamsFile); removeFileIfExist(AnswerFile); mutexRelease(MutexHandle); } }
void Manager::saveActive( const QStringList &list) { QTextStream cout(stdout); // set cout for console debug QDir dir("/home/nemo/.local/share/harbour-pocketmonsters"); if (!dir.exists()) dir.mkpath("."); cout << QDir::setCurrent("/home/nemo/.local/share/harbour-pocketmonsters") << endl; QFile file("active.xml"); if ( file.exists()) { file.remove(); QFile file("active.xml"); } cout << file.open(QIODevice::ReadWrite) << endl; QXmlStreamWriter xml( &file ); xml.setAutoFormatting(true); xml.writeStartDocument(); xml.writeStartElement("index"); xml.writeAttribute("id", list[0] ); xml.writeTextElement("name", list[1] ) ; xml.writeTextElement("type1", list[2] ) ; xml.writeTextElement("type2", list[3] ) ; xml.writeTextElement("level",list[4] ) ; xml.writeTextElement("exp", list[5] ) ; xml.writeTextElement("life", list[6] ) ; xml.writeTextElement("hpev", list[7] ) ; xml.writeTextElement("atkev",list[8] ) ; xml.writeTextElement("defev", list[9] ) ; xml.writeTextElement("satkev", list[10] ) ; xml.writeTextElement("sdefev", list[11] ) ; xml.writeTextElement("speev", list[12] ) ; xml.writeStartElement("moveset") ; xml.writeEmptyElement("move") ; xml.writeAttribute("id", list[13] ) ; xml.writeAttribute("pp", list[14] ) ; xml.writeEmptyElement("move") ; xml.writeAttribute("id", list[15] ) ; xml.writeAttribute("pp", list[16] ) ; xml.writeEmptyElement("move") ; xml.writeAttribute("id", list[17] ) ; xml.writeAttribute("pp", list[18] ) ; xml.writeEmptyElement("move") ; xml.writeAttribute("id", list[19] ) ; xml.writeAttribute("pp", list[20] ) ; xml.writeEndElement() ; // moveset xml.writeEndElement(); // index xml.writeEndDocument(); saveActiveDone(); // Do Something }
void MainWindow::slotPrintStdErr() { QTextStream cout(stderr); cout << sudoProc->readAllStandardError(); }
void c_label (const char *lab) { cout ("__N%s:\n", lab); add_fixup (0, C_ADDR, lab); }
void Recipe::print(){ QTextStream cout(stdout); cout << "Recipe" << endl;; cout << "=========================================================" << endl;; cout << "id:" << id << endl;; cout << "large_cup:" << large_cup<< endl;; cout << "medium_cup:" << medium_cup<< endl; cout << "small_cup:" << small_cup<< endl; cout << "seq1:" << seq1<< endl; cout << "seq2:" << seq2<< endl; cout << "seq3:" << seq3<< endl; cout << "dispense_type:" << dispense_type<< endl; cout << "default_cup_size:" << default_cup_size<< endl; cout << "left_bib_type:" << left_bib_type<< endl; cout << "left_bib_pressure_time:" << left_bib_pressure_time<< endl; cout << "left_bib_percent:" << left_bib_percent<< endl; cout << "left_bib_mild_ratio:" << left_bib_mild_ratio<< endl; cout << "left_bib_norm_ratio:" << left_bib_norm_ratio<< endl; cout << "left_bib_strong_ratio:" << left_bib_strong_ratio<< endl; cout << "left_bib_default_ratio:" << left_bib_default_ratio<< endl; cout << "left_bib_water_flow:" << left_bib_water_flow<< endl; cout << "left_bib_ingredient_start:" << left_bib_ingredient_start<< endl; cout << "left_bib_airvalve:" << left_bib_airvalve<< endl; cout << "left_bib_airpump_start:" << left_bib_airpump_start<< endl; cout << "left_bib_airpump_stop:" << left_bib_airpump_stop<< endl; cout << "left_bib_airpump_speed:" << left_bib_airpump_speed<< endl; cout << "left_bib_after_flush_vol:" << left_bib_after_flush_vol<< endl; cout << "right_bib_type:" << right_bib_type<< endl; cout << "right_bib_pressure_time:" << right_bib_pressure_time<< endl; cout << "right_bib_percent:" << right_bib_percent<< endl; cout << "right_bib_mild_ratio:" << right_bib_mild_ratio<< endl; cout << "right_bib_norm_ratio:" << right_bib_norm_ratio<< endl; cout << "right_bib_strong_ratio:" << right_bib_strong_ratio<< endl; cout << "right_bib_default_ratio:" << right_bib_default_ratio<< endl; cout << "right_bib_water_flow:" << right_bib_water_flow<< endl; cout << "right_bib_ingredient_start:" << right_bib_ingredient_start<< endl; cout << "right_bib_airvalve:" << right_bib_airvalve<< endl; cout << "right_bib_airpump_start:" << right_bib_airpump_start<< endl; cout << "right_bib_airpump_stop:" << right_bib_airpump_stop<< endl; cout << "right_bib_airpump_speed:" << right_bib_airpump_speed<< endl; cout << "right_bib_after_flush_vol:" << right_bib_after_flush_vol<< endl; cout << "instant_type:" << instant_type<< endl; cout << "instant_pressure_time:" << instant_pressure_time<< endl; cout << "instant_percent:" << instant_percent<< endl; cout << "instant_default_pwm:" << instant_default_pwm<< endl; cout << "instant_water_flow:" << instant_water_flow<< endl; cout << "instant_ingredient_gram_strong:" << instant_ingredient_gram_strong<< endl; cout << "instant_ingredient_gram_norm:" << instant_ingredient_gram_norm<< endl; cout << "instant_ingredient_gram_mild:" << instant_ingredient_gram_mild<< endl; cout << "instant_ingredient_mild_pwm:" << instant_ingredient_mild_pwm<< endl; cout << "instant_ingredient_norm_pwm:" << instant_ingredient_norm_pwm<< endl; cout << "instant_ingredient_strong_pwm:" << instant_ingredient_strong_pwm<< endl; cout << "instant_ingredient_rtd_standard:" << instant_ingredient_rtd_standard<< endl; cout << "instant_mixer_start_delay:" << instant_mixer_start_delay<< endl; cout << "instant_mixer_stop_delay:" << instant_mixer_stop_delay<< endl; cout << "instant_mixer_speed:" << instant_mixer_speed<< endl; cout << "instant_after_flush_vol:" << instant_after_flush_vol<< endl; cout << "rtd_max:" << rtd_max<< endl; cout << "rtd_min:" << rtd_min<< endl; cout << "left_bib_ratio_max:" << left_bib_ratio_max<< endl; cout << "left_bib_ratio_min:" << left_bib_ratio_min<< endl; cout << "right_bib_ratio_max:" << right_bib_ratio_max<< endl; cout << "right_bib_ratio_min:" << right_bib_ratio_min<< endl; cout << "instant_gram_max:" << instant_gram_max<< endl; cout << "instant_gram_min:" << instant_gram_min<< endl; cout << "left_bib_percent_max:" << left_bib_percent_max<< endl; cout << "left_bib_percent_min:" << left_bib_percent_min<< endl; cout << "RLine:" << toRLine(true) << endl; cout << endl;; qDebug() << "Recipe" ;; qDebug() << "=========================================================" ;; qDebug() << "id:" << id ;; qDebug() << "large_cup:" << large_cup;; qDebug() << "medium_cup:" << medium_cup; qDebug() << "small_cup:" << small_cup; qDebug() << "seq1:" << seq1; qDebug() << "seq2:" << seq2; qDebug() << "seq3:" << seq3; qDebug() << "dispense_type:" << dispense_type; qDebug() << "default_cup_size:" << default_cup_size; qDebug() << "left_bib_type:" << left_bib_type; qDebug() << "left_bib_pressure_time:" << left_bib_pressure_time; qDebug() << "left_bib_percent:" << left_bib_percent; qDebug() << "left_bib_mild_ratio:" << left_bib_mild_ratio; qDebug() << "left_bib_norm_ratio:" << left_bib_norm_ratio; qDebug() << "left_bib_strong_ratio:" << left_bib_strong_ratio; qDebug() << "left_bib_default_ratio:" << left_bib_default_ratio; qDebug() << "left_bib_water_flow:" << left_bib_water_flow; qDebug() << "left_bib_ingredient_start:" << left_bib_ingredient_start; qDebug() << "left_bib_airvalve:" << left_bib_airvalve; qDebug() << "left_bib_airpump_start:" << left_bib_airpump_start; qDebug() << "left_bib_airpump_stop:" << left_bib_airpump_stop; qDebug() << "left_bib_airpump_speed:" << left_bib_airpump_speed; qDebug() << "left_bib_after_flush_vol:" << left_bib_after_flush_vol; qDebug() << "right_bib_type:" << right_bib_type; qDebug() << "right_bib_pressure_time:" << right_bib_pressure_time; qDebug() << "right_bib_percent:" << right_bib_percent; qDebug() << "right_bib_mild_ratio:" << right_bib_mild_ratio; qDebug() << "right_bib_norm_ratio:" << right_bib_norm_ratio; qDebug() << "right_bib_strong_ratio:" << right_bib_strong_ratio; qDebug() << "right_bib_default_ratio:" << right_bib_default_ratio; qDebug() << "right_bib_water_flow:" << right_bib_water_flow; qDebug() << "right_bib_ingredient_start:" << right_bib_ingredient_start; qDebug() << "right_bib_airvalve:" << right_bib_airvalve; qDebug() << "right_bib_airpump_start:" << right_bib_airpump_start; qDebug() << "right_bib_airpump_stop:" << right_bib_airpump_stop; qDebug() << "right_bib_airpump_speed:" << right_bib_airpump_speed; qDebug() << "right_bib_after_flush_vol:" << right_bib_after_flush_vol; qDebug() << "instant_type:" << instant_type; qDebug() << "instant_pressure_time:" << instant_pressure_time; qDebug() << "instant_percent:" << instant_percent; qDebug() << "instant_default_pwm:" << instant_default_pwm; qDebug() << "instant_water_flow:" << instant_water_flow; qDebug() << "instant_ingredient_gram_strong:" << instant_ingredient_gram_strong; qDebug() << "instant_ingredient_gram_norm:" << instant_ingredient_gram_norm; qDebug() << "instant_ingredient_gram_mild:" << instant_ingredient_gram_mild; qDebug() << "instant_ingredient_mild_pwm:" << instant_ingredient_mild_pwm; qDebug() << "instant_ingredient_norm_pwm:" << instant_ingredient_norm_pwm; qDebug() << "instant_ingredient_strong_pwm:" << instant_ingredient_strong_pwm; qDebug() << "instant_ingredient_rtd_standard:" << instant_ingredient_rtd_standard; qDebug() << "instant_mixer_start_delay:" << instant_mixer_start_delay; qDebug() << "instant_mixer_stop_delay:" << instant_mixer_stop_delay; qDebug() << "instant_mixer_speed:" << instant_mixer_speed; qDebug() << "instant_after_flush_vol:" << instant_after_flush_vol; qDebug() << "rtd_max:" << rtd_max; qDebug() << "rtd_min:" << rtd_min; qDebug() << "left_bib_ratio_max:" << left_bib_ratio_max; qDebug() << "left_bib_ratio_min:" << left_bib_ratio_min; qDebug() << "right_bib_ratio_max:" << right_bib_ratio_max; qDebug() << "right_bib_ratio_min:" << right_bib_ratio_min; qDebug() << "instant_gram_max:" << instant_gram_max; qDebug() << "instant_gram_min:" << instant_gram_min; qDebug() << "left_bib_percent_max:" << left_bib_percent_max; qDebug() << "left_bib_percent_min:" << left_bib_percent_min; qDebug() << "RLine:" << toRLine(true) << endl; qDebug() ;; }