Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Side by Side Diff: test/cctest/expression-type-collector.cc

Issue 1288773007: Adding visitors to regurgitate expression types or reset them. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.h"
10 #include "src/codegen.h"
11 #include "src/scopes.h"
12
13 namespace v8 {
14 namespace internal {
15 namespace {
16
17 struct {
18 AstNode::NodeType type;
19 const char* name;
20 } NodeTypeNameList[] = {
21 #define DECLARE_VISIT(type) \
22 { AstNode::k##type, #type } \
23 ,
24 AST_NODE_LIST(DECLARE_VISIT)
25 #undef DECLARE_VISIT
26 };
27 }
28
29
30 std::string ExpressionTypeCollector::Run(CompilationInfo* info) {
31 ExpressionTypeCollector* visitor =
32 new (info->zone()) ExpressionTypeCollector(info);
33 visitor->VisitAll();
34 return visitor->types_;
35 }
36
37
38 void ExpressionTypeCollector::VisitExpression(Expression* expression) {
titzer 2015/08/19 12:06:37 Collecting the types as a string is nice for debug
bradn 2015/08/20 04:01:40 Restructured to gather a list of expression type i
39 VariableProxy* proxy = expression->AsVariableProxy();
40 for (int i = 0; i < depth(); ++i) {
41 types_ += " ";
42 }
43 if (proxy) {
44 types_ += std::string(
45 proxy->raw_name()->raw_data(),
46 proxy->raw_name()->raw_data() + proxy->raw_name()->byte_length());
47 types_ += ": ";
48 }
49 AstNode::NodeType type = expression->node_type();
50 size_t i;
51 for (i = 0; i < arraysize(NodeTypeNameList); ++i) {
52 if (NodeTypeNameList[i].type == type) {
53 types_ += NodeTypeNameList[i].name;
54 break;
55 }
56 }
57 if (i == arraysize(NodeTypeNameList)) {
58 types_ += "unknown";
59 }
60
61 if (expression->bounds().lower->Is(Type::Integral32()) &&
62 expression->bounds().upper->Is(Type::Integral32())) {
63 types_ += ": Integral32";
64 } else if (expression->bounds().lower->Is(Type::UntaggedFloat64()) &&
65 expression->bounds().upper->Is(Type::UntaggedFloat64())) {
66 types_ += ": UntaggedFloat64";
67 } else {
68 types_ += ": Other";
69 }
70 types_ += "\n";
71 }
72
73
74 ExpressionTypeCollector::ExpressionTypeCollector(CompilationInfo* info)
75 : AstExpressionVisitor(info) {}
76 }
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698