From 6954c8936f52dcf7710e4b72b2e090b79bf38d1c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 1 Aug 2015 19:41:26 +0200 Subject: cmState: Add a VariableScope snapshot type. Match the scopes currently used in cmMakefile for definitions. --- Source/cmMakefile.cxx | 14 ++++++++++++++ Source/cmState.cxx | 19 +++++++++++++++++++ Source/cmState.h | 6 +++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index aef016e..1d02cfa 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4464,6 +4464,17 @@ void cmMakefile::PushScope() { this->Internal->PushDefinitions(Internals::VariableScope); + std::string commandName; + long line = 0; + if (!this->ContextStack.empty()) + { + commandName = this->ContextStack.back()->Name; + line = this->ContextStack.back()->Line; + } + this->StateSnapshot = this->GetState()->CreateVariableScopeSnapshot( + this->StateSnapshot, + commandName, + line); this->PushLoopBlockBarrier(); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -4482,6 +4493,9 @@ void cmMakefile::PopScope() this->CheckForUnusedVariables(); this->Internal->PopDefinitions(); + this->StateSnapshot = + this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); } void cmMakefile::RaiseScope(const std::string& var, const char *varDef) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index c777514..9e09353 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -20,6 +20,7 @@ struct cmState::SnapshotDataType { + cmState::PositionType ScopeParent; cmState::PositionType DirectoryParent; cmLinkedTree::iterator Policies; cmLinkedTree::iterator PolicyRoot; @@ -736,6 +737,7 @@ cmState::Snapshot cmState::CreateBaseSnapshot() { PositionType pos = this->SnapshotData.Extend(this->SnapshotData.Root()); pos->DirectoryParent = this->SnapshotData.Root(); + pos->ScopeParent = this->SnapshotData.Root(); pos->SnapshotType = BaseType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root()); @@ -763,6 +765,7 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; + pos->ScopeParent = originSnapshot.Position; pos->SnapshotType = BuildsystemDirectoryType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend( @@ -787,6 +790,7 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, { PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, *originSnapshot.Position); + pos->ScopeParent = originSnapshot.Position; pos->EntryPointLine = entryPointLine; pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = FunctionCallType; @@ -835,6 +839,21 @@ cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, } cmState::Snapshot +cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->ScopeParent = originSnapshot.Position; + pos->EntryPointLine = entryPointLine; + pos->EntryPointCommand = entryPointCommand; + pos->SnapshotType = VariableScopeType; + + return cmState::Snapshot(this, pos); +} + +cmState::Snapshot cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, const std::string& entryPointCommand, long entryPointLine, diff --git a/Source/cmState.h b/Source/cmState.h index bc89cc8..4d87653 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -41,7 +41,8 @@ public: MacroCallType, CallStackType, InlineListFileType, - PolicyScopeType + PolicyScopeType, + VariableScopeType }; class Directory; @@ -155,6 +156,9 @@ public: std::string const& entryPointCommand, long entryPointLine, std::string const& fileName); + Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine); Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot, const std::string& entryPointCommand, long entryPointLine, -- cgit v0.12