1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "src/compiler/source-position.h"
6 #include "src/compiler/graph.h"
7 #include "src/compiler/node-aux-data-inl.h"
13 class SourcePositionTable::Decorator : public GraphDecorator {
15 explicit Decorator(SourcePositionTable* source_positions)
16 : source_positions_(source_positions) {}
18 virtual void Decorate(Node* node) {
19 DCHECK(!source_positions_->current_position_.IsInvalid());
20 source_positions_->table_.Set(node, source_positions_->current_position_);
24 SourcePositionTable* source_positions_;
28 SourcePositionTable::SourcePositionTable(Graph* graph)
31 current_position_(SourcePosition::Invalid()),
32 table_(graph->zone()) {}
35 void SourcePositionTable::AddDecorator() {
36 DCHECK(decorator_ == NULL);
37 decorator_ = new (graph_->zone()) Decorator(this);
38 graph_->AddDecorator(decorator_);
42 void SourcePositionTable::RemoveDecorator() {
43 DCHECK(decorator_ != NULL);
44 graph_->RemoveDecorator(decorator_);
49 SourcePosition SourcePositionTable::GetSourcePosition(Node* node) {
50 return table_.Get(node);
53 } // namespace compiler
54 } // namespace internal