Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1 | // 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 | |
| 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 13 | class AstTypeBounds; |
| 14 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 15 | // 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 | |
| 19 | struct ExpressionTypeEntry { |
| 20 | int depth; |
| 21 | const char* kind; |
| 22 | const AstRawString* name; |
| 23 | Bounds bounds; |
| 24 | }; |
| 25 | |
| 26 | class ExpressionTypeCollector : public AstExpressionVisitor { |
| 27 | public: |
| 28 | ExpressionTypeCollector(Isolate* isolate, FunctionLiteral* root, |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 29 | const AstTypeBounds* bounds, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 30 | ZoneVector<ExpressionTypeEntry>* dst); |
| 31 | void Run(); |
| 32 | |
| 33 | protected: |
| 34 | void VisitExpression(Expression* expression); |
| 35 | |
| 36 | private: |
Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 37 | const AstTypeBounds* bounds_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 38 | ZoneVector<ExpressionTypeEntry>* result_; |
| 39 | }; |
| 40 | } // namespace internal |
| 41 | } // namespace v8 |
| 42 | |
| 43 | #endif // V8_EXPRESSION_TYPE_COLLECTOR_H_ |