Пример #1
0
bool PikoBackend::createLLVMModule()
{
  clang::CompilerInstance *CI = new clang::CompilerInstance();
  CI->createDiagnostics(0,0);

  std::vector<const char*> args;
  args.push_back("-xc++");
  args.push_back("-D__PIKOC__");
  args.push_back("-D__PIKOC_DEVICE__");
  args.push_back("-fno-exceptions");
  args.push_back("-I");
  args.push_back(pikocOptions.workingDir.c_str());
  args.push_back("-I");
  args.push_back(pikocOptions.clangResourceDir.c_str());
  args.push_back("-I");
  args.push_back(pikocOptions.pikoIncludeDir.c_str());
  for(int i = 0; i < pikocOptions.includeDirs.size(); ++i) {
    args.push_back("-I");
    args.push_back(pikocOptions.includeDirs[i].c_str());
  }
  args.push_back(pikocOptions.inFileName.c_str());

  llvm::ArrayRef<const char*> argList(args);
  llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> diagnostics(&CI->getDiagnostics());
  clang::CompilerInvocation *compInvoke =
    clang::createInvocationFromCommandLine(argList, diagnostics);
  CI->setInvocation(compInvoke);

  clang::TargetOptions TO; 
  TO.Triple = this->getTargetTriple() + "-" + pikocOptions.osString;
  clang::TargetInfo* feTarget =
    clang::TargetInfo::CreateTargetInfo(CI->getDiagnostics(), TO);
  CI->setTarget(feTarget);
  CI->createFileManager();
  CI->createSourceManager(CI->getFileManager());
  CI->createPreprocessor();
  clang::Preprocessor &PP = CI->getPreprocessor();
  PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(),PP.getLangOpts());

  CI->createASTContext();

  const clang::FileEntry* inFile = CI->getFileManager().getFile(pikocOptions.inFileName);
  CI->getSourceManager().createMainFileID(inFile);
  CI->getDiagnosticClient().BeginSourceFile(CI->getLangOpts(), &CI->getPreprocessor());

  llvm::LLVMContext& ctx = llvm::getGlobalContext();
  clang::CodeGenerator* llvmCodeGen = clang::CreateLLVMCodeGen(
    CI->getDiagnostics(), "PikoPipe", CI->getCodeGenOpts(), ctx);

  clang::ParseAST(CI->getPreprocessor(), llvmCodeGen, CI->getASTContext());

  if(CI->getDiagnostics().hasErrorOccurred()) {
    return false;
  }

  this->module = llvmCodeGen->GetModule();

	return true;
}
Пример #2
0
VALUE or_feval(VALUE function_name, VALUE arguments)
{
  VALUE ruby_val = Qnil;
  int i, n;
  octave_value_list argList;
  
  n = RARRAY_LEN(arguments);
  
  bool is_function_definition = (n == 1 && FIXNUM_P(RARRAY_PTR(arguments)[0]) == 0 && strncmp(RSTRING_PTR(StringValue(RARRAY_PTR(arguments)[0])), "function ", 9) == 0);
  
  for (i = 0; i < n; i++) {
    argList(i) = OR_Variable(RARRAY_PTR(arguments)[i]).to_octave();
  }
  
  if (octave_set_current_context) {
    // unwind_protect::run_all();
    raw_mode(0);
  }

  can_interrupt = true;
  octave_initialized = true;

  try {
    symbol_table::set_scope(symbol_table::top_scope());
    reset_error_handler();
    
    int nargout = (is_function_definition ? 0 : 1);
    octave_value_list val = feval(std::string(RSTRING_PTR(function_name)), argList, nargout);
    if(val.length() > 0 && val(0).is_defined()) {
      ruby_val = OR_Variable(val(0)).to_ruby();
    }
  } catch (octave_interrupt_exception) {
    recover_from_exception();
    error_state = -2; 
  } catch (std::bad_alloc) {
    recover_from_exception();
    error_state = -3;
  }

  octave_initialized = false;

  return(ruby_val);
}
Пример #3
0
TTree *dataset2tree(RooDataSet *dataset){

  const RooArgSet *args = dataset->get();
  if(args==NULL) return NULL;
  RooArgList argList(*args);

  Double_t variables[50];
  Long64_t nEntries= dataset->numEntries();
  //nEntries=1;
  TTree *tree = new TTree("tree","tree");
  tree->SetDirectory(0);
  TIterator *it1=NULL; 
  it1 = argList.createIterator();
  int index1=0;
  for(RooRealVar *var = (RooRealVar *) it1->Next(); var!=NULL;
      var = (RooRealVar *) it1->Next(),index1++){
    TString name(var->GetName());
    name.ReplaceAll("-","_");
    tree->Branch(name, &(variables[index1]), name+"/D");
  }

  //  tree->Print();

  for(Long64_t jentry=0; jentry<nEntries; jentry++){
    
    TIterator *it=NULL; 
    RooArgList argList1(*(dataset->get(jentry)));
    it = argList1.createIterator();
    //(dataset->get(jentry))->Print();
    int index=0;
    for(RooRealVar *var = (RooRealVar *) it->Next(); var!=NULL;
	var = (RooRealVar *) it->Next(), index++){
      variables[index]=var->getVal();
      //var->Print();
    }
   
    delete it;
    tree->Fill();
  }
  tree->ResetBranchAddresses();
  //  tree->Print();
  return tree;
}
Пример #4
0
void Updater::ToDoProcess()
{
    QStringList commandList(ToDo.split("\n", QString::SkipEmptyParts));


    if(!commandList.isEmpty())
    {
        for(int i = 0; i < commandList.size(); ++i)
        {
            QStringList argList(commandList.at(i).split(" ", QString::SkipEmptyParts));

            QDir dir;

            if(argList.at(0) == "mkdir")
                for(int mkDirIndex = 1; mkDirIndex < argList.size(); mkDirIndex++)
                {
                    QFileInfo dirInfo(argList.at(mkDirIndex));
                    dir.mkdir(QDir::toNativeSeparators(dirInfo.absoluteFilePath().simplified()));
                }
            else if(argList.at(0) == "rmdir")
                for(int rmDirIndex = 1; rmDirIndex < argList.size(); rmDirIndex++)
                {
                    QDir dirToRemove(argList.at(rmDirIndex).simplified());
                    QFileInfoList infoList(dirToRemove.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot));
                    for(int j = 0; j < infoList.size(); j++)
                        QFile::remove(argList.at(rmDirIndex).simplified()+"/"+infoList.at(j).fileName());
                    dir.rmdir(argList.at(rmDirIndex).simplified());
                }
            else if(argList.at(0) == "del")
                for(int delFileIndex = 1; delFileIndex < argList.size(); delFileIndex++)
                    QFile::remove(argList.at(delFileIndex).simplified());
            else if(argList.at(0) == "renameFile")
            {
                if(QFile::exists(argList.at(2).simplified()))
                    QFile::remove(argList.at(2).simplified());
                QFile::rename(argList.at(1).simplified(), argList.at(2).simplified());
            }
            else if(argList.at(0) == "renameDir")
                dir.rename(argList.at(1).simplified(), argList.at(2).simplified());
        }
    }
    finish();
}
Пример #5
0
	void dynNetwork::noiseToStatesVec ( nodeBlueprint *n ,vector <boost::function<baseType () > > r )
	{
		if (r.size() == 1)
			while (r.size() < n->dimension())
				r.push_back(r[0]);
		
		if (r.size() !=  n->dimension())
			throw "wrong dimension for randomizeStates!";


				nodeList vl;
				verticesMatching (vl, n);
				nodeIterator vi;
				vector <baseType> argList(n->dimension());
				for (vi = vl.begin();vi != vl.end(); vi++ )
				{
					for (unsigned int i = 0; i < n->dimension() ; i++)
					{
						argList[i] = getState (*vi, i) + r[i]();	
					}
					setInitialConditionVec (*vi, argList);
				}
	}
