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

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

Issue 1288773007: Adding visitors to regurgitate expression types or reset them. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: revision 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 #ifndef V8_EXPRESSION_TYPE_COLLECTOR_H_
6 #define V8_EXPRESSION_TYPE_COLLECTOR_H_
7
8 #include "src/ast-expression-visitor.h"
9
10 namespace v8 {
11 namespace internal {
12
13 // Macros to define checking of a tree walk.
titzer 2015/08/21 12:05:51 Can we move the macros to the test file?
bradn 2015/08/21 21:37:08 As they're shared, moved them to a separate header
14 // Assumes:
15 // * type walk result in "types"
16 // * HandlesAndZoneScope in "handles"
17 //
18 // Usage:
19 // CHECK_TYPES_BEGIN {
20 // CHECK_EXPR(Assignment, OTHER) {
21 // CHECK_VAR(a, OTHER);
22 // CHECK_VAR(b, OTHER);
23 // }
24 // } CHECK_TYPES_END
25
26 #define CHECK_TYPES_BEGIN \
27 { \
28 size_t index = 0; \
29 int depth = 0;
30
31 #define CHECK_TYPES_END \
32 CHECK_EQ(index, types.size()); \
33 }
34
35 #define DEFAULT_TYPE Bounds::Unbounded(handles.main_zone())
36 #define INT32_TYPE \
37 Bounds(Type::Signed32(handles.main_zone()), \
38 Type::Signed32(handles.main_zone()))
39
40 #define CHECK_EXPR(ekind, type) \
41 CHECK_LT(index, types.size()); \
42 CHECK(strcmp(#ekind, types[index].kind) == 0); \
43 CHECK_EQ(depth, types[index].depth); \
44 CHECK(type.lower->Is(types[index].bounds.lower)); \
45 CHECK(type.upper->Is(types[index].bounds.upper)); \
46 for (int j = (++depth, ++index, 0); j < 1 ? 1 : (--depth, 0); ++j)
47
48 #define CHECK_VAR(vname, type) \
49 CHECK_EXPR(VariableProxy, type); \
50 CHECK_EQ(#vname, std::string(types[index - 1].name->raw_data(), \
51 types[index - 1].name->raw_data() + \
52 types[index - 1].name->byte_length()));
53
54 // A Visitor over a CompilationInfo's AST that collects
55 // a human readable string summarizing structure and types.
56 // Used for testing of the typing information attached to the
57 // expression nodes of an AST.
58
59 struct ExpressionTypeEntry {
60 int depth;
61 const char* kind;
62 const AstRawString* name;
63 Bounds bounds;
64 };
65
66 class ExpressionTypeCollector : public AstExpressionVisitor {
67 public:
68 ExpressionTypeCollector(CompilationInfo* info,
69 ZoneVector<ExpressionTypeEntry>* dst);
70 void Run();
71
72 protected:
73 void VisitExpression(Expression* expression);
74
75 private:
76 ZoneVector<ExpressionTypeEntry>* result_;
77 };
78 }
79 } // namespace v8::internal
80
81 #endif // V8_EXPRESSION_TYPE_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698