Index: src/compiler/source-position.h |
diff --git a/src/compiler/source-position.h b/src/compiler/source-position.h |
index 81db1d2e3eff4f97d0f93e484b83d321b8115259..a1962766b399303f2c245fa1c42ab56f77bc1feb 100644 |
--- a/src/compiler/source-position.h |
+++ b/src/compiler/source-position.h |
@@ -41,30 +41,6 @@ inline bool operator!=(const SourcePosition& lhs, const SourcePosition& rhs) { |
class SourcePositionTable final { |
public: |
- class Scope final { |
- public: |
- Scope(SourcePositionTable* source_positions, SourcePosition position) |
- : source_positions_(source_positions), |
- prev_position_(source_positions->current_position_) { |
- Init(position); |
- } |
- Scope(SourcePositionTable* source_positions, Node* node) |
- : source_positions_(source_positions), |
- prev_position_(source_positions->current_position_) { |
- Init(source_positions_->GetSourcePosition(node)); |
- } |
- ~Scope() { source_positions_->current_position_ = prev_position_; } |
- |
- private: |
- void Init(SourcePosition position) { |
- if (position.IsKnown()) source_positions_->current_position_ = position; |
- } |
- |
- SourcePositionTable* const source_positions_; |
- SourcePosition const prev_position_; |
- DISALLOW_COPY_AND_ASSIGN(Scope); |
- }; |
- |
explicit SourcePositionTable(Graph* graph); |
~SourcePositionTable() { |
if (decorator_) RemoveDecorator(); |
@@ -75,10 +51,15 @@ class SourcePositionTable final { |
SourcePosition GetSourcePosition(Node* node) const; |
+#ifdef DEBUG |
titzer
2016/04/18 11:03:51
I'm not sure why this would only be useful in debu
Clemens Hammacher
2016/04/18 11:18:09
Right now it's only used in debug mode, but sure,
|
+ Graph* GetGraph() const { return graph_; } |
+#endif |
+ |
void Print(std::ostream& os) const; |
private: |
class Decorator; |
+ friend class SourcePositionScope; |
Graph* const graph_; |
Decorator* decorator_; |
@@ -88,6 +69,38 @@ class SourcePositionTable final { |
DISALLOW_COPY_AND_ASSIGN(SourcePositionTable); |
}; |
+class SourcePositionScope final { |
titzer
2016/04/18 11:03:51
I think I prefer leaving this as an inner class in
Clemens Hammacher
2016/04/18 11:18:09
If we don't need to forward-reference it from comp
|
+ public: |
+ SourcePositionScope(SourcePositionTable* source_positions, |
+ SourcePosition position = SourcePosition::Unknown()) |
+ : source_positions_(source_positions), |
+ prev_position_(source_positions->current_position_) { |
+ Init(position); |
+ } |
+ SourcePositionScope(SourcePositionTable* source_positions, Node* node) |
+ : source_positions_(source_positions), |
+ prev_position_(source_positions->current_position_) { |
+ Init(source_positions_->GetSourcePosition(node)); |
+ } |
+ ~SourcePositionScope() { |
+ source_positions_->current_position_ = prev_position_; |
+ } |
+ |
+ void SetCurrentPosition(SourcePosition position) { |
+ DCHECK(position.IsKnown()); |
+ source_positions_->current_position_ = position; |
+ } |
+ |
+ private: |
+ void Init(SourcePosition position) { |
+ if (position.IsKnown()) SetCurrentPosition(position); |
+ } |
+ |
+ SourcePositionTable* const source_positions_; |
+ SourcePosition const prev_position_; |
+ DISALLOW_COPY_AND_ASSIGN(SourcePositionScope); |
+}; |
+ |
} // namespace compiler |
} // namespace internal |
} // namespace v8 |