OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/expression-type-collector.h" | 7 #include "test/cctest/expression-type-collector.h" |
8 | 8 |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 { AstNode::k##type, #type } \ | 22 { AstNode::k##type, #type } \ |
23 , | 23 , |
24 AST_NODE_LIST(DECLARE_VISIT) | 24 AST_NODE_LIST(DECLARE_VISIT) |
25 #undef DECLARE_VISIT | 25 #undef DECLARE_VISIT |
26 }; | 26 }; |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 | 30 |
31 ExpressionTypeCollector::ExpressionTypeCollector( | 31 ExpressionTypeCollector::ExpressionTypeCollector( |
32 Isolate* isolate, Zone* zone, FunctionLiteral* root, | 32 Isolate* isolate, FunctionLiteral* root, |
33 ZoneVector<ExpressionTypeEntry>* dst) | 33 ZoneVector<ExpressionTypeEntry>* dst) |
34 : AstExpressionVisitor(isolate, zone, root), result_(dst) {} | 34 : AstExpressionVisitor(isolate, root), result_(dst) {} |
35 | 35 |
36 | 36 |
37 void ExpressionTypeCollector::Run() { | 37 void ExpressionTypeCollector::Run() { |
38 result_->clear(); | 38 result_->clear(); |
39 AstExpressionVisitor::Run(); | 39 AstExpressionVisitor::Run(); |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 void ExpressionTypeCollector::VisitExpression(Expression* expression) { | 43 void ExpressionTypeCollector::VisitExpression(Expression* expression) { |
44 ExpressionTypeEntry e; | 44 ExpressionTypeEntry e; |
45 e.depth = depth(); | 45 e.depth = depth(); |
46 VariableProxy* proxy = expression->AsVariableProxy(); | 46 VariableProxy* proxy = expression->AsVariableProxy(); |
47 if (proxy) { | 47 if (proxy) { |
48 e.name = proxy->raw_name(); | 48 e.name = proxy->raw_name(); |
49 } | 49 } |
50 e.bounds = expression->bounds(); | 50 e.bounds = expression->bounds(); |
51 AstNode::NodeType type = expression->node_type(); | 51 AstNode::NodeType type = expression->node_type(); |
52 e.kind = "unknown"; | 52 e.kind = "unknown"; |
53 for (size_t i = 0; i < arraysize(NodeTypeNameList); ++i) { | 53 for (size_t i = 0; i < arraysize(NodeTypeNameList); ++i) { |
54 if (NodeTypeNameList[i].type == type) { | 54 if (NodeTypeNameList[i].type == type) { |
55 e.kind = NodeTypeNameList[i].name; | 55 e.kind = NodeTypeNameList[i].name; |
56 break; | 56 break; |
57 } | 57 } |
58 } | 58 } |
59 result_->push_back(e); | 59 result_->push_back(e); |
60 } | 60 } |
61 | 61 |
62 } // namespace internal | 62 } // namespace internal |
63 } // namespace v8 | 63 } // namespace v8 |
OLD | NEW |