v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
source-range-ast-visitor.h
Go to the documentation of this file.
1// Copyright 2018 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.
4
5#ifndef V8_AST_SOURCE_RANGE_AST_VISITOR_H_
6#define V8_AST_SOURCE_RANGE_AST_VISITOR_H_
7
8#include <unordered_set>
9
11
12namespace v8 {
13namespace internal {
14
15class SourceRangeMap;
16
17// Post-processes generated source ranges while the AST structure still exists.
18//
19// In particular, SourceRangeAstVisitor
20//
21// 1. deduplicates continuation source ranges, only keeping the outermost one.
22// See also: https://crbug.com/v8/8539.
23//
24// 2. removes the source range associated with the final statement in a block
25// or function body if the parent itself has a source range associated with it.
26// See also: https://crbug.com/v8/8381.
28 : public AstTraversalVisitor<SourceRangeAstVisitor> {
29 public:
30 SourceRangeAstVisitor(uintptr_t stack_limit, Expression* root,
31 SourceRangeMap* source_range_map);
32
33 private:
35
36 void VisitBlock(Block* stmt);
39 bool VisitNode(AstNode* node);
42
43 void MaybeRemoveContinuationRange(Statement* last_statement);
46
48 std::unordered_set<int> continuation_positions_;
49};
50
51} // namespace internal
52} // namespace v8
53
54#endif // V8_AST_SOURCE_RANGE_AST_VISITOR_H_
void VisitTryFinallyStatement(TryFinallyStatement *stmt)
std::unordered_set< int > continuation_positions_
void VisitSwitchStatement(SwitchStatement *stmt)
void MaybeRemoveLastContinuationRange(ZonePtrList< Statement > *stmts)
void VisitFunctionLiteral(FunctionLiteral *expr)
void VisitTryCatchStatement(TryCatchStatement *stmt)
SourceRangeAstVisitor(uintptr_t stack_limit, Expression *root, SourceRangeMap *source_range_map)
void MaybeRemoveContinuationRangeOfAsyncReturn(TryCatchStatement *stmt)
void MaybeRemoveContinuationRange(Statement *last_statement)