Example #1
0
// o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o
bool
BRTReduceKernelDef::CheckSemantics() const
{
   FunctionType *fType;
   Decl *streamArg = NULL, *reduceArg = NULL;

   assert (decl->form->type == TT_Function);
   fType = (FunctionType *) decl->form;

   for (unsigned int i = 0; i < fType->nArgs; i++) {
      if (fType->args[i]->isReduce()) {
         if (reduceArg != NULL) {
            std::cerr << location << "Multiple reduce arguments in "
                      << *FunctionName() << ": ";
            reduceArg->print(std::cerr, true);
            std::cerr << ", ";
            fType->args[i]->print(std::cerr, true);
            std::cerr << ".\n";
            return false;
         }

         reduceArg = fType->args[i];
      } else if (fType->args[i]->isStream()) {
         if (streamArg != NULL) {
            std::cerr << location << "Multiple non-reduce streams in "
                      << *FunctionName() << ": ";
            streamArg->print(std::cerr, true);
            std::cerr << ", ";
            fType->args[i]->print(std::cerr, true);
            std::cerr << ".\n";
            return false;
         }

         streamArg = fType->args[i];
      }

      if ((fType->args[i]->form->getQualifiers() & TQ_Out) != 0) {
         std::cerr << location << "Non-reduce output in reduction kernel "
                   << *FunctionName() << ".\n";
         return false;
      }
   }

   if (reduceArg == NULL) {
      std::cerr << location << "Reduction kernel " << *FunctionName()
                << " has no reduce argument.\n";
      return false;
   }

   if (streamArg == NULL) {
      std::cerr << location << "Reduction kernel " << *FunctionName()
                << " has no stream argument.\n";
      return false;
   }

   return true;
}
Example #2
0
// o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o
void
BRTKernelDef::print(std::ostream& out, int) const
{
   char name[1024];

   if (Project::gDebug) {
      out << "/* BRTKernelDef:" ;
      location.printLocation(out) ;
      out << " */" << std::endl;
   }

   assert(FunctionName());
   assert(FunctionName()->entry);
   assert(FunctionName()->entry->scope);

   /* If the symbol for the generated assembly code already 
   ** exists, don't generate the assembly.  This allows the user
   ** to hand generate the code.
   */
   
#define PRINT_CODE(a,b) \
   sprintf (name, "__%s_%s", FunctionName()->name.c_str(), #b);      \
   if (!FunctionName()->entry->scope->Lookup(name)) {                \
      if (globals.target & TARGET_##a) {                             \
         BRTKernelCode *var;                                         \
            var = decl->isReduce() ? new BRT##a##ReduceCode(*this) : \
                                  new BRT##a##KernelCode(*this);     \
         out << *var << std::endl;                                   \
         delete var;                                                 \
      } else {                                                       \
         out << "static const char *__"                              \
             << *FunctionName() << "_" << #b << "= NULL;\n";         \
      }                                                              \
   }
 
   PRINT_CODE(PS20, ps20);
   PRINT_CODE(FP30, fp30);
   PRINT_CODE(ARB,  arb);
   PRINT_CODE(CPU,  cpu);
#undef PRINT_CODE

   /*
    * XXX I have no idea why this is here instead of in
    * BRTCPUKernel::print().  It's CPU only and needs to be suppressed when
    * the CPU target is suppressed.  --Jeremy.
    * The scatter functions need to be there whether or not the CPU target is repressed
    * For the fallback requirement --Daniel
    */
   if (decl->isReduce()) {
     BRTCPUReduceCode crc(*this);
     BRTScatterDef sd(*crc.fDef);
     sd.print(out,0); 
     // this is needed for CPU fallback for scatter whether or not CPU is enabled
   }

   printStub(out);
}
Example #3
0
// o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o+o
bool
BRTMapKernelDef::CheckSemantics() const
{
   FunctionType *fType;
   Decl *outArg = NULL;

   assert (decl->form->type == TT_Function);
   fType = (FunctionType *) decl->form;

   for (unsigned int i = 0; i < fType->nArgs; i++) {
      if (fType->args[i]->isReduce()) {
         std::cerr << location << "Reduce arguments are not allowed in "
                   << *FunctionName() << ": ";
         fType->args[i]->print(std::cerr, true);
         std::cerr << ".\n";
         return false;
      }

      if ((fType->args[i]->form->getQualifiers() & TQ_Out) != 0) {
 /*        if (outArg) {
            std::cerr << location << "Multiple outputs not supported: ";
            outArg->print(std::cerr, true);
            std::cerr << ", ";
            fType->args[i]->print(std::cerr, true);
            std::cerr << ".\n";
            return false;
         }*/
         outArg = fType->args[i];

         if (!recursiveIsStream(outArg->form)) {
            std::cerr << location << "Output is not a stream: ";
            outArg->print(std::cerr, true);
            std::cerr << ".\n";
            return false;
         }

         if ((outArg->form->getQualifiers() & TQ_Iter) != 0) {
            std::cerr << location << "Output cannot be an iterator: ";
            outArg->print(std::cerr, true);
            std::cerr << ".\n";
            return false;
         }
      }
   }

   if (outArg == NULL&&returnsVoid()) {
      std::cerr << location << "Warning: " << *FunctionName()
                << " has no output.\n";
   }

   return true;
}
Example #4
0
BOOL WINAPI RemovePropertySheet(int hSheet)
{
    register PSHEETLINK psl;
    FunctionName(RemovePropertySheet);

    // Validate the handle

    if (!hSheet)
        return FALSE;

    if ((UINT)hSheet > offHighestSheetLink)
        return FALSE;

    psl = (PSHEETLINK)hSheet;

    if (psl->iSig != SHEET_SIG)
        return FALSE;

    // Unlink from the global list

    cSheetLinks--;

    if (psl->pslPrev)
        psl->pslPrev->pslNext = psl->pslNext;
    else
        pslHead = psl->pslNext;

    if (psl->pslNext)
        psl->pslNext->pslPrev = psl->pslPrev;

    VERIFYTRUE(HeapFree(g_hProcessHeap, 0, (LPVOID)psl));

    return TRUE;
}
bool VerifyAnimationRename( UWidgetBlueprint* Blueprint, UWidgetAnimation* Animation, FString NewAnimationName, FText& OutErrorMessage )
{
	if ( FindObject<UWidgetAnimation>( Blueprint, *NewAnimationName, true ) )
	{
		OutErrorMessage = LOCTEXT( "NameInUseByAnimation", "An animation with this name already exists" );
		return false;
	}

	FName NewAnimationNameAsName( *NewAnimationName );
	if ( Blueprint->WidgetTree->FindWidget<UWidget>( NewAnimationNameAsName ) != nullptr )
	{
		OutErrorMessage = LOCTEXT( "NameInUseByWidget", "A widget with this name already exists" );
		return false;
	}

	FName FunctionName(*NewAnimationName);
	if (Animation->GetPreviewWidget().IsValid() && Animation->GetPreviewWidget().Get()->FindFunction(FunctionName))
	{
		OutErrorMessage = LOCTEXT("NameInUseByFunction", "A function with this name already exists");
		return false;
	}

	FKismetNameValidator Validator( Blueprint );
	EValidatorResult ValidationResult = Validator.IsValid( NewAnimationName );

	if ( ValidationResult != EValidatorResult::Ok )
	{
		FString ErrorString = FKismetNameValidator::GetErrorString( NewAnimationName, ValidationResult );
		OutErrorMessage = FText::FromString( ErrorString );
		return false;
	}

	return true;
}
Example #6
0
int WINAPI EnumPropertyLibs(int iLib, LPHANDLE lphDLL, LPTSTR lpszDLL, int cchszDLL)
{
    register PLIBLINK pll;
    FunctionName(EnumPropertyLibs);

    if (!iLib)
        pll = pllHead;
    else
        pll = ((PLIBLINK)iLib)->pllNext;

    // Validate the handle

    if (!pll)
        return 0;

    if ((UINT)pll > offHighestLibLink)
        return 0;

    if (pll->iSig != LIB_SIG)
        return 0;

    if (lphDLL)
        *lphDLL = pll->hDLL;

    if (lpszDLL)
        lstrcpyn(lpszDLL, pll->achDLL, min(cchszDLL, ARRAYSIZE(pll->achDLL)));

    return (int)pll;
}
Example #7
0
int WINAPI AddPropertySheet(const PROPSHEETPAGE *lppsi, int iType)
{
    register PSHEETLINK psl;
    FunctionName(AddPropertySheet);

    // Allocate new sheet link

    if (!(psl = (PSHEETLINK)HeapAlloc(g_hProcessHeap, HEAP_ZERO_MEMORY, SIZEOF(SHEETLINK))))
        return FALSE;

    if ((UINT)psl > offHighestSheetLink)
        offHighestSheetLink = (UINT)psl;

    // Initialize the sheet link

    psl->pslPrev = NULL;
    psl->iSig = SHEET_SIG;
    psl->psi = *lppsi;
    psl->iType = iType;

    // Link into the global sheet list

    if (NULL != (psl->pslNext = pslHead))
        pslHead->pslPrev = psl;
    pslHead = psl;

    cSheetLinks++;

    return (int)psl;
}
Example #8
0
int WINAPI LoadPropertySheets(int hProps, int flags)
{
    register PLIBLINK pll;
    FunctionName(LoadPropertySheets);

    // If this is the first edit session, do global init now

    if (cEdits++ == 0)
        if (!LoadGlobalEditData())
            return 0;

    pll = NULL;
    while (NULL != (pll = (PLIBLINK)EnumPropertyLibs((int)pll, NULL, NULL, 0))) {
        if (!pll->hDLL && (pll->flLib & LIB_DEFER)) {

            pll->hDLL = LoadLibrary(pll->achDLL);

            // If the load failed, to us that simply means those sheets
            // will not be available; the particular error is not interesting,
            // so nullify the handle

            if (pll->hDLL < (HINSTANCE)HINSTANCE_ERROR)
                pll->hDLL = NULL;
        }
    }
    return cSheetLinks + ARRAYSIZE(aPSInfo);
}
Example #9
0
void FreeGlobalEditData()
{
    FunctionName(FreeGlobalEditData);
    FreeGlobalFontEditData();

    VERIFYTRUE(HeapFree(g_hProcessHeap, 0, (LPVOID)pszNoMemory));
    pszNoMemory = NULL;

}
Example #10
0
BOOL LoadGlobalEditData()
{
    FunctionName(LoadGlobalEditData);

    pszNoMemory = (LPTSTR)HeapAlloc(g_hProcessHeap, HEAP_ZERO_MEMORY, 200*SIZEOF(TCHAR));
    if (!pszNoMemory)
        return FALSE;

    if (!LoadString(hModule, IDS_ERROR + ERROR_NOT_ENOUGH_MEMORY, pszNoMemory, 200))
        return FALSE;

    if (!LoadGlobalFontEditData())
        return FALSE;

    return TRUE;
}
Example #11
0
UINT CALLBACK PifPropPageRelease(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE lppsp)
{
    PPROPLINK ppl;
    FunctionName(PifPropPageRelease);

    if (uMsg == PSPCB_RELEASE) {

        ppl = (PPROPLINK)(int)lppsp->lParam;

        if ((--ppl->iSheetUsage) == 0) {

            FreePropertySheets((int)ppl, 0);

            PifMgr_CloseProperties((int)ppl, CLOSEPROPS_NONE);
        }
    }
    return 1;
}
Example #12
0
int WINAPI FreePropertySheets(int hProps, int flags)
{
    register PLIBLINK pll;
    FunctionName(FreePropertySheets);

    pll = NULL;
    while (NULL != (pll = (PLIBLINK)EnumPropertyLibs((int)pll, NULL, NULL, 0))) {
        if (pll->hDLL && (pll->flLib & LIB_DEFER)) {
            FreeLibrary(pll->hDLL);
            pll->hDLL = NULL;
        }
    }
    // If this is the last edit session, do global un-init now

    if (--cEdits == 0)
        FreeGlobalEditData();

    return 0;
}
Example #13
0
int WINAPI EnumPropertySheets(int hProps, int iType, int iSheet, LPPROPSHEETPAGE lppsp)
{
    register PSHEETLINK psl;
    FunctionName(EnumPropertySheets);

    // BUGBUG -- parameter validation? (raymondc)

    while (iSheet < ARRAYSIZE(aPSInfo)) {
        if (aPSInfo[iSheet].iType <= iType) {
            if (lppsp) {
                lppsp->dwSize      = SIZEOF(PROPSHEETPAGE);
                lppsp->dwFlags     = PSP_DEFAULT;
                lppsp->hInstance   = hModule;
                lppsp->pszTemplate = aPSInfo[iSheet].lpTemplateName;
                lppsp->pfnDlgProc  = aPSInfo[iSheet].lpfnDlgProc;
                // lppsp->pszTitle    = NULL;
                lppsp->lParam      = (long)hProps;
            }
            return ++iSheet;
        }
        ++iSheet;
    }
    if (iSheet == ARRAYSIZE(aPSInfo))
        psl = pslHead;
    else
        psl = ((PSHEETLINK)iSheet)->pslNext;

    // Validate the handle

    while (psl && (UINT)psl <= offHighestSheetLink && psl->iSig == SHEET_SIG) {

        if (psl->iType <= iType) {

            *lppsp = psl->psi;
            lppsp->lParam = (long)hProps;

            return (int)psl;
        }
        psl = psl->pslNext;
    }
    return 0;                   // no more matching sheets
}
Example #14
0
int WINAPI LoadPropertyLib(LPCTSTR lpszDLL, int fLoad)
{
    HINSTANCE hDLL;
    register PLIBLINK pll;
    FunctionName(LoadPropertyLib);

    hDLL = NULL;
    if (!(fLoad & LOADPROPLIB_DEFER)) {

        hDLL = LoadLibrary(lpszDLL);

        if (hDLL < (HINSTANCE)HINSTANCE_ERROR)
            return FALSE;
    }

    // Allocate new lib link

    if (!(pll = (PLIBLINK)HeapAlloc(g_hProcessHeap, HEAP_ZERO_MEMORY, SIZEOF(LIBLINK))))
        return FALSE;

    if ((UINT)pll > offHighestLibLink)
        offHighestLibLink = (UINT)pll;

    // Initialize the lib link

    pll->pllPrev = NULL;
    pll->iSig = LIB_SIG;
    pll->hDLL = hDLL;
    pll->flLib = 0;
    if (!hDLL)
        pll->flLib |= LIB_DEFER;
    lstrcpyn(pll->achDLL, lpszDLL, ARRAYSIZE(pll->achDLL));

    // Link into the global lib list

    if (NULL != (pll->pllNext = pllHead))
        pllHead->pllPrev = pll;
    pllHead = pll;

    return (int)pll;
}
Example #15
0
//---------------------------------------------------------------------------
bool TFuncData::CheckRecursive(std::vector<const TFuncData*> &FuncStack) const
{
  for(std::vector<TElem>::const_iterator Iter = Data.begin(); Iter != Data.end(); ++Iter)
    if(Iter->Ident == CodeCustom)
      try
      {
        boost::shared_ptr<TBaseCustomFunc> Func = boost::any_cast<boost::shared_ptr<TBaseCustomFunc> >(Iter->Value);
        if(std::find(FuncStack.begin(), FuncStack.end(), Func->GetFuncData().get()) != FuncStack.end())
          return true;

        FuncStack.push_back(Func->GetFuncData().get());
        if(Func->GetFuncData()->CheckRecursive(FuncStack))
          return true;
        FuncStack.pop_back();
      }
      catch(EFuncError &E)
      {
        E.Str = FunctionName(*Iter);
        throw;
      }

  return false;
}
Example #16
0
BOOL WINAPI FreePropertyLib(int hLib)
{
    register PLIBLINK pll;
    FunctionName(FreePropertyLib);

    // Validate the handle

    if (!hLib)
        return FALSE;

    if ((UINT)hLib > offHighestLibLink)
        return FALSE;

    pll = (PLIBLINK)hLib;

    if (pll->iSig != LIB_SIG)
        return FALSE;

    // Free the associated library

    if (pll->hDLL)
        FreeLibrary(pll->hDLL);

    // Unlink from the global list

    if (pll->pllPrev)
        pll->pllPrev->pllNext = pll->pllNext;
    else
        pllHead = pll->pllNext;

    if (pll->pllNext)
        pll->pllNext->pllPrev = pll->pllPrev;

    VERIFYTRUE(HeapFree(g_hProcessHeap, 0, (LPVOID)pll));

    return TRUE;
}
Example #17
0
BOOL WINAPI PifPropGetPages(LPVOID lpv,
                            LPFNADDPROPSHEETPAGE lpfnAddPage,
                            LPARAM lParam)
{
#define hDrop   (HDROP)lpv
    PPROPLINK ppl;
    PROPSHEETPAGE psp;
    int iType, iSheet, cSheets;
    HPROPSHEETPAGE hpage;
    TCHAR szFileName[MAXPATHNAME];
    FunctionName(PifPropGetPages);

    // only process things if hDrop contains only one file
    if (DragQueryFile(hDrop, (UINT)-1, NULL, 0) != 1)
    {
        return TRUE;
    }

    // get the name of the file
    DragQueryFile(hDrop, 0, szFileName, ARRAYSIZE(szFileName));

    // if this is a windows app, don't do no properties
    if (IsWinExe(szFileName))
        return TRUE;

    // if we can't get a property handle, don't do no properties either
    if (!(ppl = (PPROPLINK)PifMgr_OpenProperties(szFileName, NULL, 0, OPENPROPS_NONE)))
        return TRUE;

    InitRealModeFlag(ppl);

    if (!(cSheets = LoadPropertySheets((int)ppl, 0)))
        goto CloseProps;

    // Since the user wishes to *explicitly* change settings for this app
    // we make sure that the DONTWRITE flag isn't going to get in his way...

    ppl->flProp &= ~PROP_DONTWRITE;

    iSheet = cSheets = 0;
    iType = (GetKeyState(VK_CONTROL) >= 0? SHEETTYPE_SIMPLE : SHEETTYPE_ADVANCED);

    while (TRUE) {

        if (!(iSheet = EnumPropertySheets((int)ppl, iType, iSheet, &psp))) {
            // done with enumeration
            break;
        }
#ifndef WINNT
        psp.dwFlags |= PSP_USECALLBACK | PSP_USEREFPARENT;
        psp.pfnCallback = PifPropPageRelease;
        psp.pcRefParent = &s_cRefThisDll;
#else
        psp.dwFlags |= PSP_USECALLBACK;
        psp.pfnCallback = PifPropPageRelease;
        psp.pcRefParent = 0;
#endif

        hpage = CreatePropertySheetPage(&psp);
        if (hpage)
        {
            // the PROPLINK is now being used by this property sheet as well

            if (lpfnAddPage(hpage, lParam))
            {
                ppl->iSheetUsage++;
                cSheets++;
            }
            else
            {
                PifPropPageRelease(NULL, PSPCB_RELEASE, &psp);
            }
        }
    }

    if (!cSheets) {
        FreePropertySheets((int)ppl, 0);

CloseProps:
        PifMgr_CloseProperties((int)ppl, CLOSEPROPS_NONE);
    }
    return TRUE;
}
Example #18
0
/** Saves the first derivative of the sequence starting at Iter in the back *this
 *  \param Iter: Iterator to function to differentiate.
 *  \param Var: Variable to differentiate with respect to.
 *  \param Trigonemetry: Differentiate trigonometric functions as radians og degrees.
 *  \param Level: Indicates the number os times the function has been called recursive. To prevent infinite loops.
 *  \throw EFuncError: Thrown if differentiation fails.
 */
void TFuncData::AddDif(TConstIterator Iter, const TElem &Var, TTrigonometry Trigonometry, unsigned Level)
{
  if(*Iter == Var)
    Data.push_back(TElem(CodeNumber, 1));
  else if(Iter->Ident == CodeRand)
		throw EFuncError(ecNotDifAble, L"rand");
  else if(IsConstant(*Iter))
    Data.push_back(TElem(CodeNumber, 0.0));
	else
	{
		if(!ContainsElem(Iter, Var))
		{
			Data.push_back(TElem(CodeNumber, 0.0));
			return;
		}
		switch(Iter->Ident)
		{
			case CodeIf:
			case CodeIfSeq:
			{
				//f(x)=if(a1,b1,a2,b2, ... , an,bn [,c])
				//f'(x)=if(a1,b1',a2,b2', ... , an, bn' [,c'])
				Data.push_back(*Iter); //CodeIf with same number of arguments
				unsigned Arguments = FunctionArguments(*Iter);
				++Iter;
				for(unsigned I = 0; I < Arguments-1; I++)
				{
					TConstIterator End = FindEnd(Iter);
					if(I % 2)
						AddDif(Iter, Var, Trigonometry, Level);
					else
						Data.insert(Data.end(), Iter, End);
					Iter = End;
				}
				AddDif(Iter, Var, Trigonometry, Level);
				break;
			}

			case CodeMin:
			case CodeMax:
			{
				//f(x)=min(a1,a2,a3, ... , an) f'(x)=if(a1<a2 and a1<a3 ...,a1', a2<a1 and a2<a3 ...,a2',
				unsigned Arguments = Iter->Arguments;
				Data.push_back(TElem(CodeIf, 2*Arguments-1, 0));
				TConstIterator Param = Iter + 1;
				for(unsigned I = 0; I < Arguments-1; I++)
				{
					TConstIterator End = FindEnd(Param);
					for(unsigned J = 0; J < Arguments-2; J++)
						Data.push_back(CodeAnd);

					TConstIterator Param2 = Iter+1;
					for(unsigned J = 0; J < Arguments; J++)
					{
						if(J != I)
						{
							Data.push_back(TElem(Iter->Ident == CodeMin ? cmLess : cmGreater));
							Data.insert(Data.end(), Param, End);
							Data.insert(Data.end(), Param2, FindEnd(Param2));
						}
						Param2 = FindEnd(Param2);
					}

					AddDif(Param, Var, Trigonometry, Level);
					Param = End;
				}
				AddDif(Param, Var, Trigonometry, Level);
				break;
			}

			case CodeCustom:
			{
				if(Level > MaxDifLevel)
					throw EFuncError(ecRecursiveDif);
				boost::shared_ptr<TBaseCustomFunc> Func = boost::any_cast<boost::shared_ptr<TBaseCustomFunc> >(Iter->Value);
				if(Func)
					AddDif(Func->GetFuncData()->Data.begin(), Var, Trigonometry, Level + 1);
				else
					throw EFuncError(ecSymbolNotFound, Iter->Text);
				break;
			}
			case CodeDNorm:
			{
				std::vector<std::wstring> ArgNames;
				ArgNames.push_back(L"x");
				ArgNames.push_back(L"x2");
				ArgNames.push_back(L"x3");
				TFuncData Temp(FunctionDefinition(CodeDNorm), ArgNames);
				TFuncData Temp2;
				std::vector<std::vector<TElem> > Args(3);
				CopyReplaceArgs(Args.front(), Iter + 1, std::vector<std::vector<TElem> >());
				if(Iter->Arguments > 2)
				{
					TConstIterator Iter2 = FindEnd(Iter + 1);
					CopyReplaceArgs(Args[1], Iter2, std::vector<std::vector<TElem> >());
					CopyReplaceArgs(Args[2], FindEnd(Iter2), std::vector<std::vector<TElem> >());
				}
				else
				{
					Args[1].push_back(TElem(CodeNumber, 0.0));
					Args[2].push_back(TElem(CodeNumber, 1.0));
				}
				CopyReplaceArgs(Temp2.Data, Temp.Data.begin(), Args);
				AddDif(Temp2.Data.begin(), Var, Trigonometry, Level + 1);
				break;
			}

			case CodeMod:
				if(ContainsElem(FindEnd(Iter+1), Var))
					throw EFuncError(ecNotDifAble, FunctionName(CodeMod));
        AddDif(Iter+1, Var, Trigonometry, Level + 1);
				break;

			default:
			{
				if(Trigonometry == Degree)
				{
					//Sin, Cos, Tan, Csc, Sec, Cot must be multiplied with PI/180 when differentiated using degrees
					if((Iter->Ident >= CodeSin && Iter->Ident <= CodeTan) || (Iter->Ident >= CodeCsc && Iter->Ident <= CodeCot))
					{
						Data.push_back(CodeMul);
						Data.push_back(CodeDiv);
						Data.push_back(CodePi);
						Data.push_back(180);
					}
					//ASin, ACos, ATan, ACsc, ASec, ACot must be multiplied with 180/PI when differentiated using degrees
					else if((Iter->Ident >= CodeASin && Iter->Ident <= CodeATan) || (Iter->Ident >= CodeACsc && Iter->Ident <= CodeACot))
					{
						Data.push_back(CodeMul);
						Data.push_back(CodeDiv);
						Data.push_back(180);
						Data.push_back(CodePi);
					}
				}

				const TFuncData &DifData = GetDif(Iter->Ident);
				if(Iter->Ident == CodeIntegrate)
				{
					//f(x)=integrate(g(x,s), s, a(x), b(x))
					//f'(x)=g(x,b(x))*db(x)/dx - g(x,a(x))*da(x)/dx + integrate(dg(x,s)/dx, s, a(x), b(x))
					TConstIterator From = FindEnd(Iter + 1);
					TConstIterator To = FindEnd(From);
					TConstIterator End = FindEnd(To);
					TElem Elem = *Iter;
					Elem.Ident = CodeConst;
					if(!Iter->Text.empty())
						Data.push_back(CodeAdd);
					Data.push_back(CodeSub);
					Data.push_back(CodeMul);
					CopyReplace(Data, Iter + 1, Elem, To, End);
					AddDif(To, Var, Trigonometry, Level);

					Data.push_back(CodeMul);
					CopyReplace(Data, Iter + 1, Elem, From, To);
					AddDif(From, Var, Trigonometry, Level);
					if(!Iter->Text.empty())
					{ //Backward compatibility:
						//f(x)=integrate(g(x), a(x), b(x))
						//f'(x)=g(x,b(x))*db(x)/dx - g(x,a(x))*da(x)/dx
						Data.push_back(*Iter);
						AddDif(Iter + 1, Var, Trigonometry, Level);
						Data.insert(Data.end(), From, End);
          }
				}
				else if(DifData.IsEmpty())
					throw EFuncError(ecNotDifAble, FunctionName(*Iter));

				TConstIterator End = DifData.Data.end();
				TConstIterator FirstPar = Iter;             //Start of first parenthesis
				++FirstPar;
				TConstIterator SecondPar = FindEnd(FirstPar); //Start of second parenthesis
				TConstIterator ThirdPar;
				if(FunctionArguments(*Iter) >= 2)
					ThirdPar = FindEnd(SecondPar); //Start of third parenthesis

				TConstIterator Begin = DifData.Data.begin();
				if(Iter->Ident == CodeSum) //Use the original CodeSum instead of the one from DifData
				{
					Data.push_back(*Iter);
					Begin++;
				}

				for(TConstIterator Elem = Begin; Elem != End; ++Elem)
					if(Elem->Ident == CodeArgument)
						Data.insert(Data.end(), FirstPar, SecondPar);
					else if(*Elem == TElem(CodeCustom, L"dx"))
						AddDif(FirstPar, Var, Trigonometry, Level);
					else if(*Elem == TElem(CodeCustom, L"x2"))
						Data.insert(Data.end(), SecondPar, ThirdPar);
					else if(*Elem == TElem(CodeCustom, L"dx2"))
						AddDif(SecondPar, Var, Trigonometry, Level);
					else if(*Elem == TElem(CodeCustom, L"x3"))
						Data.insert(Data.end(), ThirdPar, FindEnd(ThirdPar));
					else if(*Elem == TElem(CodeCustom, L"dx3"))
						AddDif(ThirdPar, Var, Trigonometry, Level);
					else
						Data.push_back(*Elem);
				}
		}
	}
}
Example #19
0
int32_t TrapHandler(struct NaClApp *nap, uint32_t args)
{
  uint64_t *sargs;
  int retcode = 0;

  assert(nap != NULL);
  assert(nap->manifest != NULL);

  /*
   * translate address from user space to system
   * note: cannot set "trap error"
   */
  sargs = (uint64_t*)NaClUserToSys(nap, (uintptr_t)args);
  ZLOGS(LOG_DEBUG, "%s called", FunctionName(*sargs));
  ZTrace("untrusted code");

  switch(*sargs)
  {
    case TrapFork:
      retcode = Daemon(nap);
      if(retcode) break;
      SyscallZTrace(*sargs, 0);
      SyscallZTrace(TrapExit, 0);
      ZVMExitHandle(nap, 0);
      break;
    case TrapExit:
      SyscallZTrace(*sargs, sargs[2]);
      ZVMExitHandle(nap, (int32_t)sargs[2]);
      break;
    case TrapRead:
      retcode = ZVMReadHandle(nap,
          (int)sargs[2], (char*)sargs[3], (int32_t)sargs[4], sargs[5]);
      break;
    case TrapWrite:
      retcode = ZVMWriteHandle(nap,
          (int)sargs[2], (char*)sargs[3], (int32_t)sargs[4], sargs[5]);
      break;
    case TrapJail:
      retcode = ZVMJailHandle(nap, (uint32_t)sargs[2], (int32_t)sargs[3]);
      break;
    case TrapUnjail:
      retcode = ZVMUnjailHandle(nap, (uint32_t)sargs[2], (int32_t)sargs[3]);
      break;

#ifdef ZVM_SOCKETS
    case TrapSocket:
      retcode = ZVM_socket((int)sargs[2], (int)sargs[3], (int)sargs[4]);
      break;
    case TrapBind: {
      const struct sockaddr *addr = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      retcode = ZVM_bind((int)sargs[2], addr, (socklen_t)sargs[4]);
      break; }
    case TrapConnect: {
      const struct sockaddr *addr = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      retcode = ZVM_connect((int)sargs[2], addr, (socklen_t)sargs[4]);
      break; }
    case TrapAccept: {
      struct sockaddr *addr = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      socklen_t *len = (void*)NaClUserToSys(nap, (uintptr_t)sargs[4]);
      retcode = ZVM_accept((int)sargs[2], addr, len);
      break; }
    case TrapListen:
      retcode = ZVM_listen((int)sargs[2], (int)sargs[3]);
      break;
    case TrapRecv: {
      void *buf = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      retcode = ZVM_recv((int)sargs[2], buf, (size_t)sargs[4], (int)sargs[5]);
      break; }
    case TrapRecvfrom: {
      void *buf = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      struct sockaddr *addr = (void*)NaClUserToSys(nap, (uintptr_t)sargs[6]);
      socklen_t *len = (void*)NaClUserToSys(nap, (uintptr_t)sargs[7]);
      retcode = ZVM_recvfrom((int)sargs[2], buf, (size_t)sargs[4], (int)sargs[5], addr, len);
      break; }
    case TrapRecvmsg: {
      struct msghdr *msg = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      retcode = ZVM_recvmsg((int)sargs[2], msg, (int)sargs[4]);
      break; }
    case TrapSend: {
      const void *buf = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      retcode = ZVM_send((int)sargs[2], buf, (size_t)sargs[4], (int)sargs[5]);
      break; }
    case TrapSendto: {
      const void *buf = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      const struct sockaddr *addr = (void*)NaClUserToSys(nap, (uintptr_t)sargs[6]);
      retcode = ZVM_sendto((int)sargs[2], buf, (size_t)sargs[4], (int)sargs[5], addr, (socklen_t)sargs[7]);
      break; }
    case TrapSendmsg: {
      const struct msghdr *msg = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      retcode = ZVM_sendmsg((int)sargs[2], msg, (int)sargs[4]);
      break; }
    case TrapGetsockopt: {
      void *optval = (void*)NaClUserToSys(nap, (uintptr_t)sargs[5]);
      socklen_t *len = (void*)NaClUserToSys(nap, (uintptr_t)sargs[6]);
      retcode = ZVM_getsockopt((int)sargs[2], (int)sargs[3], (int)sargs[4], optval, len);
      break; }
    case TrapSetsockopt: {
      const void *optval = (void*)NaClUserToSys(nap, (uintptr_t)sargs[5]);
      retcode = ZVM_setsockopt((int)sargs[2], (int)sargs[3], (int)sargs[4], optval, (socklen_t)sargs[6]);
      break; }
    case TrapSelect: {
      fd_set *readfds = (void*)NaClUserToSys(nap, (uintptr_t)sargs[3]);
      fd_set *writefds = (void*)NaClUserToSys(nap, (uintptr_t)sargs[4]);
      fd_set *exceptfds = (void*)NaClUserToSys(nap, (uintptr_t)sargs[5]);
      struct timeval *timeout = (void*)NaClUserToSys(nap, (uintptr_t)sargs[6]);
      retcode = ZVM_select((int)sargs[2], readfds, writefds, exceptfds, timeout);
      break; }
    case TrapPoll: {
      struct pollfd *fds = (void*)NaClUserToSys(nap, (uintptr_t)sargs[2]);
      retcode = ZVM_poll(fds, (nfds_t)sargs[3], (int)sargs[4]);
      break; }
    case TrapGethostbyname: {
      const char *name = (void*)NaClUserToSys(nap, (uintptr_t)sargs[2]);
      retcode = (int)(intptr_t)ZVM_gethostbyname(name);
      break; }
    case TrapGethostbyaddr: {
      const void *addr = (void*)NaClUserToSys(nap, (uintptr_t)sargs[2]);
      retcode = (int)(intptr_t)ZVM_gethostbyaddr(addr, (socklen_t)sargs[3], (int)sargs[4]);
      break; }
    case TrapClose:
      retcode = ZVM_close((int)sargs[2]);
      break;
#endif

    default:
      retcode = -EPERM;
      ZLOG(LOG_ERROR, "function %ld is not supported", *sargs);
      break;
  }

  /* report, ztrace and return */
  FastReport();
  ZLOGS(LOG_DEBUG, "%s returned %d", FunctionName(*sargs), retcode);
  SyscallZTrace(*sargs, retcode, sargs[2], sargs[3], sargs[4], sargs[5], sargs[6], sargs[7]);
  return retcode;
}
Example #20
0
int WINAPI EditProperties(int hProps, LPCTSTR lpszTitle, UINT uStartPage, HWND hwnd, UINT uMsgPost)
{
    int iSheet, cSheets;
    PPROPLINK ppl;
    PROPSHEETHEADER psh;
    PROPSHEETPAGE *ppsp;
    register PSHEETLINK psl;
    FunctionName(EditProperties);

    if (!(ppl = ValidPropHandle(hProps)))
        return FALSE;

    if (hwnd && uMsgPost) {
        ppl->hwndNotify = hwnd;
        ppl->uMsgNotify = uMsgPost;
    }
    cSheets = LoadPropertySheets(hProps, 0);

    psl = pslHead;
    if (!(ppsp = (PROPSHEETPAGE *)HeapAlloc(g_hProcessHeap, HEAP_ZERO_MEMORY, cSheets*SIZEOF(PROPSHEETPAGE))))
        return FALSE;

    psh.dwSize = SIZEOF(psh);
    psh.dwFlags = PSH_PROPTITLE | PSH_PROPSHEETPAGE;
    psh.hwndParent = hwnd;
    if (!lpszTitle)
        psh.pszCaption = ppl->szPathName+ppl->iFileName;
    else
        psh.pszCaption = ppl->lpszTitle = lpszTitle;
    psh.nPages = 0;
    psh.nStartPage = uStartPage;
    psh.ppsp = ppsp;

    cSheets = iSheet = 0;

    while (0 != (iSheet = EnumPropertySheets(hProps, SHEETTYPE_SIMPLE, iSheet, ppsp))) {
        cSheets++;
        ppsp++;
    }
    psh.nPages = cSheets;

    // Since the user wishes to *explicitly* change settings for this app
    // we make sure that the DONTWRITE flag isn't going to get in his way...

    ppl->flProp &= ~PROP_DONTWRITE;

    InitRealModeFlag(ppl);

    PropertySheet(&psh);

    VERIFYFALSE(LocalFree((HLOCAL)psh.ppsp));

    FreePropertySheets(hProps, 0);

    if (ppl->flProp & PROP_NOTIFY) {
        ppl->flProp &= ~PROP_NOTIFY;
        PostMessage(ppl->hwndNotify, ppl->uMsgNotify, 0, 0);
    }
    ppl->hwndNotify = NULL;
    ppl->uMsgNotify = 0;
    ppl->lpszTitle = NULL;

    return TRUE;
}
Example #21
0
void BRTKernelDef::PrintVoutPostfix(std::ostream & out) const{
   out << "    __vout_counter+=1.0f;"<<std::endl;
   FunctionType* ft = static_cast<FunctionType*>(decl->form);
   std::set<unsigned int >::iterator beginvout
      = voutFunctions[FunctionName()->name].begin();
   std::set<unsigned int >::iterator endvout
      = voutFunctions[FunctionName()->name].end();
   std::set<unsigned int >::iterator iter;
   std::set<unsigned int >::iterator inneriter;
   bool limited_vout=false;
   bool allone=true;
   unsigned int limited_vout_counter=0;
   unsigned int numlimits=0;
   for (iter = beginvout;iter!=endvout;++iter) {
      Decl * decl = ft->args[*iter];
      Expression * vout_limit = decl->form->getQualifiers().vout;
      if (vout_limit) {
        bool filter=isFilter(vout_limit);
        allone=(allone&&filter);
        
        if (limited_vout||beginvout==iter) {
          limited_vout=true;
          numlimits++;
        }
        else
          limited_vout=false;
      }
   }
   if (numlimits>1&&!allone){
     numlimits=0;
     limited_vout=false;
   }
   for (iter = beginvout;iter!=endvout;++iter) {
      Decl * decl = ft->args[*iter];
      Expression * vout_limit = decl->form->getQualifiers().vout;
      
      if (vout_limit&&limited_vout) {
        if (limited_vout_counter==0) out << "     if (";
        bool useparen=(vout_limit->precedence() < 
                       RelExpr(RO_Less,
                               NULL,
                               NULL,
                               vout_limit->location).precedence());
        // the above is a simple check for the common expressions.
        // no need to get fancy here for parens are ok in this case.
        out <<"(__vout_counter >= ";
        if (useparen) out << "(";
        vout_limit->print(out);
        if (useparen) out << ")";
        out << ")";
        limited_vout_counter++;
        if (limited_vout_counter==numlimits) {
           out <<") {"<<std::endl;
           for (inneriter = beginvout;inneriter!=endvout;++inneriter) {
              Decl * decl = ft->args[*inneriter];
              out <<"      ";
              out <<getDeclStream(decl,"_outputs")<<".push_back(0);"<<std::endl;
           }
           out <<"      ";              
           out <<"break;"<<std::endl;
           out <<"    }"<<std::endl;
        }else {
           out << "&&";
        }
      }else {
         out << "    "<<getDeclStream(decl,"_values")<< " = ";

         out << "(";
         out << decl->name->name<<"->getDimension()==2?";
         out << "finiteValueProduced"<<getDimensionString(2)<<undecoratedBase(decl);
         out << ":finiteValueProduced"<<getDimensionString(1);      
         out << undecoratedBase(decl)<<")(*"<<getDeclStream(decl,"_outputs");
         out << ".back())?1:0;"<<std::endl;
      }
   }
   out << "  }"<<std::endl;
   for (iter = beginvout;iter!=endvout;++iter) {
      
      Decl * decl = ft->args[*iter];
      out << "  if ("<<decl->name->name<<"->getDimension()==2) {"<<std::endl;
      PrintVoutDimensionalShift(out,decl,2);
      out << "  }else {"<<std::endl;
      PrintVoutDimensionalShift(out,decl,1);
      out << "  }"<<std::endl;
      out << "  while ("<<getDeclStream(decl,"_outputs")<<".size()) {";
      out << std::endl;
      out << "    if ("<<getDeclStream(decl,"_outputs")<<".back())"<<std::endl;
      out << "      delete "<<getDeclStream(decl,"_outputs")<<".back();";
      out << std::endl;
      out << "    "<<getDeclStream(decl,"_outputs")<<".pop_back();"<<std::endl;
      out << "  }"<<std::endl;
   }
}
Example #22
0
int main(){	
	//std::cout << "Hello World!" << std::endl;
	FunctionName(1);
	return 0;
}
Example #23
0
void BRTKernelDef::PrintVoutPrefix(std::ostream & out) const{
   FunctionType* ft = static_cast<FunctionType*>(decl->form);
   std::set<unsigned int > *vouts= &voutFunctions[FunctionName()->name];
   std::set<unsigned int >::iterator iter;
   out << "  float __vout_counter=0.0f;"<<std::endl;
#ifdef INF_SENTINEL
   out << "  brook::Stream * __inf = *sentinelStream(1);";
#else
   out << "  float __inf = getSentinel();";
#endif //INF_SENTINEL
   out << std::endl;
   out << "  int maxextents[2]={0,0};"<<std::endl;
   unsigned int i=0;   
   for (bool found=0;i<ft->nArgs;++i) {
      if ((ft->args[i]->form->getQualifiers()&TQ_Out)==0
          &&ft->args[i]->isStream()
          && vouts->find(i)==vouts->end()) {
         std::string name = ft->args[i]->name->name;
         if (!found) {
            out << "  unsigned int __dimension = "<<name<<"->getDimension();";
            out << std::endl;
         }
         out << "  assert ("<<name<<"->getDimension()<=2);" << std::endl;
         out << "  maxDimension(maxextents,"<<name<<"->getExtents(),";
         out << name << "->getDimension());" << std::endl;
         found=true;
      }
   }
   for (iter = vouts->begin();iter!=vouts->end();++iter) {
      out << "  std:: vector <__BRTStreamType> ";
      std::string typevector = getDeclStream(ft->args[*iter],"_types");
      out << typevector <<";"<<std::endl;
      std::string streamiter = getDeclStream(ft->args[*iter],"_iter");
      out << "  for (int "<<streamiter << " = 0; ";
      out <<streamiter<<" < "<<ft->args[*iter]->name->name;
      out <<"->getFieldCount(); ++";
      out << streamiter << ") \n";
      out << "    "<<typevector<<".push_back("<<ft->args[*iter]->name->name;
      out << "->getIndexedFieldType("<<streamiter<<"));\n";
      out << "  "<<typevector<<".push_back(__BRTNONE);\n";
     out << "  std::vector<brook::stream*> ";
      out<<getDeclStream(ft->args[*iter],"_outputs")<<";";
      out << std::endl;
      out << "  bool "<<getDeclStream(ft->args[*iter],"_values")<<" = true;";
      out << std::endl;
   }
   out << "  while (";
   iter = vouts->begin();
   out << getDeclStream (ft->args[*iter++],"_values");
   for (;iter!=vouts->end();++iter) {
      out << " || " << getDeclStream (ft->args[*iter],"_values");
   }
   out << ") {"<<std::endl;
   for (iter = vouts->begin();iter!=vouts->end();++iter) {
      std::string typevector = getDeclStream(ft->args[*iter],"_types");
      out << "    if ("<<getDeclStream(ft->args[*iter],"_values")<<")";
      out << std::endl;
      out << "      "<<getDeclStream(ft->args[*iter],"_outputs");
      out << ".push_back (new ::brook::stream (maxextents, ";
      out << "__dimension, &"<<typevector<<"[0]));";
      out <<std::endl;      
   }
}
Example #24
0
DWORD CALLBACK
Entry(
    IN  DI_FUNCTION                 Function,
    IN  HDEVINFO                    DeviceInfoSet,
    IN  PSP_DEVINFO_DATA            DeviceInfoData,
    IN  PCOINSTALLER_CONTEXT_DATA   Context
    )
{
    HRESULT                         Error;

    Log("%s (%s) ===>",
        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
        DAY_STR "/" MONTH_STR "/" YEAR_STR);

    if (!Context->PostProcessing) {
        Log("%s PreProcessing",
            FunctionName(Function));
    } else {
        Log("%s PostProcessing (%08x)",
            FunctionName(Function),
            Context->InstallResult);
    }

    switch (Function) {
    case DIF_INSTALLDEVICE: {
        SP_DRVINFO_DATA         DriverInfoData;
        BOOLEAN                 DriverInfoAvailable;

        DriverInfoData.cbSize = sizeof (DriverInfoData);
        DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
                                                       DeviceInfoData,
                                                       &DriverInfoData) ?
                              TRUE :
                              FALSE;

        // If there is no driver information then the NULL driver is being
        // installed. Treat this as we would a DIF_REMOVE.
        Error = (DriverInfoAvailable) ?
                DifInstall(DeviceInfoSet, DeviceInfoData, Context) :
                DifRemove(DeviceInfoSet, DeviceInfoData, Context);
        break;
    }
    case DIF_REMOVE:
        Error = DifRemove(DeviceInfoSet, DeviceInfoData, Context);
        break;
    default:
        if (!Context->PostProcessing) {
            Error = NO_ERROR;
        } else {
            Error = Context->InstallResult;
        }

        break;
    }

    Log("%s (%s) <===",
        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
        DAY_STR "/" MONTH_STR "/" YEAR_STR);

    return (DWORD)Error;
}
Example #25
0
void
BRTKernelDef::printStub(std::ostream& out) const
{
  if (!returnsVoid())return;
   FunctionType *fType;
   unsigned int i,NumArgs;
   bool vout=voutFunctions.find(FunctionName()->name)!=voutFunctions.end();
   if (vout) {
      printPrototypes (out,"float");
      printPrototypes (out,"float2");
      printPrototypes (out,"float3");
      printPrototypes (out,"float4");
   }
   assert (decl->form->type == TT_Function);
   fType = (FunctionType *) decl->form;
   std::vector <bool> streamOrVal;
   NumArgs=fType->nArgs;

   if (vout) {

   }
   if (vout) {
      for (int i=NumArgs-1;i>=0;--i) {
         if (fType->args[i]->name->name=="__inf"||
             fType->args[i]->name->name=="__vout_counter")
            NumArgs--;
         else
            break;
      }
   }
   for (i = 0; i < NumArgs; i++) {
      if ((fType->args[i]->form->getQualifiers()&TQ_Reduce)!=0) {
         streamOrVal.push_back(false);
      }
   }
   do {
      unsigned int reducecount=0;
      fType->subType->printType(out, NULL, true, 0);
      out << " " << *FunctionName() << " (";
      
      for (i = 0; i < NumArgs; i++) {
         if (i) out << ",\n\t\t";
         
         if ((fType->args[i]->form->getQualifiers()&TQ_Reduce)!=0){
            if (streamOrVal[reducecount++]) {
               Symbol name;name.name = "& "+fType->args[i]->name->name;
               Type * t = fType->args[i]->form;
               if (fType->args[i]->isStream())
                  t = static_cast<ArrayType*>(fType->args[i]->form)->subType;                  
               t->printType(out,&name,true,0);
            }else{
               out << "::brook::stream "<< *fType->args[i]->name;
            }
         } else if ((fType->args[i]->form->getQualifiers() & TQ_Iter)!=0) {
            out << "const __BRTIter& " << *fType->args[i]->name;
         } else if (recursiveIsStream(fType->args[i]->form) ||
                    recursiveIsGather(fType->args[i]->form)) {
            
            out << "::brook::stream ";
            if ((voutFunctions[FunctionName()->name].find(i)
                 !=voutFunctions[FunctionName()->name].end())) {
               out << "&";
               // Vout changes dimension and must be passed by ref
               // Optionally we could make streamSwap work properly--but this
               // is tricky with all the behind-the-scenes inheritance going on
               // if you change, please talk to danielrh at graphics 
               // first  Otherwise he'll have to fix all his vout tests.
            }
            out << *fType->args[i]->name;
         } else {
            out << "const ";
            Symbol name;name.name = fType->args[i]->name->name;
            //XXX -- C++ backend needs values to be passed by value...
            // It's a one time per kernel call hit--worth it to keep
            // Values from being aliased --Daniel
            //hence we only do the & for reduction vars
            fType->args[i]->form->printType(out,&name,true,0);
         }
      }
      out << ") {\n";
      out << "  static const void *__" << *FunctionName() << "_fp[] = {";
      out << std::endl;
      out << "     \"fp30\", __" << *FunctionName() << "_fp30," << std::endl;
      out << "     \"arb\", __" << *FunctionName() << "_arb," << std::endl;
      out << "     \"ps20\", __" << *FunctionName() << "_ps20," << std::endl;
      out << "     \"cpu\", (void *) __" << *FunctionName() << "_cpu,"<<std::endl;
      if (this->decl->isReduce()||reduceNeeded(this)) {
         out << "     \"ndcpu\", (void *) __" << *FunctionName() << "_ndcpu,"<<std::endl;
         if (globals.target&TARGET_MULTITHREADED_CPU) {//only make combiner if needed
            out << "     \"combine\", (void *) __";
            out << *FunctionName() << "__combine_cpu,";
            out << std::endl;
         }
      }
      if ((globals.target&TARGET_MULTITHREADED_CPU)==0) {
         out << "     \"combine\", 0,";//this signals to runtime
         //not to use multithreading
         out << std::endl;
      }
      out << "     NULL, NULL };"<<std::endl;
      
      out << "  static __BRTKernel k("
          << "__" << *FunctionName() << "_fp);\n\n";
      if (vout) {
         PrintVoutPrefix(out);
      }
      for (i=0; i < fType->nArgs; i++) {
         if (vout)
            out <<"  ";//nice spacing
         if (recursiveIsStream(fType->args[i]->form) &&
             (fType->args[i]->form->getQualifiers()&TQ_Out)!=0) {
            
            if (voutFunctions.find(FunctionName()->name)==voutFunctions.end()
                ||  voutFunctions[FunctionName()->name].find(i)
                    == voutFunctions[FunctionName()->name].end()) {
               out << "  k->PushOutput(" << *fType->args[i]->name << ");\n";
            }else {
               out << "  k->PushOutput(*" << getDeclStream(fType->args[i],
                                                           "_outputs");
               out << ".back());\n";
            }
         } else if ((fType->args[i]->form->getQualifiers() & TQ_Reduce)!=0) {
            out << "  k->PushReduce(&" << *fType->args[i]->name;
            out << ", __BRTReductionType(&" << *fType->args[i]->name <<"));\n";
         } else if ((fType->args[i]->form->getQualifiers() & TQ_Iter)!=0) {
            out << "  k->PushIter(" << *fType->args[i]->name << ");\n";
         } else if (recursiveIsStream(fType->args[i]->form)) {
            out << "  k->PushStream(" << *fType->args[i]->name << ");\n";
         } else if (recursiveIsGather(fType->args[i]->form)) {
            out << "  k->PushGatherStream(" << *fType->args[i]->name << ");\n";
         } else {
            out << "  k->PushConstant(" << *fType->args[i]->name << ");\n";
         }
      }
      if (vout)
         out <<"  ";//nice spacing
      if (decl->isReduce()) {
         out << "  k->Reduce();\n";
      }else {
         out << "  k->Map();\n";
      }
      if (vout)
         PrintVoutPostfix(out);
      out << "\n}\n\n";
   }while (incrementBoolVec(streamOrVal));
}