bool Equation::trivialSolution( ) const { Word image; Word::const_iterator w_it = theEquation.begin( ); for( ; w_it!=theEquation.end( ) ; ++w_it ) if( isGenerator(*w_it) ) image.push_back( *w_it ); return image.length()==0; }
Func* Func::clone() const { Func* f = new (allocFuncMem( m_name, m_numParams, isClosureBody() || isGeneratorFromClosure() )) Func(*this); f->initPrologues(m_numParams, isGenerator()); f->m_funcId = InvalidFuncId; return f; }
fast_Ring<TNum,kdefs>::fast_Ring( unsigned short _char, unsigned short _epsPrec, short _generator) : characteristic(_char), epsilon(_epsPrec), generator( Convert(_generator) ) { assert( TNum::wellDefined(characteristic) ); assert( epsilon <= 1 ); assert( isGenerator(generator)); init(); assert( wellDefined() ); }
std::string func_flag_list(const FuncInfo& finfo) { auto const func = finfo.func; std::vector<std::string> flags; if (func->isGenerator()) flags.push_back("isGenerator"); if (func->isAsync()) flags.push_back("isAsync"); if (func->isClosureBody()) flags.push_back("isClosureBody"); if (func->isPairGenerator()) flags.push_back("isPairGenerator"); std::string strflags = folly::join(" ", flags); if (!strflags.empty()) return " " + strflags + " "; return " "; }
std::string func_flag_list(const FuncInfo& finfo) { auto const func = finfo.func; std::vector<std::string> flags; if (auto name = func->getGeneratorBodyName()) { flags.push_back( folly::format("hasGeneratorBody(\"{}\")", name->toCppString()).str() ); } if (func->isGenerator()) flags.push_back("isGenerator"); if (func->isAsync()) flags.push_back("isAsync"); if (func->isGeneratorFromClosure()) flags.push_back("isGeneratorFromClosure"); if (func->isClosureBody()) flags.push_back("isClosureBody"); if (func->isPairGenerator()) flags.push_back("isPairGenerator"); std::string strflags = folly::join(" ", flags); if (!strflags.empty()) return " " + strflags + " "; return " "; }
void dhGenPubKey(dhpvk_t *pvk, dhpbk_t *pbk) { // Integer used for random numbers if (!seed_initialized) rnInit(); do { mpz_urandomb(pbk->p, seed, DH_KEY_SIZE); } while (!mpz_probab_prime_p(pbk->p, NB_TURN)); mpz_set(pvk->p, pbk->p); mpz_set_ui(pbk->g, 2); // Search alpha so that alpha is a generator while(!isGenerator(pbk->p, pbk->g)) mpz_add_ui(pbk->g, pbk->g, 1); mpz_set(pvk->g, pbk->g); mpz_urandomm(pvk->a, seed, pvk->p); mpz_powm(pbk->pow, pbk->g, pvk->a, pbk->p); }
void egKeyGen(egpvk_t *pvk, egpbk_t *pbk) { // Useful for random generation if (!seed_initialized) rnInit(); // Temporary variables mpz_t tmp; mpz_init(tmp); // p definition do { mpz_urandomb(pvk->p, seed, EG_KEY_SIZE); } while (!mpz_probab_prime_p(pvk->p, NB_TURN)); mpz_set(pbk->p, pvk->p); mpz_set_ui(pbk->alpha, 2); // Search alpha so that alpha is a generator while(!isGenerator(pbk->p, pbk->alpha)) mpz_add_ui(pbk->alpha, pbk->alpha, 1); // Compute private key mpz_urandomb(pvk->a, seed, EG_KEY_SIZE); // Compute last part of public key mpz_powm(pbk->beta, pbk->alpha, pvk->a, pvk->p); // Compute k mpz_set_ui(tmp, NB_CHAR); pvk->k = 0; while (mpz_cmp(tmp, pbk->p) < 0) { mpz_mul_ui(tmp, tmp, NB_CHAR); pvk->k ++; } pbk->k = pvk->k; mpz_clear(tmp); }
void tearDownFrame(ActRec*& fp, Stack& stack, PC& pc, Offset& faultOffset) { auto const func = fp->m_func; auto const curOp = *reinterpret_cast<const Op*>(pc); auto const unwindingGeneratorFrame = func->isGenerator(); auto const unwindingReturningFrame = curOp == OpRetC || curOp == OpRetV; auto const prevFp = fp->arGetSfp(); auto const soff = fp->m_soff; FTRACE(1, "tearDownFrame: {} ({})\n fp {} prevFp {}\n", func->fullName()->data(), func->unit()->filepath()->data(), implicit_cast<void*>(fp), implicit_cast<void*>(prevFp)); // When throwing from a constructor, we normally want to avoid running the // destructor on an object that hasn't been fully constructed yet. But if // we're unwinding through the constructor's RetC, the constructor has // logically finished and we're unwinding for some internal reason (timeout // or user profiler, most likely). More importantly, fp->m_this may have // already been destructed and/or overwritten due to sharing space with // fp->m_r. if (!unwindingReturningFrame && fp->isFromFPushCtor() && fp->hasThis()) { fp->getThis()->setNoDestruct(); } // A generator's locals don't live on this stack. if (LIKELY(!unwindingGeneratorFrame)) { /* * If we're unwinding through a frame that's returning, it's only * possible that its locals have already been decref'd. * * Here's why: * * - If a destructor for any of these things throws a php * exception, it's swallowed at the dtor boundary and we keep * running php. * * - If the destructor for any of these things throws a fatal, * it's swallowed, and we set surprise flags to throw a fatal * from now on. * * - If the second case happened and we have to run another * destructor, its enter hook will throw, but it will be * swallowed again. * * - Finally, the exit hook for the returning function can * throw, but this happens last so everything is destructed. * */ if (!unwindingReturningFrame) { try { // Note that we must convert locals and the $this to // uninit/zero during unwind. This is because a backtrace // from another destructing object during this unwind may try // to read them. frame_free_locals_unwind(fp, func->numLocals()); } catch (...) {} } stack.ndiscard(func->numSlotsInFrame()); stack.discardAR(); } else { // The generator's locals will be cleaned up when the Continuation // object is destroyed. But we are leaving the generator function // now, so signal that to anyone who cares. try { EventHook::FunctionExit(fp); } catch (...) {} // As above, don't let new exceptions out of unwind. } /* * At the final ActRec in this nesting level. We don't need to set * pc and fp since we're about to re-throw the exception. And we * don't want to dereference prefFp since we just popped it. */ if (prevFp == fp) return; assert(stack.isValidAddress(reinterpret_cast<uintptr_t>(prevFp)) || prevFp->m_func->isGenerator()); auto const prevOff = soff + prevFp->m_func->base(); pc = prevFp->m_func->unit()->at(prevOff); fp = prevFp; faultOffset = prevOff; }
void tearDownFrame(ActRec*& fp, Stack& stack, PC& pc, Offset& faultOffset) { auto const func = fp->m_func; auto const curOp = *reinterpret_cast<const Op*>(pc); auto const unwindingGeneratorFrame = func->isGenerator(); auto const unwindingReturningFrame = curOp == OpRetC || curOp == OpRetV; auto const prevFp = fp->arGetSfp(); FTRACE(1, "tearDownFrame: {} ({})\n fp {} prevFp {}\n", func->fullName()->data(), func->unit()->filepath()->data(), implicit_cast<void*>(fp), implicit_cast<void*>(prevFp)); if (fp->isFromFPushCtor() && fp->hasThis()) { fp->getThis()->setNoDestruct(); } // A generator's locals don't live on this stack. if (LIKELY(!unwindingGeneratorFrame)) { /* * If we're unwinding through a frame that's returning, it's only * possible that its locals have already been decref'd. * * Here's why: * * - If a destructor for any of these things throws a php * exception, it's swallowed at the dtor boundary and we keep * running php. * * - If the destructor for any of these things throws a fatal, * it's swallowed, and we set surprise flags to throw a fatal * from now on. * * - If the second case happened and we have to run another * destructor, its enter hook will throw, but it will be * swallowed again. * * - Finally, the exit hook for the returning function can * throw, but this happens last so everything is destructed. * */ if (!unwindingReturningFrame) { try { // Note that we must convert locals and the $this to // uninit/zero during unwind. This is because a backtrace // from another destructing object during this unwind may try // to read them. frame_free_locals_unwind(fp, func->numLocals()); } catch (...) {} } stack.ndiscard(func->numSlotsInFrame()); stack.discardAR(); } assert(stack.isValidAddress(reinterpret_cast<uintptr_t>(prevFp)) || prevFp->m_func->isGenerator()); auto const prevOff = fp->m_soff + prevFp->m_func->base(); pc = prevFp->m_func->unit()->at(prevOff); fp = prevFp; faultOffset = prevOff; }