JError
JExecute
	(
	const JCharacter*		cmd,
	pid_t*					childPID,
	const JExecuteAction	toAction,
	int*					toFD,
	const JExecuteAction	fromAction,
	int*					fromFD,
	const JExecuteAction	errAction,
	int*					errFD
	)
{
	// parse the string into a list of arguments

	JPtrArray<JString> argList(JPtrArrayT::kDeleteAll);
	JParseArgsForExec(cmd, &argList);

	// pass the arguments to JExecute

	return JExecute(argList, childPID,
					toAction, toFD, fromAction, fromFD,
					errAction, errFD);
}
Пример #7
0
UtlBoolean DialogEventPublisher::handleMessage(OsMsg& rMsg)
{
   SipDialog sipDialog;
   UtlString sipDialogContent;
   Url requestUrl;
   UtlString entity;
   UtlString* pEntity;
   char dialogId[10];
   SipDialogEvent* pThisCall;
   Dialog* pDialog;
   UtlString localTag, remoteTag;
   Url localIdentity, remoteIdentity;
   Url localTarget, remoteTarget;
   UtlString identity, displayName;
   OsTime receivedTime;
   int numOldContents;
   HttpBody* oldContent[1];

   int length;
   UtlString dialogEvent;
   
   // React to telephony events
   if(rMsg.getMsgSubType()== TaoMessage::EVENT)
   {
      TaoMessage* taoMessage = (TaoMessage*)&rMsg;

      int taoEventId = taoMessage->getTaoObjHandle();
      UtlString argList(taoMessage->getArgList());
      TaoString arg(argList, TAOMESSAGE_DELIMITER);

#ifdef DEBUGGING
      dumpTaoMessageArgs(taoEventId, arg) ;
#endif        
      UtlBoolean localConnection = atoi(arg[TAO_OFFER_PARAM_LOCAL_CONNECTION]);
      UtlString  callId = arg[TAO_OFFER_PARAM_CALLID] ;
      UtlString  address = arg[TAO_OFFER_PARAM_ADDRESS] ;

      switch (taoEventId) 
      {
         case PtEvent::CONNECTION_OFFERED:

            mpCallManager->getSipDialog(callId, address, sipDialog);
#ifdef DEBUGGING            
            sipDialog.toString(sipDialogContent);
            OsSysLog::add(FAC_SIP, PRI_DEBUG, "DialogEventPublisher:: sipDialog = %s", 
                          sipDialogContent.data());
#endif            
            sipDialog.getRemoteRequestUri(entity);
            
            OsSysLog::add(FAC_SIP, PRI_DEBUG, "DialogEventPublisher:: Call arrived: callId %s address %s requestUrl %s", 
                          callId.data(), address.data(), entity.data());

            if (entity.isNull())
            {
               OsSysLog::add(FAC_SIP, PRI_WARNING, "DialogEventPublisher:: Call arrived: callId %s address %s without requestUrl", 
                             callId.data(), address.data());
               break;
            }
            else
            {
               requestUrl = Url(entity);
               requestUrl.getIdentity(entity);
            }
               
            // Create a dialog event if has not been created yet
            pThisCall = (SipDialogEvent *) mCalls.findValue(&entity);
            if (pThisCall == NULL)
            {
               pEntity = new UtlString(entity);
               pThisCall = new SipDialogEvent(STATE, entity);
               mCalls.insertKeyAndValue(pEntity, pThisCall);
               OsSysLog::add(FAC_SIP, PRI_DEBUG, "DialogEventPublisher:: insert DialogEvent object %p to the list",
                             pThisCall);
            }

            // Create the dialog element
            sipDialog.getLocalField(localIdentity);
            localIdentity.getFieldParameter("tag", localTag);
   
            sipDialog.getRemoteField(remoteIdentity);
            remoteIdentity.getFieldParameter("tag", remoteTag);
               
            sprintf(dialogId, "%ld", mDialogId);
            mDialogId++;

            pDialog = new Dialog(dialogId, callId, localTag, remoteTag, "recipient");
            pDialog->setState(STATE_EARLY, NULL, NULL);
   
            localIdentity.getIdentity(identity);
            localIdentity.getDisplayName(displayName);
            pDialog->setLocalIdentity(identity, displayName);
   
            remoteIdentity.getIdentity(identity);
            remoteIdentity.getDisplayName(displayName);
            pDialog->setRemoteIdentity(identity, displayName);
   
            sipDialog.getLocalContact(localTarget);
            pDialog->setLocalTarget(localTarget.toString());
   
            sipDialog.getRemoteContact(remoteTarget);
            pDialog->setRemoteTarget(remoteTarget.toString());
               
            pDialog->setDuration(OsDateTime::getSecsSinceEpoch());
   
            pThisCall->insertDialog(pDialog);
   
            // Insert it into the active call list
            pThisCall->buildBody();

            // Send the content to the subscribe server
            if (!mpSipPublishContentMgr->publish(entity.data(), DIALOG_EVENT_TYPE, DIALOG_EVENT_TYPE, 1, (HttpBody**)&pThisCall, 1, numOldContents, oldContent))
            {
               pThisCall->getBytes(&dialogEvent, &length);
               OsSysLog::add(FAC_SIP, PRI_ERR, "DialogEventPublisher:: Call arrived - DialogEvent %s\n was not successfully published to the subscribe server",
                             dialogEvent.data());
            }
                        
            break;

         case PtEvent::CONNECTION_ESTABLISHED:
            if (localConnection) 
            {
               mpCallManager->getSipDialog(callId, address, sipDialog);
#ifdef DEBUGGING            
               sipDialog.toString(sipDialogContent);
               OsSysLog::add(FAC_SIP, PRI_DEBUG, "DialogEventPublisher:: sipDialog = %s", 
                             sipDialogContent.data());
#endif            
               sipDialog.getRemoteRequestUri(entity);

               OsSysLog::add(FAC_SIP, PRI_DEBUG, "Call connected: callId %s address %s with request %s",
                             callId.data(), address.data(), entity.data());

               if (entity.isNull())
               {
                  OsSysLog::add(FAC_SIP, PRI_WARNING, "DialogEventPublisher:: Call connected: callId %s address %s without requestUrl", 
                                callId.data(), address.data());
                  break;
               }
               else
               {
                  requestUrl = Url(entity);
                  requestUrl.getIdentity(entity);
               }
               
               pThisCall = (SipDialogEvent *) mCalls.findValue(&entity);
               if (pThisCall == NULL)
               {
                  pEntity = new UtlString(entity);
                  pThisCall = new SipDialogEvent(STATE, entity);
   
                  // Insert it into the active call list
                  mCalls.insertKeyAndValue(pEntity, pThisCall);
               }
               
               // Get the new callId because it might be changed
               sipDialog.getCallId(callId);

               pDialog = pThisCall->getDialog(callId);
               // Update the dialog content if exist
               if (pDialog)
               {
                  sipDialog.getLocalField(localIdentity);
                  localIdentity.getFieldParameter("tag", localTag);
   
                  sipDialog.getRemoteField(remoteIdentity);
                  remoteIdentity.getFieldParameter("tag", remoteTag);
               
                  pDialog->setTags(localTag, remoteTag);
   
                  sipDialog.getLocalContact(localTarget);
                  pDialog->setLocalTarget(localTarget.toString());
   
                  sipDialog.getRemoteContact(remoteTarget);
                  pDialog->setRemoteTarget(remoteTarget.toString());
   
                  pDialog->setState(STATE_CONFIRMED, NULL, NULL);
               }
               else
               {
                  // Create a new dialog element
                  sipDialog.getLocalField(localIdentity);
                  localIdentity.getFieldParameter("tag", localTag);
   
                  sipDialog.getRemoteField(remoteIdentity);
                  remoteIdentity.getFieldParameter("tag", remoteTag);
               
                  sprintf(dialogId, "%ld", mDialogId);
                  mDialogId++;
   
                  pDialog = new Dialog(dialogId, callId, localTag, remoteTag, "recipient");
                  pDialog->setState(STATE_CONFIRMED, NULL, NULL);
   
                  localIdentity.getIdentity(identity);
                  localIdentity.getDisplayName(displayName);
                  pDialog->setLocalIdentity(identity, displayName);
   
                  remoteIdentity.getIdentity(identity);
                  remoteIdentity.getDisplayName(displayName);
                  pDialog->setRemoteIdentity(identity, displayName);
   
                  sipDialog.getLocalContact(localTarget);
                  pDialog->setLocalTarget(localTarget.toString());
   
                  sipDialog.getRemoteContact(remoteTarget);
                  pDialog->setRemoteTarget(remoteTarget.toString());
   
                  pDialog->setDuration(OsDateTime::getSecsSinceEpoch());
   
                  pThisCall->insertDialog(pDialog);
               }
                   
               pThisCall->buildBody();

               // Publish the content to the subscribe server
               if (!mpSipPublishContentMgr->publish(entity.data(), DIALOG_EVENT_TYPE, DIALOG_EVENT_TYPE, 1, (HttpBody**)&pThisCall, 1, numOldContents, oldContent))
               {
                  pThisCall->getBytes(&dialogEvent, &length);
                  OsSysLog::add(FAC_SIP, PRI_ERR, "DialogEventPublisher:: Call connected - DialogEvent %s\n was not successfully published to the subscribe server",
                                dialogEvent.data());
               }
            }

            break;
            
         case PtEvent::CONNECTION_DISCONNECTED:
            if (!localConnection) 
            {
               mpCallManager->getSipDialog(callId, address, sipDialog);
#ifdef DEBUGGING            
               sipDialog.toString(sipDialogContent);
               OsSysLog::add(FAC_SIP, PRI_DEBUG, "DialogEventPublisher:: sipDialog = %s", 
                             sipDialogContent.data());
#endif            
               sipDialog.getLocalContact(requestUrl);
               requestUrl.getIdentity(entity);

               OsSysLog::add(FAC_SIP, PRI_DEBUG, "Call dropped: %s address %s with entity %s",
                             callId.data(), address.data(), entity.data());

               if (entity.isNull())
               {
                  OsSysLog::add(FAC_SIP, PRI_WARNING, "DialogEventPublisher:: Call dropped: callId %s address %s without requestUrl", 
                                callId.data(), address.data());
                  break;
               }
               
               // Get the new callId because it might be changed
               sipDialog.getCallId(callId);

               // Remove the call from the pool and clean up the call
               pThisCall = (SipDialogEvent *) mCalls.findValue(&entity);
               if (pThisCall)
               {
                  pDialog = pThisCall->getDialog(callId);
                  if (pDialog)
                  {
                     pDialog->setState(STATE_TERMINATED, NULL, NULL);
                   
                     pThisCall->buildBody();

                     // Publish the content to the subscribe server
                     if (!mpSipPublishContentMgr->publish(entity.data(), DIALOG_EVENT_TYPE, DIALOG_EVENT_TYPE, 1, (HttpBody**)&pThisCall, 1, numOldContents, oldContent))
                     {
                        pThisCall->getBytes(&dialogEvent, &length);
                        OsSysLog::add(FAC_SIP, PRI_ERR, "DialogEventPublisher:: Call dropped - DialogEvent %s\n was not successfully published to the subscribe server",
                                      dialogEvent.data());
                     }
                       
                     // Remove the dialog from the dialog event package
                     pDialog = pThisCall->removeDialog(pDialog);
                     delete pDialog;
                  }
                  
                  if (pThisCall->isEmpty())
                  {
                     // Unpublisher the content from the subscribe server
                     if (!mpSipPublishContentMgr->unpublish(entity.data(), DIALOG_EVENT_TYPE, DIALOG_EVENT_TYPE, 1, numOldContents, oldContent))
                     {
                        pThisCall->getBytes(&dialogEvent, &length);
                        OsSysLog::add(FAC_SIP, PRI_ERR, "DialogEventPublisher:: Call dropped - DialogEvent %s\n was not successfully unpublished to the subscribe server",
                                      dialogEvent.data());
                     }
                     
                     UtlContainable *foundValue;
                     mCalls.removeKeyAndValue(pEntity, foundValue);
                     if (foundValue)
                     {
                        OsSysLog::add(FAC_SIP, PRI_DEBUG, "DialogEventPublisher:: remove DialogEvent object %p from the list",
                                      pThisCall);
                        pThisCall = (SipDialogEvent *) foundValue;
                        delete pThisCall;
                        delete pEntity;
                     }
                  }
               }
               else
               {
                  OsSysLog::add(FAC_SIP, PRI_ERR, "DialogEventPublisher:: Call dropped - no entity %s founded in the active call list",
                                entity.data());
               }
            }

            break;
            
         case PtEvent::CONNECTION_FAILED:
            OsSysLog::add(FAC_SIP, PRI_WARNING, "Connection failed on call: %s", callId.data());

            break;
      }
   }
   return(TRUE);
}
Пример #8
0
EncodedJSValue DFG_OPERATION operationNewArrayBuffer(ExecState* exec, size_t start, size_t size)
{
    ArgList argList(exec->codeBlock()->constantBuffer(start), size);
    return JSValue::encode(constructArray(exec, argList));
}
Пример #9
0
EncodedJSValue DFG_OPERATION operationNewArray(ExecState* exec, void* start, size_t size)
{
    ArgList argList(static_cast<Register*>(start), size);
    return JSValue::encode(constructArray(exec, argList));
}
Пример #10
0
UtlBoolean Listener::handleMessage(OsMsg& rMsg)
{
   // React to telephony events
   if(rMsg.getMsgSubType()== TaoMessage::EVENT)
   {
      TaoMessage* taoMessage = (TaoMessage*)&rMsg;

      TaoEventId taoEventId = taoMessage->getTaoObjHandle();
      UtlString argList(taoMessage->getArgList());
      TaoString arg(argList, TAOMESSAGE_DELIMITER);

#ifdef DEBUGGING
      dumpTaoMessageArgs(taoEventId, arg) ;
#endif        
      UtlBoolean localConnection = atoi(arg[TAO_OFFER_PARAM_LOCAL_CONNECTION]);
      UtlString  callId = arg[TAO_OFFER_PARAM_CALLID] ;
      UtlString  address = arg[TAO_OFFER_PARAM_ADDRESS] ;

      switch (taoEventId) 
      {
         case PtEvent::CONNECTION_OFFERED:
            OsSysLog::add(FAC_MEDIASERVER_VXI, PRI_DEBUG, "Call arrived: callId %s address %s\n", 
                          callId.data(), address.data());

            mpCallManager->acceptConnection(callId, address);
            mpCallManager->answerTerminalConnection(callId, address, "*");

            break;
         case PtEvent::CONNECTION_ESTABLISHED:
            if (localConnection) 
            {
               OsSysLog::add(FAC_MEDIASERVER_VXI, PRI_DEBUG, "Call connected: callId %s\n", callId.data());

               CallObject* pThisCall = new CallObject(mpCallManager, callId, mPlayfile);

               // Create a player and start to play out the file
               if (pThisCall->playAudio() == OS_SUCCESS)
               {
                  // Put it in a sorted list
                  insertEntry(callId, pThisCall);
               }
               else
               {
                  // Drop the call
                  mpCallManager->drop(callId);
                  OsSysLog::add(FAC_MEDIASERVER_VXI, PRI_WARNING, "Listener::handleMessage - drop callId %s due to failure of playing audio\n",
                                callId.data());

                  delete pThisCall;
               }
            }

            break;
            
         case PtEvent::CONNECTION_DISCONNECTED:
            if (!localConnection) 
            {
               OsSysLog::add(FAC_MEDIASERVER_VXI, PRI_DEBUG, "Call Dropped: %s\n", callId.data());

               // Remove the call from the pool and clean up the call
               CallObject* pDroppedCall = removeEntry(callId);
               if (pDroppedCall)
               {
                  pDroppedCall->cleanUp();
                  delete pDroppedCall;

                  // Drop the call
                  mpCallManager->drop(callId);
               }
               else
               {
                  OsSysLog::add(FAC_MEDIASERVER_VXI, PRI_DEBUG, "Lisenter::handleMessage - no callId %s founded in the active call list\n",
                                callId.data());
               }
            }

            break;
            
         case PtEvent::CONNECTION_FAILED:
            OsSysLog::add(FAC_MEDIASERVER_VXI, PRI_WARNING, "Dropping call: %s\n", callId.data());

            mpCallManager->drop(callId);

            break;
      }
   }
   return(TRUE);
}