示例#1
0
clCallTipPtr clTernServer::ProcessCalltip(const wxString& output)
{
    // Function calltip response:
    // ================================
    // {
    //   "type": "fn(f: fn(elt: ?, i: number), context?: ?)",
    //   "name": "Array.prototype.forEach",
    //   "exprName": "forEach",
    //   "url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach",
    //   "doc": "Executes a provided function once per array element.",
    //   "origin": "ecma5"
    // }
    TagEntryPtrVector_t tags;
    TagEntryPtr t(new TagEntry());
    JSONRoot root(output);
    wxString type = root.toElement().namedObject("type").toString();
    int imgID;
    wxString sig, retValue;
    ProcessType(type, sig, retValue, imgID);
    if(sig.IsEmpty()) {
        return NULL;
    }
    t->SetSignature(sig);
    t->SetReturnValue(retValue);
    t->SetKind("function");
    t->SetFlags(TagEntry::Tag_No_Signature_Format);
    tags.push_back(t);
    return new clCallTip(tags);
}
示例#2
0
文件: ansicon.c 项目: kmkkmk/app
// Find the name of the DLL and inject it.
BOOL Inject( LPPROCESS_INFORMATION ppi )
{
  DWORD len;
  WCHAR dll[MAX_PATH];
  int	type;

#if (MYDEBUG > 0)
  if (GetModuleFileNameEx( ppi->hProcess, NULL, dll, lenof(dll) ))
    DEBUGSTR( L"%s", dll );
#endif
  type = ProcessType( ppi );
  if (type == 0)
    return FALSE;

  len = GetModuleFileName( NULL, dll, lenof(dll) );
  while (dll[len-1] != '\\')
    --len;
#ifdef _WIN64
  wsprintf( dll + len, L"ANSI%d.dll", type );
  if (type == 32)
    InjectDLL32( ppi, dll );
  else
    InjectDLL64( ppi, dll );
#else
  wcscpy( dll + len, L"ANSI32.dll" );
  InjectDLL32( ppi, dll );
#endif
  return TRUE;
}
示例#3
0
// Inject code into the target process to load our DLL.
void Inject( LPPROCESS_INFORMATION pinfo, LPPROCESS_INFORMATION lpi,
	     DWORD dwCreationFlags )
{
  int type = ProcessType( pinfo );
  if (type != 0)
  {
#ifdef _WIN64
    if (type == 32)
    {
      hDllNameType[0] = '3';
      hDllNameType[1] = '2';
      InjectDLL32( pinfo );
    }
    else
    {
      hDllNameType[0] = '6';
      hDllNameType[1] = '4';
      InjectDLL64( pinfo );
    }
#else
#ifdef W32ON64
    if (type == 64)
    {
      TCHAR args[64];
      STARTUPINFO si;
      PROCESS_INFORMATION pi;
      wcscpy( hDllNameType, L".exe" );
      wsprintf( args, L"errout -P%lu:%lu",
		      pinfo->dwProcessId, pinfo->dwThreadId );
      ZeroMemory( &si, sizeof(si) );
      si.cb = sizeof(si);
      if (CreateProcess( hDllName, args, NULL, NULL, FALSE, 0, NULL, NULL,
			 &si, &pi ))
      {
	WaitForSingleObject( pi.hProcess, INFINITE );
	CloseHandle( pi.hProcess );
	CloseHandle( pi.hThread );
      }
      wcscpy( hDllNameType, L"32.dll" );
    }
    else
#endif
    InjectDLL32( pinfo );
#endif
  }

  if (!(dwCreationFlags & CREATE_SUSPENDED))
    ResumeThread( pinfo->hThread );

  if (lpi)
  {
    memcpy( lpi, pinfo, sizeof(PROCESS_INFORMATION) );
  }
  else
  {
    CloseHandle( pinfo->hProcess );
    CloseHandle( pinfo->hThread );
  }
}
示例#4
0
void clTernServer::ProcessOutput(const wxString& output, wxCodeCompletionBoxEntry::Vec_t& entries)
{
    // code completion response:
    // ================================
    // {
    // "start": 78,
    // "end": 78,
    // "isProperty": true,
    // "isObjectKey": false,
    // "completions": [
    //   {
    //     "name": "concat",
    //     "type": "fn(other: [?])",
    //     "doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s).",
    //     "url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat"
    //   },
    //   {
    //     "name": "every",
    //     "type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
    //     "doc": "Tests whether all elements in the array pass the test implemented by the provided function.",
    //     "url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every"
    //   }]}

    entries.clear();

    JSONRoot root(output);
    JSONElement completionsArr = root.toElement().namedObject("completions");
    for(int i = 0; i < completionsArr.arraySize(); ++i) {
        JSONElement item = completionsArr.arrayItem(i);
        wxString name = item.namedObject("name").toString();
        wxString doc = item.namedObject("doc").toString();
        wxString url = item.namedObject("url").toString();
        bool isKeyword = item.namedObject("isKeyword").toBool();
        int imgId;
        if(!isKeyword) {
            doc = this->PrepareDoc(doc, url);
            wxString type = item.namedObject("type").toString();
            wxString sig, ret;
            ProcessType(type, sig, ret, imgId);

            // Remove double quotes
            name.StartsWith("\"", &name);
            name.EndsWith("\"", &name);

            wxCodeCompletionBoxEntry::Ptr_t entry = wxCodeCompletionBoxEntry::New(name /* + sig*/, imgId);
            entry->SetComment(doc);
            entries.push_back(entry);

        } else {
            imgId = 17; // keyword
            wxCodeCompletionBoxEntry::Ptr_t entry = wxCodeCompletionBoxEntry::New(name, imgId);
            entries.push_back(entry);
        }
    }
}
示例#5
0
//
// assert that the "index" of all types that should be checked is initially
// set to OMEGA
//
void TypeDependenceChecker::PartialOrder()
{
    for (FileSymbol* file_symbol = (FileSymbol*) file_set.FirstElement();
         file_symbol;
         file_symbol = (FileSymbol*) file_set.NextElement())
    {
        for (unsigned j = 0; j < file_symbol -> types.Length(); j++)
        {
            TypeSymbol* type = file_symbol -> types[j];
            if (type -> incremental_index == OMEGA)
                ProcessType(type);
        }
    }

    for (unsigned k = 0; k < type_trash_bin.Length(); k++)
    {
        TypeSymbol* type = type_trash_bin[k];
        if (type -> incremental_index == OMEGA)
            ProcessType(type);
    }
}
示例#6
0
文件: ANSI.c 项目: aliking/ansicon
// Inject code into the target process to load our DLL.
void Inject( LPPROCESS_INFORMATION pinfo, LPPROCESS_INFORMATION lpi,
	     DWORD dwCreationFlags )
{
  int type = ProcessType( pinfo );
  if (type != 0)
  {
    WCHAR dll[MAX_PATH];
#ifdef _WIN64
    DWORD len = GetModuleFileName( GetModuleHandleA( "ANSI64.dll" ),
				   dll, lenof(dll) );
    if (type == 32)
    {
      dll[len-6] = '3';
      dll[len-5] = '2';
      InjectDLL32( pinfo, dll );
    }
    else
    {
      InjectDLL64( pinfo, dll );
    }
#else
    GetModuleFileName( GetModuleHandleA( "ANSI32.dll" ), dll, lenof(dll) );
    InjectDLL32( pinfo, dll );
#endif
  }

  if (!(dwCreationFlags & CREATE_SUSPENDED))
    ResumeThread( pinfo->hThread );

  if (lpi)
  {
    memcpy( lpi, pinfo, sizeof(PROCESS_INFORMATION) );
  }
  else
  {
    CloseHandle( pinfo->hProcess );
    CloseHandle( pinfo->hThread );
  }
}
示例#7
0
void TypeDependenceChecker::ProcessType(TypeSymbol* type)
{
    stack.Push(type);
    int indx = stack.Size();
    type -> incremental_index = indx;

    // if dependents is reflexive make it non-reflexive - saves time !!!
    type -> dependents -> RemoveElement(type);
    type -> dependents_closure = new SymbolSet;
    // compute reflexive transitive closure
    type -> dependents_closure -> AddElement(type);
    TypeSymbol* dependent;
    for (dependent = (TypeSymbol*) type -> dependents -> FirstElement();
         dependent;
         dependent = (TypeSymbol*) type -> dependents -> NextElement())
    {
        if (dependent -> incremental_index == OMEGA)
             ProcessType(dependent);
        type -> incremental_index = Min(type -> incremental_index,
                                        dependent -> incremental_index);
        type -> dependents_closure ->
            Union(*(dependent -> dependents_closure));
    }

    if (type -> incremental_index == indx)
    {
        TypeSymbol* scc_dependent;
        do
        {
            scc_dependent = stack.Top();
            scc_dependent -> incremental_index = CYCLE_INFINITY;
            *(scc_dependent -> dependents_closure) =
                *(type -> dependents_closure);
            type_list.Next() = scc_dependent;
            stack.Pop();
        } while (scc_dependent != type);
    }
}
示例#8
0
 OvrAggregate(const ProcessType& pt = ProcessType()) : ovr_(0), refItem_(0), pt_(pt)
   { /* */ }
