namespace PT { ConstFP::Fcn ConstFP::PrecisionsOfOneFcn:: CreateFcn( TyAcc const& _ty ) const { CompilationUnit& _cu ( G->CU() ); TpSgmtCntnr _pSC ( new SgmtCntnrSC ); IObj _iDolRootScope ( G->GetHierarchy().DolRootScope() ); ILexObj _iLexDolRootScope( _iDolRootScope->GetLexScope() ); typedef TypeList::Result TMods; std::vector _myArgs( nArgs() ); VariableSymbol _arg( TMods(), _ty ); for ( int _i( 0 ); _i < nArgs(); ++_i ) { std::stringstream _nmArg; _nmArg << "_arg" << _i; ITracks _iArg ( _iDolRootScope.TrackFactory(_nmArg.str(),_arg,(*_pSC),_cu) ); _myArgs[ _i ] = _iArg; } std::stringstream _nmFcn; _nmFcn << "!" << ECall::DPI(myDpiId).Id(); switch ( myDpiId ) { case ECall::DPI::_pow_: _nmFcn << "Wrapr"; default: break; } _nmFcn << R()->GetNextDLLid(); IT::FcnDclHlpr _theFunction( (*_pSC), _ty, _nmFcn, IT::TFcn::_dllExport_ ); for ( int _i( 0 ); _i < nArgs(); ++_i ) _theFunction << IT::IAcc( Expr( _myArgs[ _i ], NuVloc() ) ); IT::List _body; switch ( myDpiId ) { case ECall::DPI::_pow_: { IT::IAcc _one ( R()->c1.CastTo( _ty ) ); IT::IAcc _zero( R()->c0.CastTo( _ty ) ); IT::IAcc _condBase ( _theFunction.Arg(0) .EqEq( IT::FlagsOfIKind(), _zero ) ); IT::IAcc _condExp ( _theFunction.Arg(1) .LT( IT::FlagsOfIKind(), _zero ) ); // Specialize to capture `0 ** 0` and return 1. IT::IfHlpr _testSpcl ( _cu, _condBase .AndAnd (IT::FlagsOfIKind(), _condExp), IT::List() ); _testSpcl.True() << _one.Return(); _body << _testSpcl; break; } default: break; } IT::List _itActualList; for ( int _i( 0 ); _i < nArgs(); ++_i ) _itActualList << IT::IAcc( Expr( _myArgs[ _i ], NuVloc() ) ).FcnArg(); IT::IAcc _theLibmCall( _itActualList.Head() .CallDpi( _ty, DpiProto(), myDpiId, IT::FlagsOfIKind() ) ); _body << _theLibmCall.Return(); _theFunction << _body.Head(); typedef SgmtCntnr::IBrndToSmblsWthLval IBrndToSmblsWthLval; typedef SgmtCntnr::BtoSwLkey BtoSwLkey; TpSignature _noSig ( new Signature ); TBranding* _branding ( new TBranding ); TIBranding _iBranding ( _branding->Insert( _iLexDolRootScope,Brands() ).first ); TpBrand _pBrand ( new Brand( _iBranding ) ); RefPtr_oneBrand( new Brands( _noSig, _pBrand ) ); IBrands _iBrands (IPair((*_oneBrand).begin(),true)); IBrndToSmblsWthLval _iBtoWsl( (*_pSC)->Get( BtoSwLkey( _iBrands ) ) ); OneGeste _theGeste ( R()->terminusStmt, _iLexDolRootScope, _iDolRootScope, DLLobject() ); IT::TpLlVmGenerator _pLlVm ( _cu.LlVmGeneratorFactory( true/*isCommonToAllCUs*/ ) ); _theGeste.SetClosure( _theFunction ); _pSC->AllocLvalToGeste( _iBrands, _theGeste ); _pLlVm->AtFunction( (*_pSC), _iBrands, _iBtoWsl, _theGeste ); switch ( myDpiId ) { # ifdef C_FILE_GENERATOR case ECall::DPI::_pow_: _pSC->AddRef(); _pBrand->AddRef(); _oneBrand->AddRef(); _noSig->AddRef(); _cu.GetCfileGenerator()->AtFunction( *_pSC, _iBrands, _theGeste ); break; # endif C_FILE_GENERATOR default: delete _branding; break; } TyFloat const& _tyFloat( *(TyFloat const*)_ty ); Fcn _rslt; if ( _tyFloat.GetnBits() <= TyFloat::_IEEEdouble_ || ConstFP::LongDoubleIs128Bits() ) { try { _rslt = Fcn( _ty, _pLlVm->JIT(), _nmFcn.str() ); } catch ( Message& _msg ) { _rslt = LowerPrecision( _tyFloat, _msg ); } } return _rslt; } }