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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: test/cctest/expression-type-collector.cc
diff --git a/test/cctest/expression-type-collector.cc b/test/cctest/expression-type-collector.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2278836508237a1e20b79325b7fe66852172d5a7
--- /dev/null
+++ b/test/cctest/expression-type-collector.cc
@@ -0,0 +1,77 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/v8.h"
+
+#include "test/cctest/expression-type-collector.h"
+
+#include "src/ast.h"
+#include "src/codegen.h"
+#include "src/scopes.h"
+
+namespace v8 {
+namespace internal {
+namespace {
+
+struct {
+ AstNode::NodeType type;
+ const char* name;
+} NodeTypeNameList[] = {
+#define DECLARE_VISIT(type) \
+ { AstNode::k##type, #type } \
+ ,
+ AST_NODE_LIST(DECLARE_VISIT)
+#undef DECLARE_VISIT
+};
+}
+
+
+std::string ExpressionTypeCollector::Run(CompilationInfo* info) {
+ ExpressionTypeCollector* visitor =
+ new (info->zone()) ExpressionTypeCollector(info);
+ visitor->VisitAll();
+ return visitor->types_;
+}
+
+
+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
+ VariableProxy* proxy = expression->AsVariableProxy();
+ for (int i = 0; i < depth(); ++i) {
+ types_ += " ";
+ }
+ if (proxy) {
+ types_ += std::string(
+ proxy->raw_name()->raw_data(),
+ proxy->raw_name()->raw_data() + proxy->raw_name()->byte_length());
+ types_ += ": ";
+ }
+ AstNode::NodeType type = expression->node_type();
+ size_t i;
+ for (i = 0; i < arraysize(NodeTypeNameList); ++i) {
+ if (NodeTypeNameList[i].type == type) {
+ types_ += NodeTypeNameList[i].name;
+ break;
+ }
+ }
+ if (i == arraysize(NodeTypeNameList)) {
+ types_ += "unknown";
+ }
+
+ if (expression->bounds().lower->Is(Type::Integral32()) &&
+ expression->bounds().upper->Is(Type::Integral32())) {
+ types_ += ": Integral32";
+ } else if (expression->bounds().lower->Is(Type::UntaggedFloat64()) &&
+ expression->bounds().upper->Is(Type::UntaggedFloat64())) {
+ types_ += ": UntaggedFloat64";
+ } else {
+ types_ += ": Other";
+ }
+ types_ += "\n";
+}
+
+
+ExpressionTypeCollector::ExpressionTypeCollector(CompilationInfo* info)
+ : AstExpressionVisitor(info) {}
+}
+}

Powered by Google App Engine
This is Rietveld 408576698