void LoadEmojiUI::init() { mValue = 0; QVBoxLayout *v = new QVBoxLayout(); QHBoxLayout *h = new QHBoxLayout(); QLabel *label = new QLabel(cns("请选择过滤文件的大小"), this); mSlider = new QSlider(Qt::Horizontal, this); mSlider->setMaximum(100); mSlider->setMinimum(0); mSlider->setValue(0); connect(mSlider, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int))); mLabel = new QLabel(cns("当前:0.0Kb"), this); h->addWidget(label); h->addSpacing(2); h->addWidget(mLabel); v->addLayout(h); v->addWidget(mSlider); mBar = new QProgressBar(this); mBar->setMaximum(100); mBar->setMinimum(0); MoveEmojiCustom *movee = MoveEmojiCustom::GetInstance(); connect(movee, SIGNAL(signalProgress(int)), this, SLOT(progressValue(int))); QPushButton *load = new QPushButton(cns("选择目录"), this); connect(load, SIGNAL(clicked()), this, SLOT(clickLoad())); v->addWidget(mBar); v->addWidget(load, 0, Qt::AlignCenter); setLayout(v); this->setStyle(QStyleFactory::create(QStyleFactory::keys().last())); }
/* * The CreateCl opcode is specified as not being allowed before the * class it creates exists, and closure classes are always unique. * * This means even if we're not in RepoAuthoritative mode, as long as * this code is reachable it will always use the same closure Class*, * so we can just burn it into the TC without using RDS. */ void emitCreateCl(HTS& env, int32_t numParams, const StringData* clsName) { auto const cls = Unit::lookupClassOrUniqueClass(clsName); auto const invokeFunc = cls->lookupMethod(s_uuinvoke.get()); auto const clonedFunc = invokeFunc->cloneAndSetClass( const_cast<Class*>(curClass(env)) ); assert(cls && (cls->attrs() & AttrUnique)); auto const closure = allocObjFast(env, cls); gen(env, IncRef, closure); auto const ctx = [&]{ if (!curClass(env)) return cns(env, nullptr); auto const ldctx = gen(env, LdCtx, fp(env)); if (invokeFunc->attrs() & AttrStatic) { return gen(env, ConvClsToCctx, gen(env, LdClsCtx, ldctx)); } gen(env, IncRefCtx, ldctx); return ldctx; }(); gen(env, StClosureCtx, closure, ctx); gen(env, StClosureFunc, FuncData(clonedFunc), closure); SSATmp* args[numParams]; for (int32_t i = 0; i < numParams; ++i) { args[numParams - i - 1] = popF(env); } int32_t propId = 0; for (; propId < numParams; ++propId) { gen( env, StClosureArg, PropByteOffset(cls->declPropOffset(propId)), closure, args[propId] ); } // Closure static variables are per instance, and need to start // uninitialized. After numParams use vars, the remaining instance // properties hold any static locals. assert(cls->numDeclProperties() == clonedFunc->numStaticLocals() + numParams); for (int32_t numDeclProperties = cls->numDeclProperties(); propId < numDeclProperties; ++propId) { gen( env, StClosureArg, PropByteOffset(cls->declPropOffset(propId)), closure, cns(env, Type::Uninit) ); } push(env, closure); }
void emitNewArray(HTS& env, int32_t capacity) { if (capacity == 0) { push(env, cns(env, staticEmptyArray())); } else { if (auto newCap = PackedArray::getMaxCapInPlaceFast(capacity)) { assert(newCap > static_cast<uint32_t>(capacity)); capacity = newCap; } push(env, gen(env, NewArray, cns(env, capacity))); } }
void emitNewLikeArrayL(HTS& env, int32_t id, int32_t capacity) { auto const ldrefExit = makeExit(env); auto const ldPMExit = makeExit(env); auto const ld = ldLocInner(env, id, ldrefExit, ldPMExit, DataTypeSpecific); SSATmp* arr; if (ld->isA(Type::Arr)) { arr = gen(env, NewLikeArray, ld, cns(env, capacity)); } else { capacity = (capacity ? capacity : MixedArray::SmallSize); arr = gen(env, NewArray, cns(env, capacity)); } push(env, arr); }
Trace* TraceBuilder::genExitTrace(uint32_t bcOff, int32_t stackDeficit, uint32_t numOpnds, SSATmp* const* opnds, TraceExitType::ExitType exitType, uint32_t notTakenBcOff, std::function<void(IRFactory*, Trace*)> beforeExit) { Trace* exitTrace = makeExitTrace(bcOff); MarkerData marker; marker.bcOff = bcOff; marker.stackOff = m_spOffset + numOpnds - stackDeficit; marker.func = m_curFunc->getValFunc(); exitTrace->back()->push_back(m_irFactory.gen(Marker, marker)); if (beforeExit) { beforeExit(&m_irFactory, exitTrace); } SSATmp* sp = m_spValue; if (numOpnds != 0 || stackDeficit != 0) { SSATmp* srcs[numOpnds + 2]; srcs[0] = m_spValue; srcs[1] = cns(stackDeficit); std::copy(opnds, opnds + numOpnds, srcs + 2); SSATmp** decayedPtr = srcs; auto* spillInst = m_irFactory.gen( SpillStack, std::make_pair(numOpnds + 2, decayedPtr) ); sp = spillInst->getDst(); exitTrace->back()->push_back(spillInst); } SSATmp* pc = cns(int64_t(bcOff)); if (exitType == TraceExitType::NormalCc) { assert(notTakenBcOff != 0); SSATmp* notTakenPC = cns(notTakenBcOff); genFor(exitTrace, getExitOpcode(exitType), m_curFunc, pc, sp, m_fpValue, notTakenPC); } else { assert(notTakenBcOff == 0); genFor(exitTrace, getExitOpcode(exitType), m_curFunc, pc, sp, m_fpValue); } return exitTrace; }
void emitIssetS(HTS& env) { auto const ssaPropName = topC(env, BCSPOffset{1}); if (!ssaPropName->isA(Type::Str)) { PUNT(IssetS-PropNameNotString); } auto const ssaCls = popA(env); auto const ret = cond( env, 0, [&] (Block* taken) { auto propAddr = ldClsPropAddr(env, ssaCls, ssaPropName, false); return gen(env, CheckNonNull, taken, propAddr); }, [&] (SSATmp* ptr) { // Next: property or global exists return gen(env, IsNTypeMem, Type::Null, gen(env, UnboxPtr, ptr)); }, [&] { // Taken: LdClsPropAddr* returned Nullptr because it isn't defined return cns(env, false); } ); destroyName(env, ssaPropName); push(env, ret); }
void parseIDL(const char* idlFilePath, fbvector<PhpFunc>& funcVec, fbvector<PhpClass>& classVec, fbvector<PhpConst>& constVec, fbvector<PhpExtension>& extVec) { std::ostringstream jsonString; std::ifstream infile(idlFilePath); infile >> jsonString.rdbuf(); auto parsed = folly::parseJson(jsonString.str()); for (auto const& f : parsed["funcs"]) { PhpFunc func(f, ""); funcVec.push_back(func); } for (auto const& c : parsed["classes"]) { PhpClass klass(c); classVec.push_back(klass); } for (auto const& c : parsed["consts"]) { PhpConst cns(c); constVec.push_back(cns); } auto it = parsed.find("extension"); if (it != parsed.items().end()) { PhpExtension ext(it->second); extVec.push_back(ext); } }
void emitInitProp(IRGS& env, const StringData* propName, InitPropOp op) { auto const val = popC(env); auto const ctx = curClass(env); SSATmp* base; Slot idx = 0; switch (op) { case InitPropOp::Static: { // For sinit, the context class is always the same as the late-bound // class, so we can just use curClass(). auto const handle = ctx->sPropHandle(ctx->lookupSProp(propName)); base = gen( env, LdRDSAddr, RDSHandleData { handle }, TPtrToSPropCell ); } break; case InitPropOp::NonStatic: { // The above is not the case for pinit, so we need to load. auto const cctx = gen(env, LdCctx, fp(env)); auto const cls = gen(env, LdClsCtx, cctx); base = gen(env, LdClsInitData, cls); idx = ctx->lookupDeclProp(propName); } break; } gen(env, StElem, base, cns(env, idx * sizeof(TypedValue)), val); }
SSATmp* TraceBuilder::preOptimizeAssertLoc(IRInstruction* inst) { auto const locId = inst->extra<AssertLoc>()->locId; auto const prevType = localType(locId, DataTypeGeneric); auto const typeParam = inst->typeParam(); if (!prevType.equals(Type::None) && !typeParam.strictSubtypeOf(prevType)) { if (!prevType.subtypeOf(typeParam)) { /* Task #2553746 * This is triggering for a case where the tracked state says the local is * InitNull but the AssertLoc says it's Str. */ static auto const error = StringData::GetStaticString("Internal error: static analysis was " "wrong about a local variable's type."); auto* errorInst = m_irFactory.gen(RaiseError, inst->marker(), cns(error)); inst->become(&m_irFactory, errorInst); // It's not a disaster to generate this in unreachable code for // now. t2590033. if (false) { assert_log(false, [&]{ IRTrace& mainTrace = trace()->isMain() ? *trace() : *(trace()->main()); return folly::format("\npreOptimizeAssertLoc: prevType: {} " "typeParam: {}\nin instr: {}\nin trace: {}\n", prevType.toString(), typeParam.toString(), inst->toString(), mainTrace.toString()).str(); }); } } else { inst->convertToNop(); } } return nullptr; }
SSATmp* implInstanceOfD(IRGS& env, SSATmp* src, const StringData* className) { /* * InstanceOfD is always false if it's not an object. * * We're prepared to generate translations for known non-object types, but if * it's Gen/Cell we're going to PUNT because it's natural to translate that * case with control flow TODO(#2020251) */ if (TObj < src->type()) { PUNT(InstanceOfD_MaybeObj); } if (!src->isA(TObj)) { bool res = ((src->isA(TArr) && interface_supports_array(className))) || (src->isA(TStr) && interface_supports_string(className)) || (src->isA(TInt) && interface_supports_int(className)) || (src->isA(TDbl) && interface_supports_double(className)); return cns(env, res); } auto const checkCls = ldClassSafe(env, className); if (auto isInstance = implInstanceCheck(env, src, className, checkCls)) { return isInstance; } return gen(env, InstanceOf, gen(env, LdObjClass, src), checkCls); }
void emitPrint(HTS& env) { auto const type = topC(env)->type(); if (!type.subtypeOfAny(Type::Int, Type::Bool, Type::Null, Type::Str)) { interpOne(env, Type::Int, 1); return; } auto const cell = popC(env); Opcode op; if (type <= Type::Str) { op = PrintStr; } else if (type <= Type::Int) { op = PrintInt; } else if (type <= Type::Bool) { op = PrintBool; } else { assert(type <= Type::Null); op = Nop; } // the print helpers decref their arg, so don't decref pop'ed value if (op != Nop) { gen(env, op, cell); } push(env, cns(env, 1)); }
void LoadEmojiUI::clickLoad() { // QString dirctory = // QFileDialog::getExistingDirectory(this, cns("选择表情包路径")); // QStringList filters; // filters << "*.jpg" << "*.gif" << "*.bmp" // << "*.jpeg" << "*.png" << "*.pbm" // << "*.pgm" << "*.ppm" << "*.xbm" << "*.xpm"; // QDir dirs(dirctory); // QFileInfoList infolst = dirs.entryInfoList(filters, QDir::Files); QString filter = "(*.jpg);;(*.png);;(*.gif);;(*.bmp);;(*)"; QStringList infolst = QFileDialog::getOpenFileNames(this, cns("选择表情包"), ".", filter); QStringList imagelist; auto it = infolst.begin(); while (it != infolst.end()) { QFileInfo info = *it; if (info.exists()) { qint64 size = info.size(); if (size > mValue) { imagelist << info.filePath(); } // qDebug() << info.filePath() + " size:" + QString::number(size); } ++it; } QString path = "D:/Program Files/happy"; QDir dir("."); QFileInfo info(path); if (!info.exists()) { dir.mkpath(info.absoluteFilePath()); } if (imagelist.isEmpty()) { // mBar->setValue(100); } QFile file(path + "/emoji.data"); if (file.open(QIODevice::WriteOnly | QIODevice::Append)) { for (int i = 0; i < imagelist.size(); i++) { QString image = imagelist.at(i) + ";"; file.seek(file.size()); file.write(image.toLocal8Bit()); // float num = i; // float counts = imagelist.size(); // mBar->setValue(num / (counts - 1) * 100); } } file.close(); emit MoveEmojiCustom::GetInstance()->signalStartMoves(imagelist); }
void emitContEnter(HTS& env) { auto const returnOffset = nextBcOff(env); assert(curClass(env)); assert(curClass(env)->classof(c_AsyncGenerator::classof()) || curClass(env)->classof(c_Generator::classof())); assert(curFunc(env)->contains(returnOffset)); // Load generator's FP and resume address. auto const genObj = ldThis(env); auto const genFp = gen(env, LdContActRec, genObj); auto resumeAddr = gen(env, LdContResumeAddr, genObj); // Make sure function enter hook is called if needed. auto const exitSlow = makeExitSlow(env); gen(env, CheckSurpriseFlags, exitSlow); // Exit to interpreter if resume address is not known. resumeAddr = gen(env, CheckNonNull, exitSlow, resumeAddr); // Sync stack. auto const stack = spillStack(env); // Enter generator. auto returnBcOffset = returnOffset - curFunc(env)->base(); gen(env, ContEnter, stack, fp(env), genFp, resumeAddr, cns(env, returnBcOffset)); }
SSATmp* ldClsPropAddr(IRGS& env, SSATmp* ssaCls, SSATmp* ssaName, bool raise) { /* * We can use ldClsPropAddrKnown if either we know which property it is and * that it is visible && accessible, or we know it is a property on this * class itself. */ bool const sPropKnown = [&] { if (!ssaName->hasConstVal()) return false; auto const propName = ssaName->strVal(); if (!ssaCls->hasConstVal()) return false; auto const cls = ssaCls->clsVal(); if (!classIsPersistentOrCtxParent(env, cls)) return false; auto const lookup = cls->findSProp(curClass(env), propName); return lookup.prop != kInvalidSlot && lookup.accessible; }(); if (sPropKnown) { return ldClsPropAddrKnown(env, ssaCls->clsVal(), ssaName->strVal()); } return gen( env, raise ? LdClsPropAddrOrRaise : LdClsPropAddrOrNull, ssaCls, ssaName, cns(env, curClass(env)) ); }
void emitStaticLocInit(HTS& env, int32_t locId, const StringData* name) { if (curFunc(env)->isPseudoMain()) PUNT(StaticLocInit); auto const ldPMExit = makePseudoMainExit(env); auto const value = popC(env); // Closures and generators from closures don't satisfy the "one static per // source location" rule that the inline fastpath requires auto const box = [&]{ if (curFunc(env)->isClosureBody()) { return gen(env, ClosureStaticLocInit, cns(env, name), fp(env), value); } auto const cachedBox = gen(env, LdStaticLocCached, StaticLocName { curFunc(env), name }); ifThen( env, [&] (Block* taken) { gen(env, CheckStaticLocInit, taken, cachedBox); }, [&] { hint(env, Block::Hint::Unlikely); gen(env, StaticLocInitCached, cachedBox, value); } ); return cachedBox; }(); gen(env, IncRef, box); auto const oldValue = ldLoc(env, locId, ldPMExit, DataTypeSpecific); stLocRaw(env, locId, fp(env), box); gen(env, DecRef, oldValue); // We don't need to decref value---it's a bytecode invariant that // our Cell was not ref-counted. }
SSATmp* TraceBuilder::preOptimizeAssertLoc(IRInstruction* inst) { auto const locId = inst->extra<AssertLoc>()->locId; auto const prevType = localType(locId, DataTypeGeneric); auto const typeParam = inst->typeParam(); if (prevType.not(typeParam)) { /* Task #2553746 * This is triggering for a case where the tracked state says the local is * InitNull but the AssertLoc says it's Str. */ static auto const error = makeStaticString("Internal error: static analysis was " "wrong about a local variable's type."); auto* errorInst = m_unit.gen(RaiseError, inst->marker(), cns(error)); inst->become(m_unit, errorInst); // It's not a disaster to generate this in unreachable code for // now. t2590033. if (false) { assert_log(false, [&]{ return folly::format("\npreOptimizeAssertLoc: prevType: {} " "typeParam: {}\nin instr: {}\nin trace: {}\n", prevType.toString(), typeParam.toString(), inst->toString(), m_unit.main()->toString()).str(); }); } } else if (shouldElideAssertType(prevType, typeParam, nullptr)) { // The type we're asserting is worse than the last known type. return inst->src(0); } return nullptr; }
LoadEmojiUI::LoadEmojiUI(QWidget *parent) : QWidget(parent) { init(); setWindowFlags(Qt::Tool); setAttribute(Qt::WA_DeleteOnClose); setWindowModality(Qt::ApplicationModal); setWindowTitle(cns("哈啤表情导入")); }
void TraceBuilder::genTraceEnd(uint32_t nextPc, TraceExitType::ExitType exitType /* = Normal */) { gen(getExitOpcode(TraceExitType::Normal), m_curFunc, cns(nextPc), m_spValue, m_fpValue); }
vespalib::HealthProducer::Health StateReporter::getHealth() const { lib::NodeState cns(*_component.getStateUpdater().getCurrentNodeState()); bool up = cns.getState().oneOf("u"); std::string message = up ? "" : "Node state: " + cns.toString(true); return vespalib::HealthProducer::Health(up, message); }
void ClientOpt::recvMessageData(MessageData data) { mData->type = data.datatype(); switch (mData->type) { case Ping: { qDebug() << cns("recv ping"); MessageData msg; MessagePong *pong = new MessagePong(); msg.setDatatype(pong->datatype()); msg.setContent(pong); NetworkData data; msg.toStream(data); emit sendMessage(data); qDebug() << cns("send pong"); } break; case Pong: qDebug() << cns("recv pong"); break; case Greeting: { mData->state = ReadyForUse; MessageGreeting *greeting = dynamic_cast<MessageGreeting *>(data.content()); if (nullptr != greeting) { mData->clientKey = greeting->greetingKey(); emit readyForUse(mData->clientKey); } } break; case RichText: emit sendUIMessage(data); break; case FileSendType: emit sendFileMessage(data); break; case FileHead: emit sendFileMessage(data); break; case undefine: break; default: break; } }
void emitContCurrent(HTS& env) { assert(curClass(env)); auto const cont = ldThis(env); gen(env, ContStartedCheck, makeExitSlow(env), cont); auto const offset = cns(env, offsetof(c_Generator, m_value)); auto const value = gen(env, LdContField, Type::Cell, cont, offset); pushIncRef(env, value); }
void emitContCheck(HTS& env, int32_t checkStarted) { assert(curClass(env)); assert(curClass(env)->classof(c_AsyncGenerator::classof()) || curClass(env)->classof(c_Generator::classof())); auto const cont = ldThis(env); gen(env, ContPreNext, makeExitSlow(env), cont, cns(env, static_cast<bool>(checkStarted))); }
BuildGroupUI::BuildGroupUI(QWidget *parent) : QWidget(parent) { init(); setWindowTitle(cns("新建群")); setAttribute(Qt::WA_DeleteOnClose); setWindowFlags(Qt::Tool); setWindowModality(Qt::ApplicationModal); }
void emitParent(HTS& env) { auto const clss = curClass(env); if (clss == nullptr || clss->parent() == nullptr) { interpOne(env, Type::Cls, 0); } else { push(env, cns(env, clss->parent())); } }
void emitSelf(HTS& env) { auto const clss = curClass(env); if (clss == nullptr) { interpOne(env, Type::Cls, 0); } else { push(env, cns(env, clss)); } }
Chat *PersonItem::createChat() { if (chat) { chat->showNormal(); chat->activateWindow(); return chat; } chat = new PersonChat; chat->setRecever(recever); chat->setShakeEnable(shakeabled); chat->setRejectShake(rejectShake); if (jsondata) chat->setJsonData(jsondata->copy()); chat->setChatTitle(cns("与") + name->text() + cns("聊天中"), emoji->ImagePath()); connect(chat, &PersonChat::chatClose, this, [=] () { disconnect(chat, &PersonChat::chatClose, this, 0); disconnect(chat, &PersonChat::chatShow, this, 0); disconnect(chat, &PersonChat::starkShake, this, 0); disconnect(chat, &PersonChat::shakeRejectStatusChanged, this, 0); chat = nullptr; tab->returnChats()->remove(jsondata->getUid()); }); connect(chat, &PersonChat::chatShow, this, [=] () { stopNotify(); }); connect(chat, &PersonChat::shakeRejectStatusChanged, this, [=] (bool b) { rejectShake = b; }); connect(chat, &PersonChat::starkShake, this, [=] () { // 计时开始 //30s后重置 shakeabled = false; QTimer::singleShot(10000, this, [=] () { shakeabled = true; if (chat) chat->setShakeEnable(true); }); }); chat->show(); chat->activateWindow(); emit cloneCreateChat(chat); return chat; }
void emitEmptyL(IRGS& env, int32_t id) { auto const ldrefExit = makeExit(env); auto const ldPMExit = makePseudoMainExit(env); auto const ld = ldLocInner(env, id, ldrefExit, ldPMExit, DataTypeSpecific); push( env, gen(env, XorBool, gen(env, ConvCellToBool, ld), cns(env, true)) ); }
void FileUI::askSend() { if (mData->opt->isEmpty()) { return; } emit signalAskSend(); mSendMsg->setText(cns("等待对方确认")); }
SSATmp* TraceBuilder::genLdStackAddr(SSATmp* sp, int64_t index) { Type type; bool spansCall; UNUSED SSATmp* val = getStackValue(sp, index, spansCall, type); type = noneToGen(type); assert(IMPLIES(val != nullptr, val->type().equals(type))); assert(type.notPtr()); return gen(LdStackAddr, type.ptr(), sp, cns(index)); }
void emitContCurrent(IRGS& env) { assertx(curClass(env)); auto const cont = ldThis(env); gen(env, ContStartedCheck, IsAsyncData(false), makeExitSlow(env), cont); auto const offset = cns(env, offsetof(Generator, m_value) - Generator::objectOff()); auto const value = gen(env, LdContField, TCell, cont, offset); pushIncRef(env, value); }