| OLD | NEW |
| (Empty) |
| 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 #include "src/v8.h" | |
| 6 | |
| 7 #include "test/cctest/expression-type-collector.h" | |
| 8 | |
| 9 #include "src/ast/ast-type-bounds.h" | |
| 10 #include "src/ast/ast.h" | |
| 11 #include "src/ast/scopes.h" | |
| 12 #include "src/codegen.h" | |
| 13 | |
| 14 namespace v8 { | |
| 15 namespace internal { | |
| 16 namespace { | |
| 17 | |
| 18 struct { | |
| 19 AstNode::NodeType type; | |
| 20 const char* name; | |
| 21 } NodeTypeNameList[] = { | |
| 22 #define DECLARE_VISIT(type) \ | |
| 23 { AstNode::k##type, #type } \ | |
| 24 , | |
| 25 AST_NODE_LIST(DECLARE_VISIT) | |
| 26 #undef DECLARE_VISIT | |
| 27 }; | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 31 ExpressionTypeCollector::ExpressionTypeCollector( | |
| 32 Isolate* isolate, FunctionLiteral* root, const AstTypeBounds* bounds, | |
| 33 ZoneVector<ExpressionTypeEntry>* dst) | |
| 34 : AstExpressionVisitor(isolate, root), bounds_(bounds), result_(dst) {} | |
| 35 | |
| 36 void ExpressionTypeCollector::Run() { | |
| 37 result_->clear(); | |
| 38 AstExpressionVisitor::Run(); | |
| 39 } | |
| 40 | |
| 41 | |
| 42 void ExpressionTypeCollector::VisitExpression(Expression* expression) { | |
| 43 ExpressionTypeEntry e; | |
| 44 e.depth = depth(); | |
| 45 VariableProxy* proxy = expression->AsVariableProxy(); | |
| 46 if (proxy) { | |
| 47 e.name = proxy->raw_name(); | |
| 48 } | |
| 49 e.bounds = bounds_->get(expression); | |
| 50 AstNode::NodeType type = expression->node_type(); | |
| 51 e.kind = "unknown"; | |
| 52 for (size_t i = 0; i < arraysize(NodeTypeNameList); ++i) { | |
| 53 if (NodeTypeNameList[i].type == type) { | |
| 54 e.kind = NodeTypeNameList[i].name; | |
| 55 break; | |
| 56 } | |
| 57 } | |
| 58 result_->push_back(e); | |
| 59 } | |
| 60 | |
| 61 } // namespace internal | |
| 62 } // namespace v8 | |
| OLD | NEW |