Пример #1
0
std::pair< TokIdNode *, int > TokIdNode::Resolve(
    TokIdNode const *node,
    std::deque< TokId >::const_iterator arr,
    int len,
    TokIdNode const *hard_context,
    TokIdNode const *soft_context,
    TokIdNode const *subroot)
{
    return Resolve(node, arr, len, Matcher(), Matcher(), hard_context, soft_context, subroot);
}
Пример #2
0
nsIPrincipal*
DocInfo::Principal() const
{
  if (mPrincipal.isNothing()) {
    struct Matcher
    {
      explicit Matcher(const DocInfo& aThis) : mThis(aThis) {}
      const DocInfo& mThis;

      nsIPrincipal* match(Window aWin)
      {
        nsCOMPtr<nsIDocument> doc = aWin->GetDoc();
        return doc->NodePrincipal();
      }
      nsIPrincipal* match(LoadInfo aLoadInfo)
      {
        if (!(mThis.URL().InheritsPrincipal() || aLoadInfo->GetForceInheritPrincipal())) {
          return nullptr;
        }
        if (auto principal = aLoadInfo->PrincipalToInherit()) {
          return principal;
        }
        return aLoadInfo->TriggeringPrincipal();
      }
    };
    mPrincipal.emplace(mObj.match(Matcher(*this)));
  }
  return mPrincipal.ref();
}
bool FP4DataCache::LoadFromLog(const FString& UnrealSyncListLog)
{
	const FRegexPattern Pattern(TEXT("Label ([^ ]+) (\\d{4})/(\\d{2})/(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})")); // '.+\\n

	FRegexMatcher Matcher(Pattern, UnrealSyncListLog);

	while (Matcher.FindNext())
	{
		Labels.Add(FP4Label(
			Matcher.GetCaptureGroup(1),
			FDateTime(
				FCString::Atoi(*Matcher.GetCaptureGroup(2)),
				FCString::Atoi(*Matcher.GetCaptureGroup(3)),
				FCString::Atoi(*Matcher.GetCaptureGroup(4)),
				FCString::Atoi(*Matcher.GetCaptureGroup(5)),
				FCString::Atoi(*Matcher.GetCaptureGroup(6)),
				FCString::Atoi(*Matcher.GetCaptureGroup(7))
			)));
	}

	Labels.Sort(
		[](const FP4Label& LabelA, const FP4Label& LabelB)
		{
			return LabelA.GetDate() > LabelB.GetDate();
		});

	return true;
}
Пример #4
0
int main()
{

	char *a="{[()]}";
	Stack S=CreateStack();
	Matcher(a,S);
	return 0;
}
Пример #5
0
void Tok::Resolve(Matcher const &hard_matcher,
		  TokIdNode const *hard_context,
		  TokIdNode const *soft_context,
		  TokIdNode const *subroot)
{
    Resolve(-1, hard_matcher, Matcher(Matcher::chain_and, soft_matcher, hard_matcher),
             hard_context, soft_context, subroot);
}
Пример #6
0
std::vector< std::pair< TokIdNode *, int > > TokIdNode::AmbigResolve(
    TokIdNode const *node,
    std::deque< TokId >::const_iterator arr,
    int len,
    TokIdNode const *context,
    TokIdNode const *subroot)
{
    return AmbigResolve(node, arr, len, Matcher(), context, subroot);
}
Пример #7
0
bool
DocInfo::ShouldMatchActiveTabPermission() const
{
  struct Matcher
  {
    bool match(Window aWin) { return WindowShouldMatchActiveTab(aWin); }
    bool match(LoadInfo aLoadInfo) { return false; }
  };
  return mObj.match(Matcher());
}
Пример #8
0
bool
DocInfo::IsTopLevel() const
{
  if (mIsTopLevel.isNothing()) {
    struct Matcher
    {
      bool match(Window aWin) { return aWin->IsTopLevelWindow(); }
      bool match(LoadInfo aLoadInfo) { return aLoadInfo->GetIsTopLevelLoad(); }
    };
    mIsTopLevel.emplace(mObj.match(Matcher()));
  }
  return mIsTopLevel.ref();
}
Пример #9
0
uint64_t
DocInfo::FrameID() const
{
  if (mFrameID.isNothing()) {
    if (IsTopLevel()) {
      mFrameID.emplace(0);
    } else {
      struct Matcher
      {
        uint64_t match(Window aWin) { return aWin->WindowID(); }
        uint64_t match(LoadInfo aLoadInfo) { return aLoadInfo->GetOuterWindowID(); }
      };
      mFrameID.emplace(mObj.match(Matcher()));
    }
  }
  return mFrameID.ref();
}
Пример #10
0
TEST(TestProperty, threadSafeGetSet)
{
  static const int TARGET_COUNT = 42;
  qi::Promise<bool> isRunning;
  qi::Future<bool> running = isRunning.future();
  qi::Property<int> counter;
  counter.set(0);

  counter.connect(Matcher(TARGET_COUNT, isRunning));

  for (int i = 0; i < TARGET_COUNT; ++i)
  {
    qi::async(Incrementer(counter));
  }

  EXPECT_TRUE(running.value());
  EXPECT_EQ(TARGET_COUNT, counter.get());
}
Пример #11
0
void FileExtManager::Init()
{
    wxCriticalSectionLocker locker(m_CS);

    // per thread initialization
    static bool init_done(false);
    if(!init_done) {
        init_done = true;
        m_map[wxT("cc")] = TypeSourceCpp;
        m_map[wxT("cpp")] = TypeSourceCpp;
        m_map[wxT("cxx")] = TypeSourceCpp;
        m_map[wxT("c++")] = TypeSourceCpp;
        m_map[wxT("as")] = TypeSourceCpp;  // AngelScript files are handled as C++ source files in CodeLite
        m_map[wxT("ino")] = TypeSourceCpp; // Arduino sketches
        m_map[wxT("c")] = TypeSourceC;

        m_map[wxT("h")] = TypeHeader;
        m_map[wxT("hpp")] = TypeHeader;
        m_map[wxT("hxx")] = TypeHeader;
        m_map[wxT("hh")] = TypeHeader;
        m_map[wxT("h++")] = TypeHeader;
        m_map[wxT("inl")] = TypeHeader;

        m_map[wxT("rc")] = TypeResource;
        m_map[wxT("res")] = TypeResource;

        m_map[wxT("y")] = TypeYacc;
        m_map[wxT("l")] = TypeLex;
        m_map[wxT("ui")] = TypeQtForm;
        m_map[wxT("qrc")] = TypeQtResource;
        m_map[wxT("qml")] = TypeJS;

        m_map[wxT("project")] = TypeProject;
        m_map[wxT("workspace")] = TypeWorkspace;
        m_map[wxT("fbp")] = TypeFormbuilder;
        m_map[wxT("cdp")] = TypeCodedesigner;
        m_map[wxT("erd")] = TypeErd;

        m_map[wxT("php")] = TypePhp;
        m_map[wxT("php5")] = TypePhp;
        m_map[wxT("inc")] = TypePhp;
        m_map[wxT("phtml")] = TypePhp;
        m_map[wxT("ctp")] = TypePhp;

        m_map[wxT("xml")] = TypeXml;
        m_map[wxT("xrc")] = TypeXRC;
        m_map[wxT("css")] = TypeCSS;
        m_map[wxT("less")] = TypeCSS;
        m_map[wxT("sass")] = TypeCSS;
        m_map[wxT("js")] = TypeJS;
        m_map[wxT("javascript")] = TypeJS;
        m_map[wxT("py")] = TypePython;

        // Java file
        m_map[wxT("java")] = TypeJava;

        m_map[wxT("exe")] = TypeExe;
        m_map[wxT("html")] = TypeHtml;
        m_map[wxT("htm")] = TypeHtml;

        m_map[wxT("tar")] = TypeArchive;
        m_map[wxT("a")] = TypeArchive;
        m_map[wxT("lib")] = TypeArchive;
        m_map[wxT("zip")] = TypeArchive;
        m_map[wxT("rar")] = TypeArchive;
        m_map[wxT("targz")] = TypeArchive;

        m_map[wxT("dll")] = TypeDll;
        m_map[wxT("so")] = TypeDll;
        m_map[wxT("dylib")] = TypeDll;

        m_map[wxT("bmp")] = TypeBmp;
        m_map[wxT("jpeg")] = TypeBmp;
        m_map[wxT("jpg")] = TypeBmp;
        m_map[wxT("png")] = TypeBmp;
        m_map[wxT("ico")] = TypeBmp;
        m_map[wxT("xpm")] = TypeBmp;
        m_map[wxT("svg")] = TypeSvg;

        m_map[wxT("mk")] = TypeMakefile;

        m_map[wxT("log")] = TypeText;
        m_map[wxT("txt")] = TypeText;
        m_map[wxT("ini")] = TypeText;

        m_map[wxT("script")] = TypeScript;
        m_map[wxT("sh")] = TypeScript;
        m_map[wxT("bat")] = TypeScript;
        m_map[wxT("bash")] = TypeScript;

        m_map[wxT("wxcp")] = TypeWxCrafter;
        m_map[wxT("xrc")] = TypeXRC;

        m_map[wxT("sql")] = TypeSQL;
        m_map[wxT("sqlite")] = TypeSQL;
        m_map[wxT("phpwsp")] = TypeWorkspacePHP;
        m_map[wxT("phptags")] = TypeWorkspacePHPTags;

        m_map["pro"] = TypeQMake;
        m_map["pri"] = TypeQMake;
        m_map["cmake"] = TypeCMake;
        m_map["s"] = TypeAsm;
        m_map["yaml"] = TypeYAML;
        m_map["yml"] = TypeYAML;
        m_map["db"] = TypeDatabase;
        m_map["tags"] = TypeDatabase;

        // Initialize regexes:
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/bin/bash", TypeScript));
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/bin/sh", TypeScript));
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/usr/bin/sh", TypeScript));
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/usr/bin/bash", TypeScript));
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/bin/python", TypePython));
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/usr/bin/python", TypePython));
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/bin/node", TypeJS));
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/usr/bin/node", TypeJS));
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/bin/nodejs", TypeJS));
        m_matchers.push_back(Matcher("#[ \t]*![ \t]*/usr/bin/nodejs", TypeJS));
        m_matchers.push_back(Matcher("<?xml", TypeXml, false));
        m_matchers.push_back(Matcher("<?php", TypePhp, false));
        m_matchers.push_back(Matcher("#!/usr/bin/env node", TypeJS, false));
        m_matchers.push_back(Matcher("#!/usr/bin/env nodejs", TypeJS, false));
        m_matchers.push_back(Matcher("SQLite format 3", TypeDatabase, false));

        // STL sources places "-*- C++ -*-" at the top of their headers
        m_matchers.push_back(Matcher("-*- C++ -*-", TypeSourceCpp, false));

        // #ifndef WORD
        m_matchers.push_back(Matcher("#ifndef[ \t]+[a-zA-Z0-9_]+", TypeSourceCpp));

        // vim modlines
        m_matchers.push_back(Matcher("/\\* \\-\\*\\- Mode:[ \t]+c\\+\\+", TypeSourceCpp));
        m_matchers.push_back(Matcher("# \\-\\*\\- Mode:[ \t]+python", TypePython));

        // #include <
        m_matchers.push_back(Matcher("#include[ \t]+[\\<\"]", TypeSourceCpp));
    }
}
Пример #12
0
const LCDbTankMap * LCDbTankMaps::findCurrent( int pTankCID ) const
{
	return findMatch( Matcher( pTankCID ) );
}
void RepairManifestAndArchives(TSharedRef<FInternationalizationManifest> Manifest, TArray< TSharedRef<FInternationalizationArchive> > Archives)
{
	// Update source text if this manifest was saved before the escape sequence fixes.
	if (Manifest->GetFormatVersion() < FInternationalizationManifest::EFormatVersion::EscapeFixes)
	{
		TManifestEntryBySourceTextContainer::TConstIterator Iterator = Manifest->GetEntriesBySourceTextIterator();
		for(; Iterator; ++Iterator)
		{
			const FString& Source = Iterator.Key();
			const TSharedRef<FManifestEntry>& ManifestEntry = Iterator.Value();

			// Find double quotes and unescape them once.
			FLocItem UpdatedSource(ManifestEntry->Source);
			UpdatedSource.Text.ReplaceInline(TEXT("\\\""), TEXT("\""));

			TSharedRef<FManifestEntry> UpdatedManifestEntry = MakeShareable(new FManifestEntry(ManifestEntry->Namespace, UpdatedSource));
			UpdatedManifestEntry->Contexts = ManifestEntry->Contexts;

			Manifest->UpdateEntry(ManifestEntry, UpdatedManifestEntry);
		}
	}

	for (const TSharedRef<FInternationalizationArchive>& Archive : Archives)
	{
		// Update source text if this archive was saved before the escape sequence fixes.
		if (Archive->GetFormatVersion() < FInternationalizationArchive::EFormatVersion::EscapeFixes)
		{
			TArchiveEntryContainer::TConstIterator Iterator = Archive->GetEntryIterator();

			for (; Iterator; ++Iterator)
			{
				const FString& Source = Iterator.Key();
				const TSharedRef<FArchiveEntry>& ArchiveEntry = Iterator.Value();

				// Find double quotes and unescape them once.
				FLocItem UpdatedSource(ArchiveEntry->Source);
				UpdatedSource.Text.ReplaceInline(TEXT("\\\""), TEXT("\""));

				// Find double quotes and unescape them once.
				FLocItem UpdatedTranslation(ArchiveEntry->Translation);
				UpdatedTranslation.Text.ReplaceInline(TEXT("\\\""), TEXT("\""));

				TSharedRef<FArchiveEntry> UpdatedArchiveEntry = MakeShareable(new FArchiveEntry(ArchiveEntry->Namespace, UpdatedSource, UpdatedTranslation, ArchiveEntry->KeyMetadataObj, ArchiveEntry->bIsOptional));

				Archive->UpdateEntry(ArchiveEntry, UpdatedArchiveEntry);
			}
		}
	}

	const FRegexPattern Pattern(TEXT(".* - line \\d+"));

	TManifestEntryBySourceTextContainer::TConstIterator Iterator = Manifest->GetEntriesBySourceTextIterator();
	for(; Iterator; ++Iterator)
	{
		const FString& Source = Iterator.Key();
		const TSharedRef<FManifestEntry>& ManifestEntry = Iterator.Value();

		// Identify if this entry comes from source text only.
		bool AreAllContextsFromSource = ManifestEntry->Contexts.Num() > 0;
		for (const FContext& Context : ManifestEntry->Contexts)
		{
			FRegexMatcher Matcher(Pattern, Context.SourceLocation);
			AreAllContextsFromSource = Matcher.FindNext();

			if(!AreAllContextsFromSource)
			{
				break;
			}
		}

		// No updates needed for this entry if it isn't all from source.
		if(!AreAllContextsFromSource)
		{
			continue;
		}

		for (const TSharedRef<FInternationalizationArchive>& Archive : Archives)
		{
			// Update source text if this manifest was saved before the escape sequence fixes.
			if (Archive->GetFormatVersion() < FInternationalizationArchive::EFormatVersion::EscapeFixes)
			{
				const TSharedPtr<FArchiveEntry> ArchiveEntry = Archive->FindEntryBySource(ManifestEntry->Namespace, ManifestEntry->Source, /*KeyMetadataObj*/ nullptr);
				if (!ArchiveEntry.IsValid())
				{
					continue;
				}

				// Replace escape sequences with their associated character, once.
				FLocItem UpdatedSource(ArchiveEntry->Source);
				UpdatedSource.Text = UpdatedSource.Text.ReplaceEscapedCharWithChar();

				// Replace escape sequences with their associated character, once.
				FLocItem UpdatedTranslation(ArchiveEntry->Translation);
				UpdatedTranslation.Text = UpdatedTranslation.Text.ReplaceEscapedCharWithChar();

				TSharedRef<FArchiveEntry> UpdatedArchiveEntry = MakeShareable(new FArchiveEntry(ArchiveEntry->Namespace, UpdatedSource, UpdatedTranslation, ArchiveEntry->KeyMetadataObj, ArchiveEntry->bIsOptional));

				Archive->UpdateEntry(ArchiveEntry.ToSharedRef(), UpdatedArchiveEntry);
			}
		}

		// Update source text if this manifest was saved before the escape sequence fixes.
		if (Manifest->GetFormatVersion() < FInternationalizationManifest::EFormatVersion::EscapeFixes)
		{
			// Replace escape sequences with their associated character, once.
			FLocItem UpdatedSource(ManifestEntry->Source);
			UpdatedSource.Text = UpdatedSource.Text.ReplaceEscapedCharWithChar();

			TSharedRef<FManifestEntry> UpdatedManifestEntry = MakeShareable(new FManifestEntry(ManifestEntry->Namespace, UpdatedSource));
			UpdatedManifestEntry->Contexts = ManifestEntry->Contexts;

			Manifest->UpdateEntry(ManifestEntry, UpdatedManifestEntry);
		}
	}

	Manifest->SetFormatVersion(FInternationalizationManifest::EFormatVersion::Latest);
	for (const TSharedRef<FInternationalizationArchive>& Archive : Archives)
	{
		Archive->SetFormatVersion(FInternationalizationArchive::EFormatVersion::Latest);
	}
}
Пример #14
0
void perform_collective_detection(GOAL_Schedule* sched) {
	
	schedule_t* schedules = (schedule_t*) malloc(G_GOAL_GroupSize * sizeof(schedule_t)); // pointers to local schedules
	int* sched_sizes = (int*) malloc(G_GOAL_GroupSize * sizeof(int)); // array of schedule sizes
	MPI_Gather(&sched->size, 1, MPI_INT, sched_sizes, 1, MPI_INT, 0, G_GOAL_WorldComm);
	int sum = 0; // for calculating displacements
	int* displs = (int*) malloc(G_GOAL_GroupSize * sizeof(int));
	for (int i=0; i<G_GOAL_GroupSize; i++) {
		displs[i]=sum;
		sum += sched_sizes[i];
	}
	char* schedules_real = (char*) malloc(sum);
	int mem_allocated = sum;
	for (int i=0; i<G_GOAL_GroupSize; i++) schedules[i] = (schedule_t) (((char*) schedules_real) + displs[i]);
	MPI_Gatherv(sched->active, sched->size, MPI_BYTE, schedules_real, sched_sizes, displs, MPI_BYTE, 0, G_GOAL_WorldComm);
	free(sched->active);

#ifdef HAVE_PGT
	PGT_Rec(3); //record gather id:3
#endif

	int newsched_size = 0;

	if (G_GOAL_MyRank == 0) {

		SetOfGraphs LocalGraphs;
		unpack_binary_schedules(G_GOAL_GroupSize, schedules, sched_sizes, &LocalGraphs); // parses the binary schedules and fills LocalGraphs
#ifdef HAVE_PGT
		PGT_Rec(4); //record unpack id:4 
#endif
		HtorSets* hs = Matcher(&LocalGraphs);
#ifdef HAVE_PGT
		PGT_Rec(5); //record matching id:5 
#endif
		hs->printGlobalGraphAsDot();
		std::vector<tuple*>* tuples = DataFlowAnalysis(hs);
		delete hs;
#ifdef HAVE_PGT
		PGT_Rec(6); //record data flow analysis id:6
#endif
	//	printf("old tuples\n");
	//	print_tuples(tuples);
		std::vector<Collective*> colls;
		tuples = DetectCollectives(G_GOAL_GroupSize, tuples, &colls);
#ifdef HAVE_PGT
		PGT_Rec(7); //record collective detection id:7
#endif
	//	printf("new tuples\n");
	//	print_tuples(tuples);
		
		// create new graphs based on the collectives that have been found
		GOAL_Graph* new_graphs = (GOAL_Graph*) malloc(sizeof(GOAL_Graph) * G_GOAL_GroupSize);
		for (int rank=0; rank < G_GOAL_GroupSize; rank++) new_graphs[rank] = _GOAL_Create_graph_internal();
		// add all detected collectives to the new graphs (as predefined operations which make MPI calls)
		for (int c=0; c<colls.size(); c++) generate_goalop_for_collective(colls[c], new_graphs);
		// now add send-recv pairs for each remaining tuple (a remaining tuple is a tuple not replaced by a coll)
		for (std::vector<tuple*>::iterator ri = tuples->begin(); ri!=tuples->end(); ++ri) {
			tuple *t = *ri;
			GOAL_Send(new_graphs[t->sowner], (void*) t->sstart, t->ssize, t->owner); // TODO we need tags here!
			GOAL_Recv(new_graphs[t->owner], (void*) t->start, t->size, t->sowner); // TODO we need tags here!
			free(t);
		}
		delete tuples;

#ifdef HAVE_PGT
		PGT_Rec(8); //record building of new graphs id:8
#endif

		int size_acc = 0;
		
		// compile the newly created graphs into binary schedules
		// set do_coll_detection to 0 to avaoid recursion!
		for (int rank=0; rank < G_GOAL_GroupSize; rank++) {
			displs[rank] = size_acc;
			new_graphs[rank]->do_coll_detection = 0;
			GOAL_Schedule nsched = GOAL_Compile_internal(new_graphs[rank]);
			GOAL_FreeGraph(new_graphs[rank]);
			if (mem_allocated == 0) {
				mem_allocated = nsched.size;
				schedules_real = (char*) malloc(mem_allocated);
			}
			while (mem_allocated < (size_acc + nsched.size)) {
				mem_allocated =  mem_allocated *= 2;
				schedules_real = (char*) realloc(schedules_real, mem_allocated);
			}
			memcpy(schedules_real + size_acc, nsched.active, nsched.size);
			sched_sizes[rank] = nsched.size;
			size_acc += sched_sizes[rank];
			GOAL_FreeSchedule(nsched);
		}
		free(new_graphs);

#ifdef HAVE_PGT
		PGT_Rec(9); //record compiling of new graphs id:9
#endif
	}

	MPI_Scatter(sched_sizes, 1, MPI_INT, &newsched_size, 1, MPI_INT, 0, G_GOAL_WorldComm);
	char* newsched = (char*) malloc(newsched_size);
	MPI_Scatterv(schedules_real, sched_sizes, displs, MPI_BYTE, newsched, newsched_size, MPI_BYTE, 0, G_GOAL_WorldComm);
	sched->active = newsched;
	sched->size = newsched_size;

	free(sched_sizes);
	free(schedules);
	free(schedules_real);
	free(displs);

#ifdef HAVE_PGT
	PGT_Rec(10); //record scatter of new graphs id:10
#endif
}