示例#9
0
  /** 
   * Run the unfolding and correction task. 
   *
   * The @a measuredFile is assumed to have the structure 
   *
   * @verbatim
   *     /- ForwardMultSums         (TCollection)
   *          |- [type]             (TCollection)
   *          |    |- [bin]         (TCollection) 
   *          |    |    `- rawDist  (TH1)
   *          |    |- [bin]
   *          |    ...
   *          |- [type]
   *          ...
   * @endverbatim 
   * 
   * and @a corrFile is assumed to have the structure 
   *
   * @verbatim
   *     /- ForwardMultResults            (TCollection)
   *          |- [type]                   (TCollection)
   *          |    |- [bin]               (TCollection) 
   *          |    |    |- truth          (TH1)
   *          |    |    |- truthAccepted  (TH1)
   *          |    |    |- triggerVertex  (TH1)
   *          |    |    `- response       (TH2)
   *          |    |- [bin]
   *          |    ...
   *          |- [type]
   *          ...
   * @endverbatim 
   *
   * where @c [type] is one of <i>symmetric</i>, <i>positive</i>,
   * <i>negative</i>, or <i>other</i>, and [bin] is the @f$ \eta@f$
   * bin named like
   *
   * @verbatim
   *   [bin]          := [eta_spec] _ [eta_spec]
   *   [eta_spec]     := [sign_char] [integer_part] d [decimal_part]
   *   [sign_part]    := p          positive eta 
   *                  |  m          negative eta 
   *   [integer_part] := [number]
   *   [decimal_part] := [number] [number]
   *   [number]       := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 
   * @endverbatim
   *
   * That is, the bin @f$ -3\le\eta\ge3@f$ is labeled
   * <b>m3d00_p3d00</b>, @f$ 0\le\eta\ge2.5@f$ is <b>p0d00_p2d50</b> 
   *
   * @a measuredFile and @a corrFile can point to the same file.  If
   * @a corrFile is not specified, it is assumed that @a measuredFile
   * has the expected @a corrFile @e in @e addition to the
   * expected content of that file.
   * 
   * @param measuredFile Name of file containing measured data
   * @param corrFile     Name of file containing correction data
   * @param method       Unfolding method to use 
   * @param regParam     Regularization parameter 
   */  
  void Run(const TString& measuredFile, const TString& corrFile,
	   const TString& method="Bayes", Double_t regParam=4)
  {
    // Get the input collections 
    if (measuredFile.IsNull()) {
      Error("Run", "No measurements given");
      return;
    }
    TCollection* mTop = GetTop(measuredFile, false);
    TCollection* cTop = GetTop(corrFile.IsNull() ? measuredFile : corrFile, 
			       true);
    if (!mTop || !cTop) return;

    // Get some info from the input collection 
    UShort_t sys;
    UShort_t sNN; 
    ULong_t  trig; 
    Double_t minZ; 
    Double_t maxZ;
    GetParameter(mTop, "sys",     sys);	  
    GetParameter(mTop, "sNN",     sNN);	  
    GetParameter(mTop, "trigger", trig);
    GetParameter(mTop, "minIpZ",  minZ); 
    GetParameter(mTop, "maxIpZ",  maxZ); 
    if (sys == 0 || sNN == 0) 
      Warning("Run", "System (%d) and/or collision energy (%d) unknown", 
	      sys, sNN);
    
    // Open the output file 
    TFile* out = TFile::Open("forward_unfolded.root", "RECREATE");
    if (!out) { 
      Error("Run", "Failed to open output file");
      return;
    }

    // Decode method option and store in file 
    TString meth(method);
    UInt_t  mId = MethodId(meth);
    if (mId == 0xDeadBeef) return;

    // Store information 
    SaveInformation(out,meth,mId,regParam,sys,sNN,trig,minZ,maxZ,
		    corrFile.IsNull());

    // Load other data 
    TString savPath(gROOT->GetMacroPath());
    gROOT->SetMacroPath(Form("%s:$(ALICE_PHYSICS)/PWGLF/FORWARD/analysis2/scripts",
                             gROOT->GetMacroPath()));
    // Always recompile 
    if (!gROOT->GetClass("OtherPNch"))
      gROOT->LoadMacro("OtherPNchData.C++");
    gROOT->SetMacroPath(savPath);

    // Loop over the input 
    const char*  inputs[] = { "symmetric", "positive", "negative", 0 };
    const char** pinput   = inputs;
    while (*pinput) { 
      TCollection* mInput = GetCollection(mTop, *pinput, false);
      TCollection* cInput = GetCollection(cTop, *pinput, false);
      if (mInput && cInput)
	ProcessType(mInput, cInput, mId, regParam, out,
		    sys, sNN);
      pinput++;
    }      

    out->Write();
    // out->ls();
    out->Close();

    SaveSummarize();
  }