summaryrefslogtreecommitdiff
path: root/deps/v8/src/ast/ast-source-ranges.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/ast/ast-source-ranges.h')
-rw-r--r--deps/v8/src/ast/ast-source-ranges.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/deps/v8/src/ast/ast-source-ranges.h b/deps/v8/src/ast/ast-source-ranges.h
index a04e68fa2f..1b42a055dd 100644
--- a/deps/v8/src/ast/ast-source-ranges.h
+++ b/deps/v8/src/ast/ast-source-ranges.h
@@ -25,6 +25,18 @@ struct SourceRange {
int end = kNoSourcePosition) {
return that.IsEmpty() ? Empty() : SourceRange(that.end, end);
}
+
+ static constexpr int kFunctionLiteralSourcePosition = -2;
+ STATIC_ASSERT(kFunctionLiteralSourcePosition == kNoSourcePosition - 1);
+
+ // Source ranges associated with a function literal do not contain real
+ // source positions; instead, they are created with special marker values.
+ // These are later recognized and rewritten during processing in
+ // Coverage::Collect().
+ static SourceRange FunctionLiteralMarkerRange() {
+ return {kFunctionLiteralSourcePosition, kFunctionLiteralSourcePosition};
+ }
+
int32_t start, end;
};
@@ -35,6 +47,7 @@ struct SourceRange {
V(Block) \
V(CaseClause) \
V(Conditional) \
+ V(FunctionLiteral) \
V(IfStatement) \
V(IterationStatement) \
V(JumpStatement) \
@@ -155,6 +168,18 @@ class ConditionalSourceRanges final : public AstNodeSourceRanges {
SourceRange else_range_;
};
+class FunctionLiteralSourceRanges final : public AstNodeSourceRanges {
+ public:
+ SourceRange GetRange(SourceRangeKind kind) override {
+ DCHECK(HasRange(kind));
+ return SourceRange::FunctionLiteralMarkerRange();
+ }
+
+ bool HasRange(SourceRangeKind kind) override {
+ return kind == SourceRangeKind::kBody;
+ }
+};
+
class IfStatementSourceRanges final : public AstNodeSourceRanges {
public:
explicit IfStatementSourceRanges(const SourceRange& then_range,