blob: a52cfdacc8fcbcdedfc5c94af4466e6f71e1632e [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2015 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_EXPRESSION_TYPE_COLLECTOR_H_
6#define V8_EXPRESSION_TYPE_COLLECTOR_H_
7
8#include "src/ast/ast-expression-visitor.h"
9
10namespace v8 {
11namespace internal {
12
Ben Murdochc5610432016-08-08 18:44:38 +010013class AstTypeBounds;
14
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000015// A Visitor over an AST that collects a human readable string summarizing
16// structure and types. Used for testing of the typing information attached
17// to the expression nodes of an AST.
18
19struct ExpressionTypeEntry {
20 int depth;
21 const char* kind;
22 const AstRawString* name;
23 Bounds bounds;
24};
25
26class ExpressionTypeCollector : public AstExpressionVisitor {
27 public:
28 ExpressionTypeCollector(Isolate* isolate, FunctionLiteral* root,
Ben Murdochc5610432016-08-08 18:44:38 +010029 const AstTypeBounds* bounds,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000030 ZoneVector<ExpressionTypeEntry>* dst);
31 void Run();
32
33 protected:
34 void VisitExpression(Expression* expression);
35
36 private:
Ben Murdochc5610432016-08-08 18:44:38 +010037 const AstTypeBounds* bounds_;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000038 ZoneVector<ExpressionTypeEntry>* result_;
39};
40} // namespace internal
41} // namespace v8
42
43#endif // V8_EXPRESSION_TYPE_COLLECTOR_H_